help-bison
[Top][All Lists]
Advanced

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

Re: How to make Bison disregard tokens?


From: Edsko de Vries
Subject: Re: How to make Bison disregard tokens?
Date: Fri, 2 Mar 2007 14:39:30 +0000
User-agent: Mutt/1.5.9i

Hey,

> 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.

Alas, I cannot do that, because we don't represent the } in the abstract
syntax. 

> 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).

Again, not a solution for us, since we wouldn't represent the EOF token as part 
of the abstract syntax. 

> 
> > 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.

Yeah, that's fair enough :) 

> 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)?

Hmmm. That is an interesting suggestion! I'll have to give that some
thought, but that might work! Thanks! 

Edsko




reply via email to

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