The reason for this desire is to be able to cater for different variants
of the language with, say, different forms of expressions. Also, I wish
to use the expressions grammar with a simplified intermediate form of the
language.
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?
--
Charles Lakos. C.A....@cs.utas.edu.au
Computer Science Department, cha...@probitas.cs.utas.edu.au
University of Tasmania, Phone: +61 02 20 2959
Australia. Fax: +61 02 20 2913
--
Send compilers articles to comp...@iecc.cambridge.ma.us or
{ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
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.R...@cwi.nl) Centrum voor Wiskunde en Informatica (CWI)
P.O. Box 4079, 1009 AB Amsterdam, The Netherlands