[antlr-interest] Find X :-)

Sameh W. Zaky sameh.wz at gmail.com
Tue May 18 10:24:48 PDT 2010


Yea that was helpful, Thanks :-)

On Tue, May 18, 2010 at 5:25 PM, John B. Brodie <jbb at acm.org> wrote:

> On Tue, 2010-05-18 at 17:10 +0200, Sameh W. Zaky wrote:
> > OK, Sorry for that!
> >
> > Just after I have sent this message I realized that the problem is that
> > ANTLR cannot find my method myLookUpMethod..
> > I have defined it in @members{} part of the grammar file.. But ANTLR
> still
> > cannot find it.. Any idea?
>
> since it is in the lexer, the method needs to be defined in a
> @lexer::members{} section....
>
> @members{} defaults to the parser when placed in a combined grammar.
>
> >
> > On Tue, May 18, 2010 at 4:35 PM, Sameh W. Zaky <sameh.wz at gmail.com>
> wrote:
> >
> > > Dear All,
> > >
> > > I have in my grammar:
> > >
> > > fragment UNIT_NAME :;
> > >
> > > ID : ('a'..'z'|'_')*
> > >  {
> > > if ( myLookUpMethod( *X* ) ) $type=UNIT_NAME;
> > >  }
> > > ;
> > > ===============================
> > >
> > > Instead of *X*, I wanna refer to the text that is in red.. For example,
> > > the token "w_aw_s"  is ID. I want to take the text of this token
> "w_aw_s"
> > > and look it up in a certain array and if it is in this array then I set
> its
> > > type to UNIT_NAME.
> > >
> > > P.S.: I tried to replace *X* with *$text* but I receive the error:
> > >
> > > [16:15:56] symbol  : method myLookUpMethod(java.lang.String)
> > > [16:15:56] location: class SimpleTestLexer
> > > [16:15:56]             if(myLookUpMethod(getText())) _type=UNIT_NAME;
> > > [16:15:56]                ^
> > > [16:15:56] 1 error
> > >
> > > Find X :-)
> > >
> > > Many Thanks !
> > > --
> > > Sameh W. Zaky
> > >
> >
> >
> >
>
>
>
>


-- 
Sameh W. Zaky


More information about the antlr-interest mailing list