[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: #line format
From: |
Paul Eggert |
Subject: |
Re: #line format |
Date: |
Thu, 11 Apr 2002 11:05:35 -0700 (PDT) |
> 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?
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, 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.
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.
But this may be gilding the lily.