Taken from Java.stg, we end up with a mismatched mark/rewind, which
causes the temporary stream buffer (FastQueue) to flush during a predict
operation that encounters predicates.

 

/** A state in a cyclic DFA; it's a special state and part of a big
switch on

 *  state.

 */

cyclicDFAState(decisionNumber,stateNumber,edges,needErrorClause,semPredS
tate) ::= <<

int LA<decisionNumber>_<stateNumber> = input.LA(1);<\n>

<if(semPredState)> <! get next lookahead symbol to test edges, then
rewind !>

int index<decisionNumber>_<stateNumber> = input.index();

input.rewind();<\n>

<endif>

s = -1;

<edges; separator="\nelse ">

<if(semPredState)> <! return input cursor to state before we rewound !>

input.seek(index<decisionNumber>_<stateNumber>);<\n>

<endif>

if ( s>=0 ) return s;

break;

>> 

 

For now I noticed it "works" to simply add a call input.mark() right
after the call to input.rewind(), but I don't think that's the proper
solution.

 

Sam

_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org/mailman/listinfo/antlr-dev

Reply via email to