PL_BEGIN(Parser Generics for Modula-3) The situation often arises that several different programs need to parse the same language. Traditionally, each program would have its own generated parser. This makes it hard for these programs to share the parser or extensions to the parser. It also tends to allow for minute variations in the language that may make the programs incompatible.
In _TT(parserlib), the traditional lexer/parser abstraction is used as a starting point. However, rather than directly importing each other, the lexer and parser know only about a _TI which makes them compatible. Also, there is no user code inserted into the generated lexers and parsers. The generated lexers and parsers only check the grammar of the input. Additional functionality is added by extending each lexer or parser using _EXT. Each extended parser or lexer can itself be further extended, allowing highly modular hierarchies of parsers and lexers.
The lexers generated by _TT(parserlib) use convenient Modula-3 _TT(Rd.T)s and _TT(TEXT)s for their input, allowing language generated on the fly to be parsed. The generated parsers can also be instructed _LN(kyacc.html#exhaust,not) to exhaust their input. This allows a program to parse a language embedded in another language without having an extra pass to match delimiters.
Finally, the generated lexers and parsers are _TT(OBJECT)s and do not rely on global variables, so that many streams can be parsed concurrently by a single process.
_H(using parserlib) _LN(m3build.html,m3build support)
_LN(SeekRd.html,reading from standard input)
_LN(calc.html,calculator example)
_H(package installation) The following items are required in order to build _TT(parserlib):
The _TT(Makefile) in the _TT(parserlib) directory builds the following constituent programs:
#define _TR3(name)
Finally, a library called _TT(parserlib) (in _TT(parserlib/parserlib)) contains the _LN(SeekRd.html,_TT(SeekRd)) interface which is imported by generated lexers, and the _LN(m3build.html,m3build template) which finds and runs the built constituent programs. _H(acknowledgements) Special thanks to Mika Nyström for the basic idea.
- Karl Papadantonakis PL_END $Id: index.html,v 1.2 2001-09-19 15:31:35 wagner Exp $ HTML_END