[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to make Bison disregard tokens?
From: |
Tim Van Holder |
Subject: |
Re: How to make Bison disregard tokens? |
Date: |
Fri, 02 Mar 2007 15:32:10 +0100 |
User-agent: |
Thunderbird 1.5.0.10 (Windows/20070221) |
Edsko de Vries wrote:
> if(...)
> {
> blah
> // TODO: must do something else here
> }
>
> f();
>
> the comment is not associated with the call to f, but with a NOP
> instruction which is the last instruction in the body of the if. That
I would expect a } to be a token, so the comment would be associated
with that }, never with the f() call.
As long as you don't discard significant punctuation like this, I doubt
there is any need for NOPs.
> also works if the body of the if is completely empty, or if the comment
> is the very last thing in the file.
I use a fake EOF token to handle this case (because I deal with language
conversion (e.g. Natural to COBOL), it is fairly important for me to
attach comments to the most logically relevant token - that is the pain
in the ass part).
> Now when we combine it with the empty lines problem, suppose we have
> something like
>
> function g()
> {
> code 1
> code 2
> code 3
>
> // TODO: I need to do something here
>
> code 4
> code 5
> code 6
> }
>
> At the moment, what happens is that the comment gets associated with
> "code 4", and the blank lines are ignored entirely:
>
> function g()
> {
> code 1
> code 2
> code 3
> // TODO: I need to do something here
> code 4
> code 5
> code 6
> }
>
> If we do what you suggest, then we mark "code 3" as having three
> (including the line of the comment) blank lines after it (or,
> equivalently, code 4 as having three blank lines before it), but we
> still associate the comment with "code 4":
Sure but your question was blank lines, so I only offered a blank-lines
related answer.
But if you already have comments handled like this, why don't you simply
treat a blank line like a full-line comment (which it is, to some
extent)?
- Re: How to make Bison disregard tokens?, (continued)
- Re: How to make Bison disregard tokens?, Edsko de Vries, 2007/03/02
- Re: How to make Bison disregard tokens?, henrik . sorensen, 2007/03/02
- Re: How to make Bison disregard tokens?, Edsko de Vries, 2007/03/02
- Re: How to make Bison disregard tokens?, henrik . sorensen, 2007/03/02
- Re: How to make Bison disregard tokens?, Edsko de Vries, 2007/03/02
- Re: How to make Bison disregard tokens?, henrik . sorensen, 2007/03/02
- Re: How to make Bison disregard tokens?, Tim Van Holder, 2007/03/02
- Re: How to make Bison disregard tokens?, henrik . sorensen, 2007/03/02
- Re: How to make Bison disregard tokens?, Edsko de Vries, 2007/03/02
- Re: How to make Bison disregard tokens?, henrik . sorensen, 2007/03/02
- Re: How to make Bison disregard tokens?,
Tim Van Holder <=
- Re: How to make Bison disregard tokens?, Edsko de Vries, 2007/03/02
- Re: How to make Bison disregard tokens?, Edsko de Vries, 2007/03/02