Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!ima!johnl From: johnl@ima.UUCP Newsgroups: mod.compilers Subject: YACC for dynamic grammars Message-ID: <458@ima.UUCP> Date: Mon, 26-Jan-87 10:27:28 EST Article-I.D.: ima.458 Posted: Mon Jan 26 10:27:28 1987 Date-Received: Tue, 27-Jan-87 03:49:29 EST Sender: johnl@ima.UUCP Lines: 30 Approved: compilers@ima.UUCP 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] -- Send compilers articles to ima!compilers or, in a pinch, to Levine@YALE.EDU Plausible paths are { ihnp4 | decvax | cbosgd | harvard | yale | cca}!ima Please send responses to the originator of the message -- I cannot forward mail accidentally sent back to compilers. Meta-mail to ima!compilers-request