help-bison
[Top][All Lists]
Advanced

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

location tracking for the empty rules without prior symbol


From: Bill Allombert
Subject: location tracking for the empty rules without prior symbol
Date: Wed, 19 Dec 2007 12:28:48 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

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)




reply via email to

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