|Modular grammars and parsing? email@example.com (1992-01-04)|
|Re: Modular grammars and parsing? Jan.Rekers@cwi.nl (1992-01-07)|
|From:||Jan.Rekers@cwi.nl (Jan Rekers)|
|Date:||7 Jan 92 11:03:30 GMT|
In article 92-01-013, firstname.lastname@example.org
(Charles Lakos) writes:
|> I wish to write a parser to handle an imperative language in a modularised
|> way. It should reflect three distinct sub-grammars - the statements, the
|> declarations and the expressions. The "statements" part should "call" the
|> "declarations" and the "expressions" parts.
|> I can obviously do the above with a top-down recursive parser, but I was
|> hoping to be able to do it by modifying an existing yacc + lex (flex)
|> grammar. Can anyone suggest how it might be done?
I cannot help you with a clean-cut yacc + lex solution, but you might be
interested in a paper I wrote on parser generation for modular grammars.
I have implemented the syntax definition formalism SDF in which the
grammar can be subdivided in different modules which may import each
other. There is no limmitation on the import graph, except that it may not
be cyclic. It is allowed to define rules for one non-terminal in different
modules. It is possible to select any module and to parse according to the
rules valid in that module and the modules it imports. The implementation
is in LISP and part of the centaur system.
The paper is just sent in for publication, so I do not have an easy
reference. If you are interested in this technique, please drop me a note
with your surface address.
Jan Rekers (Jan.Rekers@cwi.nl) Centrum voor Wiskunde en Informatica (CWI)
P.O. Box 4079, 1009 AB Amsterdam, The Netherlands
Return to the
Search the comp.compilers archives again.