[antlr-interest] Re: generated code not compilable - with par amet ers.
praveen_c
praveen_c at yahoo.com
Wed Oct 30 13:09:43 PST 2002
Good idea! I'll try that.
Thanks.
--- In antlr-interest at y..., mzukowski at y... wrote:
> or make a top level rule that calls a protected TEXT with the
correct value,
> e.g.
>
> TOP_TEXT: TEXT(false);
>
> Monty
>
> > -----Original Message-----
> > From: praveen_c [mailto:praveen_c at y...]
> > Sent: Wednesday, October 30, 2002 11:59 AM
> > To: antlr-interest at y...
> > Subject: [antlr-interest] Re: generated code not compilable - with
> > paramet ers.
> >
> >
> > This rule( TEXT ) is referred in some other rule with a slightly
> > different twist ( which is why I had the boolean in the first
> > place ). I wanted to reuse the same rule without having to code
> > another one again.
> >
> > I could use an instance variable, but I wanted to stay away from
it
> > because then I will have to make sure that I set/reset the
instance
> > variables at various points. I can see it getting a bit complex.
> >
> > I'll go with copying the rule into the place where I was
referring to
> > this one. If you guys can think of other alternatives please let
me
> > know.
> >
> > Thanks,
> > Praveen.
> >
> > --- In antlr-interest at y..., mzukowski at y... wrote:
> > > Where is that param coming from? nextToken() doesn't know
anything
> > about
> > > it. It doesn't make sense to have a parameter passed in to a
non-
> > protected
> > > rule in the lexer. Why don't you use an instance variable?
> > >
> > > Monty
> > >
> > > > -----Original Message-----
> > > > From: praveen_c [mailto:praveen_c at y...]
> > > > Sent: Wednesday, October 30, 2002 9:54 AM
> > > > To: antlr-interest at y...
> > > > Subject: [antlr-interest] generated code not compilable - with
> > > > parameters.
> > > >
> > > >
> > > > I got ANT 2.7.2 and got rid of the previous problem. Thanks
guys.
> > > >
> > > > Looks like I'm onto the next one. I pasted the rule and code
> > fragment
> > > > at the end of this message. Line 15 of the generated code
should
> > have
> > > > an additional boolean parameter. How do I tell ant to
generate an
> > > > additional param?? I don't think I've control on that.
> > > >
> > > > Please help.
> > > >
> > > > Thanks,
> > > > Praveen.
> > > >
> > > > ------------------------GRAMMAR-----------------------
> > > > TEXT [boolean stopAtEndingAngleBracket]: (END_LOOP) =>
END_LOOP
> > {
> > > > $setType(END_LOOP); } |
> > > > (
> > > > options
> > > > {
> > > > generateAmbigWarnings=false;
> > > > }:
> > > > ( { !isEndOfText(stopAtEndingAngleBracket) }? . )
*
> > > > );
> > > > ------------------------END GRAMMAR-----------------------
> > > >
> > > > ------------------------GENERATED CODE--------------------
> > > > 1 public Token nextToken() throws TokenStreamException {
> > > > 2 Token theRetToken=null;
> > > > 3 tryAgain:
> > > > 4 for (;;) {
> > > > 5 Token _token = null;
> > > > 6 int _ttype = Token.INVALID_TYPE;
> > > > 7 resetText();
> > > > 8 try { // for char stream error handling
> > > > 9 try { // for lexical error handling
> > > > 10 if ((LA(1)=='<') &&
> > (LA(2)=='@')) {
> > > > 11 mTAG(true);
> > > > 12
> > theRetToken=_returnToken;
> > > > 13 }
> > > > 14 else {
> > > > 15 mTEXT(true);
> > > > 16
> > theRetToken=_returnToken;
> > > > 17 }
> > > > -------------------------------------------------------------
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Your use of Yahoo! Groups is subject to
> > > http://docs.yahoo.com/info/terms/
> >
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list