[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reserved Words
From: |
Mike Aubury |
Subject: |
Re: Reserved Words |
Date: |
Thu, 20 Feb 2003 17:05:55 +0000 |
Cheers for that - I actually managed to do it a different way...
Using bison 1.875 - there is a -r all option - I used this to create a
y.output which (helpfully) descends states (unlike some older versions..) and
prints all the possible tokens at each state..
Using a %pure_parser - I pass that state into my yylex - and then check to see
if the token is allowed in that state...
If it is - then I let it through, if its not - the I convert it to the
identifier token (after checking it looks like an identifier a-z etc)...
Seems to work like a charm... (Over 500,000 lines of our language source code
correctly parsed as a test).
Long story short - I've tried to attach the script - if it gets kicked off -
you can look for mk_states_c in the aubit project on sourceforge....
On Thursday 20 February 2003 2:57 pm, Akim Demaille wrote:
> | Is there a version of Bison which can handle this situation ?
> |
> | Are there any simple solutions (maybe using other compatible
> | compilers - I've got a lot of code so I don't want to manually
> | convert it) ?
>
> You might want to try recent versions of Bison, and the GLR output.
> The idea is:
>
> string: DEFINE;
> string: DECLARE;
> string: DATE;
>
> definition: DEFINE string string
>
> etc. for each keyword. Then, the GLR parser will keep only the valid
> interpretation, even with "define define define" (not that I would
> recommend such a syntax).
>
> | Are there any hacks I can make in Bison ?
>
> Yep. Look for Heisenberg tokens on the web, it's an alternative.
mk_states_c
Description: Text document