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.
This commit is contained in:
Sasha Koshka 2022-08-23 01:30:56 -04:00
parent 6a6fe8353e
commit d8074fa5cb
2 changed files with 8 additions and 6 deletions

View File

@ -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

View File

@ -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"
}
}