revert-complexity #7

Merged
sashakoshka merged 34 commits from revert-complexity into main 2022-09-29 14:06:54 -06:00
2 changed files with 11 additions and 10 deletions
Showing only changes of commit 37a216a53d - Show all commits

View File

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

View File

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