help-bison
[Top][All Lists]
Advanced

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

Re: #line format


From: Akim Demaille
Subject: Re: #line format
Date: 12 Apr 2002 10:02:44 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp)

| > From: Akim Demaille <address@hidden>
| > Date: 11 Apr 2002 12:08:20 +0200
| 
| > | Can't you solve the problem by having the #line directive refer
| > | instead to some template file like bison.simple, in a well-known
| > | location?  That's what Bison 1.35 does.
| > 
| > This approach has several problems, all related to the fact that
| > bison.simple is independent from the parser file:
| > 
| > - it may not exist
| > - it may not be at the same location
| > - it may belong to a different version of Bison (worst case IMO).
| 
| These arguments apply equally well to the .y file, don't they?

Indeed, but the underlying assumption is that sources are available :)

| There's a simple solution when these problems arise: manually edit the
| .c file to remove its #line directives.  So this issue is mostly one
| of what's more convenient and useful in the normal case.

I definitely agree, and for having practiced both intensively, I
definitely prefer no longer having to remove the #line by hand.

| > I, for one, have always had problems with this `feature'.  Flex does
| > what 1.5x does, and in practice, it is much more convenient.
| 
| It solves the first and third of the problems that you mention, so I
| guess it is an improvement.  Given the limitations of C, it may be the
| best that can be done.

It does fix the second problem too.  I might be misunderstanding you
here.


| I can think of one further elaboration.  You could start the output
| file like this:
| 
|   #ifndef YY__FILE__
|   # define YY__FILE__ "y.tab.c"
|   #endif
| 
| and then use `#line 234 YY__FILE__' instead of `#line 234 "y.tab.c"'.
| (It is tempting to write `# define YY__FILE__ __FILE__' but that
| doesn't work the way we want.)  That will make it a bit easier for the
| user to fix up the output file after renaming it, or to compile a
| renamed file with -DYY__FILE__=... without modifying it.

Hm...  It looks unnecessarily complex...

| But this may be gilding the lily.

... which probably means the same thing :)



Well, thanks.  The information I was lacking is that only #line LINE
"FILE" is standard, which explains why I didn't find information on
GNU CPP's format.



reply via email to

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