[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "Eating" comments: not with Flex but with Bison
From: |
Akim Demaille |
Subject: |
Re: "Eating" comments: not with Flex but with Bison |
Date: |
Tue, 14 Jun 2005 13:36:04 +0200 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
>>> "Frans" == Frans Englich <address@hidden> writes:
> I would prefer to do this at the Bison/Parser level because it is
> convenient: I have access to various information passed to the
> parse function,
You can easily make them available to the scanner. And in fact, you
probably should, to have a clean, pure, interface bw the two.
> the YYERROR macro, and the error function.
There is nothing wrong with defining a token, but not allowing it in
the grammar. Just return it when there is a comment (and you don't
want them), then you'll have the expected result: a parser error.
> The problem I see if I let Flex return a COMMENT token and add a
> non-terminal in the Bison grammar to implement the checking, is how
> to make it play well with the other rules -- the token gets in the
> way.
Of course you must not try to use the token COMMENT when comment are
valid, just discard them.