Generators for high-speed front-ends
High-speed compilers can be constructed automatically. We present some existing tools for the generation of fast front-ends.
Rex (Regular EXpression tool) is a scanner generator whose specifications are based on regular expressions and arbitrary semantic actions written in one of the target languages C or Modula-2. As scanners sometimes have to consider the context to unambiguously recognize a token the right context can be specified by an additional regular expression and the left context can be handled by so-called start states. The generated scanners automatically compute the line and column position of the tokens and offer an efficient mechanism to normalize identifiers and keywords to upper or lower case letters. The scanners are table-driven and run at a speed of 180,000 to 195,000 lines per minute on a MC 68020 processor.
Lalr is a LALR(1) parser generator accepting grammars written in extended BNT notation which may be augmented by semantic actions expressed by statements of the target language. The generator provides a mechanism for S-attribution, that is synthesized attributes can be computed during parsing. In case of LR-conflicts, unlike other tools, Lalr provides not only information about an internal state consisting of a set of items but it prints a derivation tree which is much more useful to analyze the problem. Conflicts can be resolved by specifying precedence and associativity of operators and productions. The generated parsers include automatic error reporting, error recovery, and error repair. The parsers are table-driven and run at a speed of 400,000 lines per minute. Currently parsers can be generated in the target languages C and Modula-2.
Ell is a LL(1) parser generator accepting the same specification language as Lalr except that the grammars must obey the LL(1) property. The generated parsers include automatic error reporting, recovery, and repair like Lalr. The parsers are implemented following the recursive descent method and reach a speed of 450,000 lines per minute. The possible target languages are again C and Modula-2
A comparison of the above tools with the corresponding UNIX tools shows that significant improvements have been achieved thus allowing the generation of high-speed compilers.
KeywordsRegular Expression Target Language Error Recovery Derivation Tree Semantic Action
- [ASU86]A. V. Aho, R. Sethi and J. D. Ullman, Compilers: Principles, Techniques, and Tools, Addison Wesley, Reading, MA, 1986.Google Scholar
- [DeP82]F. DeRemer and T. Pennello, Efficient Computation of LALR(1) Look-Ahead Sets, ACM Trans. Prog. Lang. and Systems 4, 4 (Oct. 1982), 615–649.Google Scholar
- [GNU88]GNU Project, Bison — Manual Page, Public Domain Software, 1988.Google Scholar
- [GrK86]J. Grosch and E. Klein, User Manual for the PGS-System, GMD Forschungsstelle an der Universität Karlsruhe, Aug. 1986.Google Scholar
- [Gro87]J. Grosch, Rex — A Scanner Generator, Compiler Generation Report No. 5, GMD Forschungsstelle an der Universität Karlsruhe, Dec. 1987.Google Scholar
- [Gro88a]J. Grosch, Selected Examples of Scanner Specifications, Compiler Generation Report No. 7, GMD Forschungsstelle an der Universität Karlsruhe, Mar. 1988.Google Scholar
- [Gro88b]J. Grosch, LALR — Generates Efficient Table-Driven Parsers, Compiler Generation Report No. 10, GMD Forschungsstelle an der Universität Karlsruhe, Sep. 1988.Google Scholar
- [Ive86]F. Ives, Unifying View of Recent LALR(1) Lookahead Set Algorithms, SIGPLAN Notices 21, 7 (1986), 131–135.Google Scholar
- [Joh75]S. C. Johnson, Yacc — Yet Another Compiler-Compiler, Computer Science Technical Report 32, Bell Telephone Laboratories, Murray Hill, NJ, July 1975.Google Scholar
- [KlM88]E. Klein and M. Martin, The Parser Generating System PGS, to appear in Software—Practice & Experience, 1988.Google Scholar
- [Les75]M. E. Lesk, LEX — A Lexical Analyzer Generator, Computing Science Technical Report 39, Bell Telephone Laboratories, Murray Hill, NJ, 1975.Google Scholar
- [Pax88]V. Paxson, Flex-Manual Pages, Public Domain Software, 1988.Google Scholar
- [Röh76]J. Röhrich, Syntax-Error Recovery in LR-Parsers, in Informatik-Fachberichte, vol. 1, H.-J. Schneider and M. Nagl (ed.), Springer, Berlin, 1976, 175–184.Google Scholar
- [Röh80]J. Röhrich, Methods for the Automatic Construction of Error Correcting Parsers, Acta Inf. 13, 2 (1980), 115–139.Google Scholar
- [Röh82]J. Röhrich, Behandlung syntaktischer Fehler, Informatik Spektrum 5, 3 (1982), 171–184.Google Scholar
- [Vie88]B. Vielsack, The Parser Generators Lalr and Ell, Compiler Generation Report No. 8, GMD Forschungsstelle an der Universität Karlsruhe, Apr. 1988.Google Scholar
- [WaG84]W. M. Waite and G. Goos, Compiler Construction, Springer Verlag, New York, NY, 1984.Google Scholar