List Info

Thread: location tracking for the empty rules without prior symbol




location tracking for the empty rules without prior symbol
user name
2007-12-19 05:28:48
Hello GNU Bison people,

I am using location tracking. While it works great in
general, there
is a corner case where I am unsure about the intended
behaviour of
bison and how the program should handle it.

The issue is what is the value of $ for the first reduction
when the rule
involved has no components.

For example if the grammar is
%%
seq: /* empty */ {printf("empty: (%d, %d)n",$.first_line,$.first_column);}
   | seq item
;
item: '(' seq ')'
;
%%
and the text to parse is "()", then the first
reduction will involve the
rule {seq : /* empty */} for which N=0, but there is no
symbol prior to
the reduction. 

What is the output of this program according to the
specification ?

Is it different for a custom YYLTYPE and/or a custom
YYLLOC_DEFAULT ?

Looking at the parser code I see:
#if YYLTYPE_IS_TRIVIAL
  /* Initialize the default location before parsing starts. 
*/
  yylloc.first_line   = yylloc.last_line   = 1;
  yylloc.first_column = yylloc.last_column = 0;
#endif
which imply that the default YYLTYPE is handled specially.

Cheers,
Bill.  (Please CC me)


_______________________________________________
help-bisongnu.org http
://lists.gnu.org/mailman/listinfo/help-bison

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )