[antlr-interest] Re: upgrade question

nagii5 nagii5 at yahoo.com
Sun Feb 17 13:38:15 PST 2002


Thanks, Terrence
had another question on similar lines.
with 2.7.0 the following grammer would work

protected SAMPLE: ( {!(LA(1) == '<' &&  LA(2) == '/' LA(3) == 'f'
&& LA(4) == 'o' && LA(5) == 'o' && LA(6) == '>' } ? NL_CTR )* ;

with 2.7.1,  i changed the above to look like

protected SAMPLE: ( options{greedy=false;} : NL_CTR )* ;

protected NL_CTR: c:. {if(c=='\n') newline();} ;

and the generated code looks exactly as the documentation says
k = 3 isnt enough for such a rule.

what do you suggest i should do in this case.
meaning should i increase my look ahead to the maximum needed 
i.e. in this case k = 6. 
or should i rather use some other way to deal with such rules.
which say everything but </foo> 
TIA
nagesh


--- In antlr-interest at y..., Terence Parr <parrt at j...> wrote:
> 
> On Friday, February 15, 2002, at 06:31  PM, nagii5 wrote:
> 
> > Upgrading from 2.7.0 to 2.7.1
> >
> > So i had this Token
> >
> > protected SCRIPT: "<%" MY_CONTENT "%>" ;
> >
> > protected MY_CONTENT
> >   : ~('!' | '=' | '@' | '-' | '%' | '\uffff')
> >     ( {!(LA(1) == '%' && LA(2) == '>') }? NL_CTR )* ;
> 
> Try ( options {greedy=false;} : . ) * for MY_CONTENT.  It should 
stop 
> when it sees %>.
> 
> Ter
> >
> > protected NL_CTR :c:. { if (c=='\n') newline(); } ;
> >
> > also my
> > charVocabulary = '\3'..'\uffff'
> >
> >
> > Doesnt seem to get kicked in..
> > AM i doing anything wrong?
> > why is the generated code different in both cases?
> > and why did this work with 270?
> >
> > TIA
> > nagesh
> >
> >
> >
> >
> >
> >
> > Your use of Yahoo! Groups is subject to 
> > http://docs.yahoo.com/info/terms/
> >
> >
> --
> Chief Scientist & Co-founder, http://www.jguru.com
> Creator, ANTLR Parser Generator: http://www.antlr.org


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list