|
ABSTRACT
Current parser generators are based on context-free grammars. Because such grammars lack abstraction facilities, the resulting specifications are often not easy to read. Fischer's macro grammars extend context-free grammars with macro-like productions thus providing the equivalent of procedural abstraction. However, their use is hampered by the lack of an efficient, off-the-shelf parsing technology for macro grammars. We define specialization for macro grammars to enable reuse of parsing technology for context-free grammars while facilitating the specification of a language with a macro grammar. This specialization yields context-free rules, but it does not always terminate. We present a sound and complete static analysis that applies to any macro grammar and decides whether specialization terminates for it and thus yields a (finite) context-free grammar. The analysis is based on an intuitive notion of self-embedding nonterminals, which is easy to check by hand. We have implemented the analysis as part of a preprocessing tool that transforms a Yacc grammar extended with macro productions to a standard Yacc grammar.
REFERENCES
Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.
| |
1
|
Alfred V. Aho , Ravi Sethi , Jeffrey D. Ullman, Compilers: principles, techniques, and tools, Addison-Wesley Longman Publishing Co., Inc., Boston, MA, 1986
|
| |
2
|
|
 |
3
|
|
| |
4
|
|
| |
5
|
|
| |
6
|
Compiler Resources, Inc. Yacc++ and the language objects library. http://world.std.com/~compres/, July 2004.
|
| |
7
|
K. Culik and R. Cohen. LR-regular grammars¿an extension of LR(k) grammars. J. Comput. Syst. Sci., 7:66--96, 1973.
|
| |
8
|
W. Damm. The IO- and OI-hierarchies. Theoretical Computer Science, 20(2):95--207, May 1982.
|
| |
9
|
C. Donnelly and R. Stallman. Bison¿The YACC-compatible Parser Generator. Free Software Foundation, Boston, MA, Nov. 1995. Part of the Bison distribution.
|
| |
10
|
ECMAScript Language Specification. http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf, Dec. 1999. ECMA International, ECMA-262, 3rd edition.
|
| |
11
|
M. J. Fischer. Grammars with macro-like productions. In IEEE Conference Record of 9th Annual Symposium on Switching and Automata Theory, pages 131--142, 1968.
|
| |
12
|
A. Gill and S. Marlow. Happy Manual. University of Glasgow, Department of Computing Science, 1995. Available via http://www.dcs.gla.ac.uk/fp/software/happy.html.
|
 |
13
|
|
| |
14
|
|
| |
15
|
The GrammarForge. build parsing applications with confidence. http://www.thothic.com/downloads/MetaSFactSheet.pdf, 2005.
|
 |
16
|
Robert W. Gray , Steven P. Levi , Vincent P. Heuring , Anthony M. Sloane , William M. Waite, Eli: a complete, flexible compiler construction system, Communications of the ACM, v.35 n.2, p.121-130, Feb. 1992
[doi> 10.1145/129630.129637]
|
| |
17
|
|
| |
18
|
S. Heilbrunner. On the definition of ELR(k) and ELL(k) grammars. Acta Informatica, 11:169--176, 1979.
|
| |
19
|
|
| |
20
|
JavaCC the java parser generator. https://javacc.dev.java.net/.
|
| |
21
|
S. C. Johnson. Yacc¿yet another compiler compiler. Technical Report 32, AT&T Bell Laboratories, Murray Hill, NJ, 1975.
|
| |
22
|
|
 |
23
|
|
| |
24
|
|
 |
25
|
|
| |
26
|
|
| |
27
|
|
| |
28
|
S. Peyton Jones, editor. Haskell 98 Language and Libraries, The Revised Report. Cambridge University Press, 2003.
|
| |
29
|
F. Pottier and Y. Régis-Gianas. Menhir reference manual. http://pauillac.inria.fr/~fpottier/menhir/manual.pdf, July 2007.
|
| |
30
|
J. Rekers. Parser Generation for Interactive Environments. PhD thesis, University of Amsterdam, 1992.
|
| |
31
|
S. D. Swierstra. Fast, error repairing parsing combinators. http://www.cs.uu.nl/groups/ST/Software/UU Parsing/, Aug. 2003.
|
| |
32
|
|
| |
33
|
P. Thiemann and M. Neubauer. Parameterized LR parsing. In G. Hedin and E. van Wyk, editors, Fourth Workshop on Language Descriptions, Tools and Applications, LDTA 2004, volume 110 of ENTCS, pages 115--132, Barcelona, Spain, Apr. 2004. Elsevier Science.
|
| |
34
|
|
| |
35
|
M. van den Brand and P. Klint. ASF+SDF meta-environment user manual. http://www.cwi.nl/projects/MetaEnv/meta/doc/manual/user-manual.html, July 2002.
|
| |
36
|
|
| |
37
|
|
| |
38
|
Parsing with Sandstone's Visual Parse++. http://www.sand-stone.com/pwvp.ZIP, 2001.
|
| |
39
|
|
|