Right now this only breaks tree parsers. However, the fundamental
semantics of the mark/rewind operation indicate they should come in
pairs.

There is a matched mark/rewind inside each of the semantic predicate
evaluation functions. I'm not even sure this rewind is needed, but I
also don't have proof that it's not.

Sam

-----Original Message-----
From: Terence Parr [mailto:[email protected]] 
Sent: Tuesday, March 03, 2009 7:43 PM
To: Sam Harwell
Cc: [email protected]
Subject: Re: [antlr-dev] cyclicDFAState template incompatible with
unbuffered tree node streams


On Mar 3, 2009, at 4:06 PM, Sam Harwell wrote:

> 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.

oh right!  that used to work because we buffered up the entire thing.  
thanks for catching this Sam!

>
> /** A state in a cyclic DFA; it's a special state and part of a big  
> switch on
>  *  state.
>  */
> cyclicDFAState 
> (decisionNumber,stateNumber,edges,needErrorClause,semPredState) ::= <<
> 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.

Hmm...now I have to remember what the hell I meant the stuff to do.

I assume this is for a tree parser since the parser is not yet using  
the fast queue?
Ter
_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org/mailman/listinfo/antlr-dev

Reply via email to