Re: how to get left hand side symbol in action

Hans Åberg <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
> On 10 May 2019, at 07:24, Akim Demaille <[email protected]> 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_.



_______________________________________________
[email protected] https://lists.gnu.org/mailman/listinfo/help-bison
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.