YACC for dynamic grammars

"Micha Meier" <harvard!seismo!unido!ecrcvax!micha>
Mon, 26 Jan 87 14:27:28 -0100

          From comp.compilers

Related articles
YACC for dynamic grammars harvard!seismo!unido!ecrcvax!micha (Micha Meier) (1987-01-26)
YACC for dynamic grammars drw@eddie.mit.edu (1987-01-27)
| List of all articles for this month |

Date: Mon, 26 Jan 87 14:27:28 -0100
From: "Micha Meier" <harvard!seismo!unido!ecrcvax!micha>

Is it possible to use YACC to write a parser for a simple language
whose gramatic may dynamically change, namely defining new operators?
In this interpreter, new operators (unary or binary) can be added
by the user dynamically, e.g. define the binary operator ++
with a certain precedence and then the system can recognize a ++ b.
I have no experiences with YACC, I see it in the following way:
YACC generates some tables which correspond to the grammar.
If a new operator is added to the grammar, it should be possible
to dynamically update the tables in order to recognize the new item.
If this is not possible, is there any other way?


--Micha


ARPA: micha%ecrcvax.UUCP@seismo.CSS.gov
micha%ecrcvax.UUCP%Germany.CSNET@CSNET-RELAY
CSNET: micha%ecrcvax.UUCP@Germany.CSNET
UUCP: unido!ecrcvax!micha
[I doubt it -- the calculation that produces the parsing tables from the input
grammar is pretty complicated. If you only allow people to define new
operators that have the same precedence as existing ones, your job is pretty
easy since you haven't really changed the syntax, just added new flavors of
existing tokens from the point of view of the parser. If you get more general
than that, you can add ambiguties and you probably need the full extremely slow
glory of Earley's algorithm, which is a long way from the efficient LALR
approach of yacc. -John]
--


Post a followup to this message

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