From d8074fa5cb7a8d0e58482b0a9607f231b8864966 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Tue, 23 Aug 2022 01:30:56 -0400 Subject: [PATCH] Enum default values are now parsed properly Previously the parser would stay on the member name and parse it the default value. It now moves forward and catches the actual default value. --- parser/enum.go | 2 ++ parser/tree-tostring.go | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/parser/enum.go b/parser/enum.go index ca7c822..139cd9f 100644 --- a/parser/enum.go +++ b/parser/enum.go @@ -68,6 +68,8 @@ func (parser *ParsingOperation) parseEnumMembers ( err = parser.nextToken(lexer.TokenKindName) if err != nil { return } name := parser.token.Value().(string) + err = parser.nextToken() + if err != nil { return } // parse default value var argument Argument diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index a26c6c9..67eb8ef 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -335,19 +335,19 @@ func (section *EnumSection) ToString (indent int) (output string) { for _, name := range sortMapKeysAlphabetically(section.members) { output += doIndent(indent, name, " ") - member := section.members[name] + defaultValue := section.members[name] isComplexInitialization := - member.kind == ArgumentKindObjectInitializationValues || - member.kind == ArgumentKindArrayInitializationValues + defaultValue.kind == ArgumentKindObjectInitializationValues || + defaultValue.kind == ArgumentKindArrayInitializationValues - if member.value == nil { + if defaultValue.value == nil { output += "\n" } else if isComplexInitialization { output += "\n" - output += member.ToString(indent + 1, true) + output += defaultValue.ToString(indent + 1, true) } else { - output += " " + member.ToString(0, false) + output += " " + defaultValue.ToString(0, false) output += "\n" } }