help-bison
[Top][All Lists]
Advanced

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

Re: how to get left hand side symbol in action


From: Hans Åberg
Subject: Re: how to get left hand side symbol in action
Date: Fri, 10 May 2019 15:47:04 +0200

> On 10 May 2019, at 07:24, Akim Demaille <address@hidden> wrote:
> 
> 1. there is a real and valid need for the feature, which I still need
>   to be convinced of, especially because symbol names are technical
>   details!

One can also write better error messages by using these internal yytname_ table 
names:

If one checks on a lookup table whether the name has been already defined and 
it is, then one can give information about that already present name. For 
example:
  “name” {
      std::optional<std::pair<token_type, semantic_type> x0 = 
my::symbol_table.find($x.text);

      if (x0) {
        throw syntax_error(@x, "Name " + $x.text + " already defined in this 
scope as "
          + yytnamerr_(yytname_[x0->first - 255]));
      }
    …
  }

Right now, all parts are internal and may change: the token translation 
x0->first - 255, yytname_ lookup, and error message cleanup yytnamerr_.





reply via email to

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