[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug: inlining changes start state



I've encountered a bug where inlining the initial production causes the start state to change and therefore the grammar to be incorrect. I've already submitted this as a Trac bug but I don't know if anybody monitors that, so I apologize for the duplication.

Here's an example which seems to trigger the bug:

Productions
	expression = {atomic} atomic;
	formals = {one} pattern | {many} pattern comma formals;
	atomic =
		{name} name
		| {call} atomic lparen args? rparen
		| {dot} atomic dot name
		| {lambda} lambda lparen formals? rparen eq expression
		| {tuple} lparen args? rparen
		| {list} lbracket args? rbracket
		| {null} null
		| {int} int
		| {string} string
		| {true} true
		| {false} false;
	args = {one} expression | {many} expression comma args;

If I add an intentional LR conflict, for example by adding to formals:

 | formals [two]:formals

then SableCC will dump the inlined version of the productions and indeed "expression" has been entirely eliminated and the result looks like this:

Productions
    formals
         {-> P.formals  } =
...

I am aware of the --no-inline declaration, but the grammar I am working with is quite complex and manually inlining productions is not an option.

Thanks,
Adrian Quark