From 39f8d7e4ac64eec84c338d20a3265a7218af96e8 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Wed, 24 Aug 2022 00:25:52 -0400 Subject: [PATCH] Fixed parsing of interface section behaviors --- examples/full/main.arf | 2 +- parser/face.go | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/full/main.arf b/examples/full/main.arf index 8990b62..9db675a 100644 --- a/examples/full/main.arf +++ b/examples/full/main.arf @@ -9,7 +9,7 @@ data pv helloText:String "Hello, world!" # this is a struct definition objt ro Greeter:Obj - wr text:String "Hi." + rw text:String "Hi." # this is a function func ro main diff --git a/parser/face.go b/parser/face.go index a6b96eb..d0e1b64 100644 --- a/parser/face.go +++ b/parser/face.go @@ -34,7 +34,7 @@ func (parser *ParsingOperation) parseFaceSection () ( if err != nil { return } section.inherits = parser.token.Value().(string) if err != nil { return } - err = parser.expect(lexer.TokenKindNewline) + err = parser.nextToken(lexer.TokenKindNewline) if err != nil { return } err = parser.nextToken() if err != nil { return } @@ -46,8 +46,6 @@ func (parser *ParsingOperation) parseFaceSection () ( if parser.token.Value().(int) != 1 { return } // parse behavior - err = parser.nextToken(lexer.TokenKindName) - if err != nil { return } behaviorBeginning := parser.token.Location() var behavior FaceBehavior behavior, err = parser.parseFaceBehavior() @@ -74,18 +72,21 @@ func (parser *ParsingOperation) parseFaceBehavior () ( behavior FaceBehavior, err error, ) { + err = parser.expect(lexer.TokenKindIndent) + if err != nil { return } + // get name err = parser.nextToken(lexer.TokenKindName) if err != nil { return } behavior.name = parser.token.Value().(string) + err = parser.nextToken(lexer.TokenKindNewline) + if err != nil { return } + err = parser.nextToken() + if err != nil { return } + for { - err = parser.nextToken(lexer.TokenKindNewline) - if err != nil { return } - // if we've left the block, stop parsing - err = parser.nextToken() - if err != nil { return } if !parser.token.Is(lexer.TokenKindIndent) { return } if parser.token.Value().(int) != 2 { return }