Synonyms in Bison/yacc?

Kai-Mikael =?iso-8859-1?Q?J=E4=E4=2DAro?= <kai@nada.kth.se>
3 Apr 1998 17:16:46 -0500

          From comp.compilers

Related articles
Synonyms in Bison/yacc? kai@nada.kth.se (Kai-Mikael =?iso-8859-1?Q?J=E4=E4=2DAro?=) (1998-04-03)
Re: Synonyms in Bison/yacc? vladimir@cs.ualberta.ca (Vladimir Alexiev) (1998-04-09)
| List of all articles for this month |
From: Kai-Mikael =?iso-8859-1?Q?J=E4=E4=2DAro?= <kai@nada.kth.se>
Newsgroups: comp.compilers
Date: 3 Apr 1998 17:16:46 -0500
Organization: Royal Institute of Technology
Keywords: yacc, question

I am writing a parser where I for reasons of clarity would like to
refer to a given construct by one token name in one context and by
another name in another context, e g use the token name INT for [0-9]+
in one place and NUMBER in another.


Basically I would like to just stick in a =


#define NUMBER INT


somewhere, but bison doesn't like this at all. Neither was I allowed to
say
%token INT 4711 NUMBER 4711


Of course I could just have a flag and let yylex return one or the
other depending on the flag, but I was hoping there would be a more
elegant way. Suggestions?
-- =


Kai-Mikael J=E4=E4-Aro email: kai@nada.kth.se
CID voice: +46 8 790 62 79
NADA, KTH fax: +46 8 10 24 77
SE-100 44 Stockholm telex: 812 6154 1156 SICS
SWEDEN teletex:2401-812 6154 1156 SICS
[In your parser, write


NUMBER: INT ;


and just return INT in the lexer. -John]




--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.