help-bison
[Top][All Lists]
Advanced

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

yyparse() & yyval


From: Hans Aberg
Subject: yyparse() & yyval
Date: Fri, 3 Nov 2000 11:38:47 +0100

When I call yyparse(), I would want to be able to access the $$ value it
builds. It seems it is put into the local variable yyval, but that there is
no external way to access it.

Therefore, I would want to have a version
  yyparse(YYSTYPE* yyval);

The use would be
  YYSTYPE yyval;
  yyparse(&yyval);
                    -- Now the parsed value is in yyval.

This is similar, I gather, to the YYPARSE_PARAM, but not exactly the same:

The yyval is the internally parsed value, whereas (I gather) the
YYPARSE_PARAM is the externally (interface) parsed value. -- Please correct
me, if I misunderstood something.

Should not the latter be improved, say so that one has a macro YYPARSETYPE,
together with a new $ variable, say $!, which could be used in the semantic
actions. The use would be
  YYPARSETYPE parseval;
  yyparse(&parseval);
  -- Now the user interface parsed value is in yyval, whereas internally
  parsed value yyval is inaccessible to the user of yyparse().

The idea I have in my mind is that one makes say a C++ parser that can read
arithmetical expressions by the syntax
  Parser parser;
  double d;
  cin >> parser >> d;  // Use parser to read arithmetical expression.
Then, when making such a parser (regardless of what syntax one finally
decides to use), it may happen that the parser may need to construct its
own internal $$ value, but should also build another value to make
available to the user (the $! value above). -- The suggest is merely that
Bison should be more friendly in order to support such uses.

  Hans Aberg





reply via email to

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