bug-bison
[Top][All Lists]
Advanced

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

Pure parser value, C++


From: Hans Aberg
Subject: Pure parser value, C++
Date: Sun, 27 Oct 2002 20:41:37 +0100

I am experimenting with a pure parser under C++ -- essentially a rewrite of
lalr1.cc.

Then it turns out that in addition to the semantic $$ and $n semantic
values, my parser actually generates a different value.

In my example, the parser creates a database of axioms and other
metalogical entities; whenever a full entity has been parsed, it is put
into the database. The actual $$ and $n semantic values are irrelevant from
the outside point of view -- only the database is important.

Therefore, the typing of my parse function becomes, if the parser generates
such a value:
  class parser {
  public:
  #if !YYLSP_NEEDED
    int parse(parse_type& p, semantic_type& s = semantic_type());
  #else
    int parse(parse_type& p, semantic_type& s = semantic_type(),
              location_type& l = location_type());
    ...
  };
#endif

Because the semantic_type value may be irrelevant, I decided to not put the
parse value into that one. -- In fact, the parse value type will be used in
the typing of some other functions, and one would then not carry along
stuff that does not properly belong there.

Now to the question:

When writing actions, this parse value must be given a variable name. One
can of course give it a name like yypval, parse_value or something. But
when writing code in rule actions, it would be neater if one had a special
variable name, like $$$, or something.

Any thoughts (apart from the obvious die-hard comments)?

  Hans Aberg






reply via email to

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