Fixed enum parsing
I think I did anyways. It wont parse either way becasue I haven't implemented lists.
This commit is contained in:
parent
38409db74b
commit
37a216a53d
@ -61,18 +61,11 @@ func (parser *ParsingOperation) parseEnumMembers (
|
||||
// if we've left the block, stop parsing
|
||||
if !parser.token.Is(lexer.TokenKindIndent) { return }
|
||||
if parser.token.Value().(int) != 1 { return }
|
||||
err = parser.nextToken(lexer.TokenKindMinus)
|
||||
if err != nil { return }
|
||||
|
||||
var member EnumMember
|
||||
member, err = parser.parseEnumMember()
|
||||
into.members = append(into.members, member)
|
||||
if err != nil { return }
|
||||
|
||||
err = parser.expect(lexer.TokenKindNewline)
|
||||
if err != nil { return }
|
||||
err = parser.nextToken()
|
||||
if err != nil { return }
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +74,7 @@ func (parser *ParsingOperation) parseEnumMember () (
|
||||
member EnumMember,
|
||||
err error,
|
||||
) {
|
||||
err = parser.expect(lexer.TokenKindMinus)
|
||||
err = parser.nextToken(lexer.TokenKindMinus)
|
||||
if err != nil { return }
|
||||
|
||||
// get name
|
||||
@ -98,6 +91,9 @@ func (parser *ParsingOperation) parseEnumMember () (
|
||||
// if we have exited the member, return
|
||||
if !parser.token.Is(lexer.TokenKindIndent) { return }
|
||||
if parser.token.Value().(int) != 2 { return }
|
||||
|
||||
err = parser.nextToken()
|
||||
if err != nil { return }
|
||||
}
|
||||
|
||||
// get value
|
||||
@ -105,5 +101,8 @@ func (parser *ParsingOperation) parseEnumMember () (
|
||||
err = parser.expect(lexer.TokenKindNewline)
|
||||
if err != nil { return }
|
||||
|
||||
err = parser.nextToken()
|
||||
if err != nil { return }
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -215,8 +215,10 @@ func (section EnumSection) ToString (indent int) (output string) {
|
||||
section.what.ToString(), "\n")
|
||||
|
||||
for _, member := range section.members {
|
||||
output += doIndent(indent + 1, "- ", member.name, "")
|
||||
output += member.argument.ToString(indent, false)
|
||||
output += doIndent(indent + 1, "- ", member.name)
|
||||
if member.argument.kind != ArgumentKindNil {
|
||||
output += " " + member.argument.ToString(indent, false)
|
||||
}
|
||||
output += "\n"
|
||||
}
|
||||
return
|
||||
|
Reference in New Issue
Block a user