I'm trying to write a parser using JFlex and Cup, but I have some issues dealing with recursive pointed notation like function call with recursive properties access like :
var x = obj.property1.functionCall(p1, p2).property2;
Here is the related parser definition:
unary_exp ::= postfix_exp
| ADD2 unary_exp
| SUB2 unary_exp
| unary_operator unary_exp;
unary_operator ::= ADD
| SUB
| BIT_NOT
| NOT;
postfix_exp ::= primary_exp
| postfix_exp LPAR_SQ right_value_exp RPAR_SQ
| postfix_exp LPAR optional_postfix_exp_list RPAR
| postfix_exp DOT postfix_exp
| postfix_exp SUB2
| postfix_exp ADD2;
primary_exp ::= BOOL
| STRING
| INTEGER
| NUMBER
| NULL;
I got following shift/reduce conflicts :
Warning : *** Shift/Reduce conflict found in state #190
between postfix_exp ::= postfix_exp DOT postfix_exp (*)
and postfix_exp ::= postfix_exp (*) LPAR optional_postfix_exp_list RPAR
under symbol LPAR
Resolved in favor of shifting.
Warning : *** Shift/Reduce conflict found in state #190
between postfix_exp ::= postfix_exp DOT postfix_exp (*)
and postfix_exp ::= postfix_exp (*) LPAR_SQ right_value_exp RPAR_SQ
under symbol LPAR_SQ
Resolved in favor of shifting.
Warning : *** Shift/Reduce conflict found in state #190
between postfix_exp ::= postfix_exp DOT postfix_exp (*)
and postfix_exp ::= postfix_exp (*) DOT postfix_exp
under symbol DOT
Resolved in favor of shifting.
Warning : *** Shift/Reduce conflict found in state #190
between postfix_exp ::= postfix_exp DOT postfix_exp (*)
and postfix_exp ::= postfix_exp (*) ADD2
under symbol ADD2
Resolved in favor of shifting.
Warning : *** Shift/Reduce conflict found in state #190
between postfix_exp ::= postfix_exp DOT postfix_exp (*)
and postfix_exp ::= postfix_exp (*) SUB2
under symbol SUB2
Resolved in favor of shifting.
Error : *** More conflicts encountered than expected -- parser generation aborted
May someone explain to me how to deal with these conflicts or where to find a working example using java cup, yacc or bison?