A Fast General Parser for Automatic Code Generation
- 552 Downloads
The code generator in a compiler attempts to match a subject tree against a collection of tree-shaped patterns for generating instructions. Tree-pattern matching may be considered as a generalization of string parsing. We propose a new generalized LR (GLR) parser, which extends the LR parser stack with a parser cactus. GLR explores all plausible parsing steps to find the least-cost matching. GLR is fast due to two properties: (1) duplicate parsing steps are eliminated and (2) partial parse trees that will not lead to a least-cost matching are discarded as early as possible.
Keywordsambiguous grammar code generator compiler context-free grammar parsing general parsing pattern matching tree pattern tree-pattern matching
Unable to display preview. Download preview PDF.
- 2.Aho, A.V., Lam, M.S., Sethi, R., Ullman, J.D.: Compilers, Principles, Techniques, and Tools, 2nd edn. Addison-Wesley, New York (2007)Google Scholar
- 5.Fischer, C.N., LeBlanc Jr., R.J.: Crafting a Compiler with C. Benjamin/Cummings, Reading (1991)Google Scholar
- 7.Glanville, R.S.: A machine independent algorithm for code generation and its use in retargetable compilers. Ph.D. dissertation, University of California, Berkeley (December 1977)Google Scholar
- 8.Steven Glanville, R., Graham, S.L.: A new method for compiler code generation. In: Proceedings of 5th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, Tucson, Arizona, pp. 231–254 (1978)Google Scholar
- 9.Nigel Horspool, R.: An Alternative to the Graham-Glanville Code-Generation Method. IEEE Computers 20, 33–39 (1987)Google Scholar
- 10.Madhavan, M., Shankar, P.: Optimal regular tree pattern matching using pushdown automata. In: Arvind, V., Sarukkai, S. (eds.) FST TCS 1998. LNCS, vol. 1530, pp. 122–133. Springer, Heidelberg (1998)Google Scholar
- 12.Sun Microsystems, Connected, Limited Device Configuration, Specification Version 1.0a, Java 2 Platform Micro Edition 1.0a, CA, USA (May 19, 2000)Google Scholar