I have a grammar in which I would like to include multi-parameter functions (e.g. f(x,y) ). I use AST output with my own tree parser. Production parameter list right now
paramdefs: (ID COMMA)* ID ;
This works fine, but AST output for
z(x,y)=expression
is an
(FUNC (z)(x)(,)(y)(expression))
(that is, it is very flat).
FUNC CommonTree children are generally { function name , parameter , comma , parameter , defined expression } for any number of parameters. I would like the parameter list to be an only child and not have commas (this would make it easier to move around the tree).
Ideally, this would look like a tree:
(FUNC (z)((x)(y))(expression))
(note the absence of a comma element and the grouping of x and y .
Relevant related areas of grammar:
funcdef: ID '(' paramdefs ')' '=' expr -> ^(FUNC ID paramdefs expr) ; paramdefs: (ID COMMA)* ID ;
source share