diff --git a/parser/enum.go b/parser/enum.go index 06e110b..c2427d9 100644 --- a/parser/enum.go +++ b/parser/enum.go @@ -103,7 +103,7 @@ func (parser *ParsingOperation) parseEnumMember () ( if err != nil { return } err = parser.expect ( lexer.TokenKindLessThan, - lexer.TokenKindGreaterThan) + lexer.TokenKindLParen) if err != nil { return } if parser.token.Is(lexer.TokenKindLessThan) { diff --git a/parser/enum_test.go b/parser/enum_test.go index 582084e..c6c8c75 100644 --- a/parser/enum_test.go +++ b/parser/enum_test.go @@ -20,14 +20,33 @@ enum ro AffrontToGod:Int:4 3 4> enum ro NamedColor:U32 - - red: <0xFF0000> - - green: <0x00FF00> - - blue: <0x0000FF> -enum ro ThisIsTerrible:Obj:(.rw x:Int .rw y:Int) - - up: (.x: 0 .y: -1) - - down: (.x: 0 .y: 1) - - left: (.x: -1 .y: 0) - - right: (.x: 1 .y: 0) + - red:<0xFF0000> + - green:<0x00FF00> + - blue:<0x0000FF> +enum ro ThisIsTerrible:Obj: + ( + .rw x:Int + .rw y:Int + ) + - up: + ( + .x:<0> + .y:<-1> + ) + - down: + ( + .x:<0> + .y:<1>) + - left: + ( + .x:<-1> + .y:<0> + ) + - right: + ( + .x:<1> + .y:<0> + ) enum ro Weekday:Int - sunday - monday diff --git a/parser/misc.go b/parser/misc.go index 9d54782..ebe2e00 100644 --- a/parser/misc.go +++ b/parser/misc.go @@ -12,7 +12,10 @@ func (parser *ParsingOperation) parseIdentifier () ( identifier.location = parser.token.Location() for { - if !parser.token.Is(lexer.TokenKindName) { break } + if !parser.token.Is(lexer.TokenKindName) { + parser.previousToken() + break + } identifier.trail = append ( identifier.trail, diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index f0cf4b4..31bbfb2 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -364,10 +364,10 @@ func (section EnumSection) ToString (indent int) (output string) { member.value.kind == ArgumentKindArrayDefaultValues if isComplexInitialization { - output += "\n" + output += ":\n" output += member.value.ToString(indent + 2, true) } else if member.value.kind != ArgumentKindNil { - output += " " + member.value.ToString(0, false) + output += ":<" + member.value.ToString(0, false) + ">" } output += "\n" } diff --git a/parser/type-notation.go b/parser/type-notation.go index 1c7b50c..44c6b9a 100644 --- a/parser/type-notation.go +++ b/parser/type-notation.go @@ -6,7 +6,10 @@ import "git.tebibyte.media/arf/arf/types" // parseType parses a type notation of the form Name, {Name}, etc. func (parser *ParsingOperation) parseType () (what Type, err error) { + println("START") + defer println("END") err = parser.expect(lexer.TokenKindName, lexer.TokenKindLBrace) + println(parser.token.Describe()) if err != nil { return } what.location = parser.token.Location() @@ -181,11 +184,11 @@ func (parser *ParsingOperation) parseObjectDefaultValueAndMembers () ( } else if parser.token.Is(lexer.TokenKindPermission) { // parsing a member declaration var member TypeMember - member, - err = parser.parseObjectNewMember() + member, err = parser.parseObjectNewMember() // TODO: error on duplicate members = append(members, member) + if err != nil { return } } }