bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using existing token values


From: Akim Demaille
Subject: Re: Using existing token values
Date: Tue, 26 Jul 2011 13:13:43 +0200

Le 18 juil. 2011 à 10:45, Ludovic Courtès a écrit :

> Hi,

Hi!

> I’m writing a parser where the lexer already has #defines or enum values
> for all the tokens.  So I’d like to write, say:
> 
>  %token YCPP_NAME CPP_NAME
> 
> or just
> 
>  %token CPP_NAME
> 
> where ‘CPP_NAME’ is a CPP macro expanding to an integer constant, or an
> enum value, already defined elsewhere.
> 
> However, ‘%token CPP_NAME’ yields a new #define CPP_NAME, and in
> ‘%token YCPP_NAME CPP_NAME’ the second argument is interpreted as an
> alternate name for the token.
> 
> Any idea how to achieve this?

Well, you will really have to preprocess your file if you want to do that.  
Bison really needs to know the values, it's not just something it can just 
forward to the output file.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]