[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to use our own token ?
From: |
Aurelien Tran |
Subject: |
Re: How to use our own token ? |
Date: |
Thu, 28 Jan 2010 18:11:53 -0800 (PST) |
Hans Aberg wrote:
>
> On 28 Jan 2010, at 07:34, Aurelien Tran wrote:
>
>> I have my own lexer which is returning me a token_type identifier
>> define as
>> follow:
>>
>> namespace mynamespace {
>> enum token_type {
>> mytoken1 = 123,
>> mytoken2 = 456,
>> mytoken3 = 789
>> };
>> }
>> When I tried to write the parser, how do I need to write the bison
>> script to
>> use my token system ?
>
> Use 'bison --defines' - see manual or 'bison --help', which then
> writes a header .tab.h, which contains stuff like:
> enum yytokentype {
> token_error = 258,
> help_key = 259,
> quit_key = 260,
> ...
> }
>
> Include this header in the lexer file, and use those names.
>
> Hans
>
>
Thank you Hans for this answer,
I know that this is the general way to do this but the lexer is in fact an
external module that I cant modify. I would like to avoid rewriting all the
token and their value in another file. If need to I will but I would to
avoid it in order to have more maintainable source code.
I just want to be sure that Bison do not support this kind of feature (Which
is actually the real purpose of my post here).
Aurelien
--
View this message in context:
http://old.nabble.com/How-to-use-our-own-token---tp27351674p27365736.html
Sent from the Gnu - Bison - Help mailing list archive at Nabble.com.