> On 10 May 2019, at 07:24, Akim Demaille <a...@lrde.epita.fr> 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_.



_______________________________________________
help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to