bug-bison
[Top][All Lists]
Advanced

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

Re: error-tokens and locations?


From: Ian Badcoe
Subject: Re: error-tokens and locations?
Date: Wed, 19 Nov 2003 11:40:00 +0000

At 13:38 18/11/2003 -0800, you wrote:


MERGING LOCATIONS: (0 - 0) [0](5 - 10)

This indicates a call to YYLLOC_DEFAULT with N equal to zero.

It's simplest to explain if I paste part of the info file:

   The `YYLLOC_DEFAULT' macro takes three parameters.  The first one is
the location of the grouping (the result of the computation).  When a
rule is matched, the second parameter is an array holding locations of
all right hand side elements of the rule being matched, and the third
parameter is the size of the rule's right hand side.  When processing a
syntax error, the second parameter is an array holding locations of the
symbols that were discarded during error processing, and the third
parameter is the number of discarded symbols.

   By default, `YYLLOC_DEFAULT' is defined this way for simple LALR(1)
parsers:

     #define YYLLOC_DEFAULT(Current, Rhs, N)          \
       Current.first_line   = Rhs[1].first_line;      \
       Current.first_column = Rhs[1].first_column;    \
       Current.last_line    = Rhs[N].last_line;       \
       Current.last_column  = Rhs[N].last_column;

   When defining `YYLLOC_DEFAULT', you should consider that:

   * All arguments are free of side-effects.  However, only the first
     one (the result) should be modified by `YYLLOC_DEFAULT'.

   * For consistency with semantic actions, valid indexes for the
     location array range from 1 to N.

So N == 0 is conceptually odd (how do you merge no tokens) and
programmatically it accesses the zero-element of the rhs array, which is
not supposed to be used (when built on another compiler, it looks
uninitialised).

        Ian B

Free transport into the future - while you wait.






reply via email to

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