Im writing a parser than can parse expressions like myfunc1()
, myfunc2(param1)
and myfunc3(param1, param2)
(with an unknown amount of parameters). Now I'm trying to get my parse expressions right. I'm using the Lemon Parser Generator. Here is what I've come up with:
application(res) ::= APPLICATIONNAME(a) BRACE_OPEN params BRACE_CLOSE. {res = a;}
application(res) ::= APPLICATIONNAME(a) BRACE_OPEN BRACE_CLOSE. {res = a;}
params ::= PARAM(p). {res = p;}
params ::= SEPARATOR.
Never mind the contents of the curly braces for the moment. The params
definition allows empty params (several separators after each other), which is ok at the moment. But how would I have to change the definition to force non-empty parameters but still have all parameters separated by the SEPARATOR
token?