Abstract
Most language translation problems can be solved with existing LALR(1) or LL(k) language tools; e.g., YACC [Joh78] or ANTLR [PDC92]. However, there are language constructs that defy almost all parsing strategy commonly in use. Some of these constructs cannot be parsed without semantics, such as symbol table information, and some cannot be properly recognized without first examining the entire construct, that is we need “infinite lookahead.”
In this paper, we introduce a new LL(k) parser strategy, pred- LL(k), that uses semantic or syntactic predicates to recognize language constructs when normal deterministic LL(k) parsing breaks down. Semantic predicates indicate the semantic validity of applying a production; syntactic predicates are grammar fragments that describe a syntactic context that must be satisfied before application of an associated production is authorized. Throughout, we discuss the implementation of predicates in ANTLR—the parser generator of The Purdue Compiler-Construction Tool Set.
Chapter PDF
References
Margaret A. Ellis and Bjarne Stroustrup. The Annotated C + + Reference Manual. Addison Wesley Publishing Company, Reading, Massachusetts, 1990.
Mahadevan Ganapathi. Semantic Predicates in Parser Generators. Computer Language, 14(1):25–33, 1989.
R. C. Holt, J. R. Cordy, and D. B. Wortman. An Introduction to S/SL: Syntax/Semantic Language. ACM TOPLAS, 4(2):149–178, April 1982.
S. C. Johnson. Yacc: Yet Another Compiler-Compiler. Bell Laboratories; Murray Hill, N J, 1978.
Donald E. Knuth. Semantics of Context-Free Languages. Mathematical Systems Theory, 2(2):127–145, 1968.
P. M. Lewis, D. J. Rosenkrantz, and R. E. Stearns. Attributed Translations. Journal of Computer and System Sciences, 9:279–307, 1974.
B. J. McKenzie. LR parsing of CFGs with restrictions. Software-Practice & Experience, 20(8):823–832, 1990.
D.R. Milton and C.N. Fischer. LL(k) Parsing for Attributed Grammars. In Proceedings of Automata, Languages and Programming, Sixth Colloquium, pages 422–430, 1979.
D.R. Milton, L.W. Kirchhoff, and B.R. Rowland. An ALL(1) Compiler Generator. In Conference Record of SIGPLAN Symposium on Compiler Construction, 1979.
Terence John Parr. Obtaining Practical Variants of LL(k) and LR(k) for k > 1 by Splitting the Atomic k-Tuple. PhD thesis, Purdue University, West Lafayette, Indiana, August 1993.
Terence Parr, Will Cohen, and Hank Dietz. The Purdue Compiler Construction Tool Set: Version 1.10 Release Notes. Technical Report Preprint No. 93-088, Army High Performance Computing Research Center, August 1993.
T.J. Parr, H.G. Dietz, and W.E. Cohen. PCCTS 1.00: The Purdue Compiler Construction Tool Set. SIGPLAN Notices, 1992.
W. M. Waite. Use of Attribute Grammars in Compiler Construction. In Attribute Grammars and their Applications; Lecture Notes in Computer Science, volume 461, pages 254–265. Springer-Verlag, 1990.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1994 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Parr, T.J., Quong, R.W. (1994). Adding semantic and syntactic predicates to LL(k): pred-LL(k) . In: Fritzson, P.A. (eds) Compiler Construction. CC 1994. Lecture Notes in Computer Science, vol 786. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-57877-3_18
Download citation
DOI: https://doi.org/10.1007/3-540-57877-3_18
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-57877-2
Online ISBN: 978-3-540-48371-7
eBook Packages: Springer Book Archive