Yacc++, was Re: Seeking parser generator topics

26 Aug 90 17:08:18 GMT

          From comp.compilers

Related articles
Yacc++, was Re: Seeking parser generator topics mike@vlsivie.at (1990-08-26)
| List of all articles for this month |

Newsgroups: comp.compilers
From: mike@vlsivie.at
Keywords: yacc, C++
Organization: Technical University of Vienna, AUSTRIA
References: <9008241906.AA11285@cssun.tamu.edu>
Date: 26 Aug 90 17:08:18 GMT

In article <9008241906.AA11285@cssun.tamu.edu>, terry@cs.tamu.edu (Terry Escamilla) writes:
> - making every component of the grammar an object with multiple attributes
> for grammar symbols (contrary to YACC), thus giving a very fine grain of
> reusability (though I don't know what one would do with this).

Stephen C. Johnson proposed something of the kind. There was a paper in
the Proceedings of the EUUG Spring '88 Conference called "Yacc meets C++"
introducing Y++. In y++, every grammar symbol is associated with a class
which may have any number of members.

It is implemented as two passes from what I gather from the papaer, one
doing the parsing, the second the evaluation, by executing all members defined
on the start symbol. (this has to be done by the user)

What it boils down to seems to be this:

%start expr


expr : expr '+' expr
              { postfix() { $1.postfix(); $3.postfix(); putchar('+'); }
                  prefix () { putchar('+'); $1.prefix(); $3.prefix(); }
          | NUM
              { postfix () { $1.print(); }
                  prefix () { $1.print(); }

/* I doubt that this is the syntax, but either there was none specified or
      I don't recall */

Now if you wanted to print the expression in prefix and postfix you would do
something like

/* somehow define return value */

return_value = yyparse();



Neat concept, isn't it? Does anybody know whatever happened to y++?

It was supposed to be a research tool, no finished program....

this brings us full circle back to two pass compilers; what do you think
about this:

                /* somehow define return value */

                return_value = yyparse();



I think it is as clean as you can ever do it with YACC ....

Michael K. Gschwind mike@vlsivie.at
Technical University, Vienna mike@vlsivie.uucp
Voice: (++43).1.58801 8144 e182202@awituw01.bitnet
Fax: (++43).1.569697

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.