diff --git a/parser/parser.go b/parser/parser.go index 9cb79cbb..d33892dd 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -451,6 +451,10 @@ func (p *parser) parseCall(token Token, arguments []Node, checkOverrides bool) N arguments = append(arguments, node) } + // skip last comma + if p.current.Is(Operator, ",") { + p.next() + } p.expect(Bracket, ")") node = &BuiltinNode{ @@ -486,6 +490,9 @@ func (p *parser) parseArguments(arguments []Node) []Node { if len(arguments) > offset { p.expect(Operator, ",") } + if p.current.Is(Bracket, ")") { + break + } node := p.parseExpression(0) arguments = append(arguments, node) } diff --git a/parser/parser_test.go b/parser/parser_test.go index 2a30787a..47b66484 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -647,6 +647,39 @@ world`}, Right: &BoolNode{Value: true}, }, }, + { + `all( + [true, false], + #, + )`, + &BuiltinNode{ + Name: "all", + Arguments: []Node{ + &ArrayNode{ + Nodes: []Node{ + &BoolNode{Value: true}, + &BoolNode{Value: false}, + }, + }, + &ClosureNode{ + Node: &PointerNode{}, + }, + }, + }, + }, + { + `func( + parameter1, + parameter2, + )`, + &CallNode{ + Callee: &IdentifierNode{Value: "func"}, + Arguments: []Node{ + &IdentifierNode{Value: "parameter1"}, + &IdentifierNode{Value: "parameter2"}, + }, + }, + }, } for _, test := range tests { t.Run(test.input, func(t *testing.T) {