[antlr-interest] Keyword match

Alexey Demakov demakov at ispras.ru
Wed Aug 24 05:30:41 PDT 2005


I think tokens block is not required in this case.
It is very hard to say why parser hangs without lexer/parser sources.

Regards,
Alexey

-----
Alexey Demakov
TreeDL: Tree Description Language: http://treedl.sourceforge.net
RedVerst Group: http://www.unitesk.com


----- Original Message ----- 
From: "Ersin Er" <ersin_er at yahoo.com>
To: <antlr-interest at antlr.org>
Sent: Wednesday, August 24, 2005 4:25 PM
Subject: Re: [antlr-interest] Keyword match


> Ok, now I have an identifier rule. Do I need a tokens block? As I said,
> my program just hangs when i do the identifier block and testLiterals
> stuff.
> 
> Thanks.
> 
> -- Ersin
> 
> --- Alexey Demakov <demakov at ispras.ru> wrote:
> 
> > If you have no identifier rule in lexer, you should define all
> > keywords in lexer rules:
> > 
> > BASE : "base" ;
> > 
> > Otherwise keywords should be in tokens section:
> > 
> > tokens
> > {
> >   BASE = "base";
> > }
> > 
> > And use tokens instead of strings in parser:
> > 
> > ss_base :
> >      BASE l_name=localName
> >      {
> >          // do something with l_name
> >      }
> >      ;
> > 
> > I beleive that strings in parser rules are processed correctly only
> > when
> > they are belong to some lexer rule where literals are tested.
> > 
> > Regards,
> > Alexey
> > 
> > -----
> > Alexey Demakov
> > TreeDL: Tree Description Language: http://treedl.sourceforge.net
> > RedVerst Group: http://www.unitesk.com
> > 
> > ----- Original Message ----- 
> > From: "Ersin Er" <ersin_er at yahoo.com>
> > To: <antlr-interest at antlr.org>
> > Sent: Wednesday, August 24, 2005 3:48 PM
> > Subject: Re: [antlr-interest] Keyword match
> > 
> > 
> > > Hi,
> > > 
> > > I have more information about the problem now:
> > > 
> > > If I do not have an identifier rule and if I have keywords in the
> > > grammar then the problem I explained in my previous mail (below)
> > occurs
> > > (and this is normal I think). If I have include the indentifier
> > rule in
> > > the lexer and if I do the testLiterals stuff and when I try to test
> > the
> > > parser it just HANGS without any messages.
> > > 
> > > Now, is there any suggestions?
> > > 
> > > -- Ersin
> > > 
> > > --- Ersin Er <ersin_er at yahoo.com> wrote:
> > > 
> > > > Hi all,
> > > > 
> > > > I have problem with keyword in my language. Here is a simple
> > > > production
> > > > (some action code ommited for briefness):
> > > > 
> > > > ss_base :
> > > >     "base" l_name=localName
> > > >     {
> > > >         // do something with l_name
> > > >     }
> > > >     ;
> > > > 
> > > > What ANTLR says about this grammar is:
> > > > 
> > > > "unexpected char 'b'"
> > > > 
> > > > The 'b' here is the 'b' of the "base". I face the same problem
> > with
> > > > all
> > > > my keywords. ANTLR allways complain about the first character of
> > any
> > > > keyword in the parser productions. I did the testLiterals trick
> > but
> > > > it
> > > > did not help and in fact I do not have an identifier type)
> > > > 
> > > > Can you help please?
> > > > 
> > > > Greetings.
> > > > 
> > > > -- Ersin
> > > > 
> > > > 
> > > > 
> > > > __________________________________ 
> > > > Do you Yahoo!? 
> > > > Yahoo! Mail - Helps protect you from nasty viruses. 
> > > > http://promotions.yahoo.com/new_mail
> > > > 
> > > 
> > > 
> > > --
> > > Ersin ER
> > > Arastirma Gorevlisi
> > > Hacettepe Universitesi
> > > Bilgisayar Muhendisligi Bolumu
> > > 
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam?  Yahoo! Mail has the best spam protection around 
> > > http://mail.yahoo.com
> > 
> > 
> 
> 
> 
> 
> ____________________________________________________
> Start your day with Yahoo! - make it your home page 
> http://www.yahoo.com/r/hs 
> 



More information about the antlr-interest mailing list