[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Locations in bison itself are wrong
From: |
Paul Eggert |
Subject: |
Re: Locations in bison itself are wrong |
Date: |
Sun, 2 Mar 2003 00:46:45 -0800 (PST) |
Akim Demaille <address@hidden> writes:
> @@ -1069,6 +1073,7 @@
> yyssp = yyss;
> yyvsp = yyvs;
> yylsp = yyls;
> + *yylsp = b4_location_initial;
> goto yysetstate;
>
> /*------------------------------------------------------------.
>
> with a bit more m4_ifdef so that only people specifying it will
> trigger the code (any K&R portability issue with struct assignments?).
glr.c has this:
static YYLTYPE yyloc_default;
and uses it unconditionally, without letting the user override it as
far as I can see. Is that the sort of thing you wanted to see?
Hmm, how about something like this instead? It would allow overriding.
#ifndef YYLOC_START_OF_INPUT
# define YYLOC_START_OF_INPUT(loc) ((loc).last_line = 1, (loc).last_column = 0)
#endif
...
yylsp = yyls;
YYLOC_START_OF_INPUT (*yylsp);
goto yysetstate;
That way, a user who overrides YYLLOC_DEFAULT can also override
YYLOC_START_OF_INPUT consistently with YYLLOC_DEFAULT.
> An alternative would consist in using the location of the lookahead,
I agree that this won't work, for the reasons that you gave.