here's part from my grammar.
statement
: assignmentStatement
| doLoopStatement
| whileStatement
| ifStatement
| procedureCallStatement
;
functio开发者_如何学Cn
: 'FUNCTION' IDENT '(' parameters? ')' ':' type ':='
(variable (';' variable)*)?
'BEGIN'
main_body //body can be empty
return_Statement
'END' IDENT
;
where main_body is:
main_body
: (statement (';' statement)*)?
;
now, before creating my AST, I need to fix the return statement,
the problem is that the assignmentStatement and return_Statement
and so I'm getting a LL(*) error from the parser, as it does not know what to choose.
assignmentStatement
: IDENT ':=' expression
;
return_Statement
: IDENT ':=' expression
;
any ideas?
If assignmentStatement is really supposed to be identical to return_Statement then there's no reason to have both. Eliminate the return_Statement rule and in your function rule replace it with assignmentStatement.
加载中,请稍侯......
精彩评论