parsing - shift/reduce conflict in cup parser (grammar with arrarys and matrices) -


i writing cup parser small language supposed support classes arrays , matrices fields. example, if there class instance:

c c; 

the fields accessed with:

c.x; c.y[]; c.z[][]; 

i having trouble writing production last part, because of shift/reduce conflict keep getting. production:

designator ::= ident                |                designator dot ident                |                designator lsquare expr rsquare                |                designator lsquare expr rsquare lsquare expr rsquare                ; 

warning : * shift/reduce conflict found in state #189 between designator ::= designator lsquare expr rsquare () , designator ::= designator lsquare expr rsquare () lsquare expr rsquare under symbol lsquare resolved in favor of shifting.

can me solve this?

the last designator line of grammer invalid. designator lsquare expr rsquare (two lines above) recursively defines jagged array expressions of arbitrary many dimensions.

according grammar, following expression valid:

c.y[a].b 

and following invalid:

c.y[a].z[b] 

is intention?

it might inspiring @ c# grammar knows jagged arrays.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -