diff --git a/parser/face.go b/parser/face.go index 776f198..80368e7 100644 --- a/parser/face.go +++ b/parser/face.go @@ -47,11 +47,13 @@ func (parser *ParsingOperation) parseFaceSection () ( if parser.token.Is(lexer.TokenKindName) { // parse type interface + section.kind = FaceKindType parser.previousToken() section.behaviors, err = parser.parseFaceBehaviors() if err != nil { return } } else { // parse function interface + section.kind = FaceKindFunc parser.previousToken() section.inputs, section.outputs, err = parser.parseFaceBehaviorArguments(1) @@ -157,15 +159,16 @@ func (parser *ParsingOperation) parseFaceBehaviorArguments ( if err != nil { return } declaration.what, err = parser.parseType() if err != nil { return } - err = parser.expect(lexer.TokenKindNewline) - if err != nil { return } - err = parser.nextToken() - if err != nil { return } if kind == lexer.TokenKindGreaterThan { inputs = append(inputs, declaration) } else { outputs = append(outputs, declaration) } + + err = parser.expect(lexer.TokenKindNewline) + if err != nil { return } + err = parser.nextToken() + if err != nil { return } } } diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index 0896e16..ab75531 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -250,10 +250,21 @@ func (section FaceSection) ToString (indent int) (output string) { section.name, ":", section.inherits.ToString(), "\n") - for _, name := range sortMapKeysAlphabetically(section.behaviors) { - behavior := section.behaviors[name] - output += behavior.ToString(indent + 1) + if section.kind == FaceKindType { + for _, name := range sortMapKeysAlphabetically(section.behaviors) { + behavior := section.behaviors[name] + output += behavior.ToString(indent + 1) + } + } else if section.kind == FaceKindFunc { + for _, inputItem := range section.inputs { + output += doIndent(indent + 1, "> ", inputItem.ToString(), "\n") + } + + for _, outputItem := range section.outputs { + output += doIndent(indent + 1, "< ", outputItem.ToString(), "\n") + } } + return } diff --git a/parser/tree.go b/parser/tree.go index 35eb8fd..f46e053 100644 --- a/parser/tree.go +++ b/parser/tree.go @@ -196,7 +196,8 @@ type EnumSection struct { type FaceKind int const ( - FaceKindType FaceKind = iota + FaceKindEmpty FaceKind = iota + FaceKindType FaceKindFunc )