Abstract
An attribute grammar is an ordinary context-free grammar augmented with attributes and semantic rules for describing the semantics of terminal strings generated by the underlying context-free grammar. The meaning of a terminal string is revealed in two steps: first a parse tree is constructed for the string, and then a so-called evaluator defines the values of attribute instances attached to the parse tree. Many of these values are very temporary in nature, making it important to use the space allocated for them repeatedly.
In this paper the evaluator construction method of Kennedy and Warren is improved in two ways. First, we present how temporary values can be detected and stored in a stack so that their space requirement is linear in the height of the parse tree. Second, we demonstrate how to reduce the size of the evaluator. In the best case a reduction by an exponential factor can be achieved.
Preview
Unable to display preview. Download preview PDF.
References
Aho, A.V. and Ullman, J.D.: The theory of parsing, translation and compiling, Volume 1: parsing. Prentice-Hall, Inc., Englewood Cliffs, N.J., 1972.
Blaizot, L.: DELTA: Système de description de langages et traducteurs par attributs. Rapport de Recherche 20, IRIA Laboria, Rocquencourt, Juin 1973.
Bochmann, G.V.: Semantic evaluation from left to right. Publication #175, Département d'Informatique, Université de Montréal, Montréal, May 1974. Also in CACM 19, 2 (February 1976), 55–62.
Böhm, C.(ed.): λ-calculus and computer science theory. Lecture Notes in Computer Science, Volume 37, Springer-Verlag, New York, 1975.
Borowiec, J.: Pragmatics in a compiler production system. Methods of algorithmic language implementation, A. Ershov and C.H.A. Koster (eds.), Springer-Verlag, Berlin-Heidelberg-New York, 1977, 314–340.
Bruno, J. and Burkhard, W.A.: A circularity test for interpreted grammars. Technical Report 88, Computer Science Laboratory, Department of Electrical Engineering, Princeton University, Princeton, N.J., 1970.
Fang, I: FOLDS, a declarative formal language definition system. STAN-CS-72-329, Computer Science Department, Stanford University, Stanford, California, December 1972.
Feldman, J.A. and Gries, D.: Translator writing systems. CACM 11, 2 (February 1968), 77–113.
Ganzinger,H.: MUG1 — Manual. Report 7608, Institut für Informatik, Technische Universität München, Juli 1976.
Ganzinger, H., Ripken, K. and Wilhelm, R.: Automatic generation of optimizing multipass compilers. Information Processing 77, Proceedings of IFIP Congress 77, B. Gilchrist (ed.), North-Holland Publ. Co., Amsterdam-New York-Oxford, 1977, 535–540.
Giegerich, R. and Wilhelm, R.: Implementierbarkeit attributierter Grammatiken. GI — 7.Jahrestagung, H.J. Schneider (ed.), Springer-Verlag, Berlin-Heidelberg-New York, 1977.
Jazayeri, M.: On attribute grammars and the semantic specification of programming languages. Report 1159, Jennings Computing Center, Case Western University, Cleveland, Ohio, October 1974.
Jazayeri, M., Ogden, W.F. and Rounds, W.C.: The intrinsically exponential complexity of the circularity problem for attribute grammars. CACM 18, 12 (December 1975), 697–706.
Jazayeri, M. and Pozefsky, D.: Algorithms for efficient evaluation of multi-pass attribute grammars without a parse tree. Report TR 77-001, Department of Computer Science, University of North Carolina, Chapel Hill, N.C., February 1977.
Jazayeri,M. and Walter,K.G.: Alternating semantic evaluator. Proceedings of the Annual Conference ACM 1975, October 1975, 230–234.
Kastens, U.: Ein Übersetzer-erzeugendes System auf der Basis attributierter Grammatiken. Interner Bericht 10, Fakultät für Informatik, Universität Karlsruhe, Karlsruhe, September 1976.
Kennedy, K. and Ramanathan, J.: A deterministic attribute grammar evaluator based on dynamic sequencing. Technical Report 476-093-12, Department of Mathematical Sciences, Rice University, Houston, Texas, October 1975.
Kennedy,K. and Warren,S.K.: Automatic generation of efficient evaluators for attribute grammars. Conference Record of the Third ACM Symposium on Principles of Programming Languages, January 1976, 32–49.
Knuth, D.E.: Semantics of context-free languages. Mathematical Systems Theory 2, 2 (1968), 127–145.
Knuth, D.E.: Semantics of context-free languages: correction. Mathematical Systems Theory 5, 1 (1971), 95–96.
Koster, C.H.A.: Affix grammars. Algol 68 implementation, J.E.L. Peck (ed.), North-Holland Publ. Co., Amsterdam-London, 1971, 95–109.
Lecarme, O.L. and Bochmann, G.V.: A (truly) usable and portable compiler writing system. Information Processing 74, Proceedings of IFIP Congress 74, J.L. Rosenfeld (ed.), North-Holland Publ. Co., Amsterdam-London, 1974, 218–221.
Lewi, J., DeVlaminck, K., Huens, J. and Mertens, P.: SLS/I: a translator writing system. GI — 5. Jahrestagung, J. Mühlbacher (ed.), Springer-Verlag, Berlin-Heidelberg-New York, 1975, 627–641.
Lorho, B.: De la définition à la traduction des langages de programmation: méthode des attributs sémantiques. Thèse d'Etat, Université Paul Sabatier, Toulouse, 1974.
Lorho, B. and Pair, C.: Algorithms for checking consistency of attribute grammars. Proving and improving programs, G. Huet and G. Kahn (eds.), IRIA, Rocquencourt, July 1975, 29–54.
Milne, R. and Strachey, C.: A theory of programming language ɛemantics. Chapman and Hall, London, and Wiley, New York, 2 Volumes, 1976.
Néel, D. and Amirchahy, M.: Semantic attributes and improvement of generated code. Proceedings of the Annual Conference ACM 1974, November 1974, 1–10.
Räihä, K.-J.: On attribute grammars and their use in a compiler writing system. Report A-1977-4, Department of Computer Science, University of Helsinki, Helsinki, August 1977.
Räihä, K.-J. and Saarinen, M.: Developments in compiler writing systems. GI-6. Jahrestagung, E.J. Neuhold (ed.), Springer-Verlag, Berlin-Heidelberg-New York, 1976, 164–178.
Räihä, K.-J. and Saarinen, M.: An optimization of the alternating semantic evaluator. Information Processing Letters 6, 3 (1977), 97–100.
Räihä, K.-J., Saarinen, M., Soisalon-Soininen, E. and Tienari, M.: The compiler writing system HLP (Helsinki Language Processor). Report A-1978-2, Department of Computer Science, University of Helsinki, Helsinki, March 1978.
Saarinen, M.: Stack realizable attribute grammars. In preparation.
Schulz, W.A.: Semantic analysis and target language synthesis in a translator. Ph.D. Thesis, University of Colorado, Boulder, Colorado, 1976.
Warren, S.K.: The efficient evaluation of attribute grammars. M.A. Thesis, Department of Mathematical Sciences, Rice University, Houston, Texas, April 1975.
Watt, D.A.: The parsing problem for affix grammars. Acta Informatica 8, 1 (1977), 1–20.
Wegner, P.: The Vienna definition language. Computing Surveys 4, 1 (March 1972), 5–63.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1978 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Saarinen, M. (1978). On constructing efficient evaluators for attribute grammars. In: Ausiello, G., Böhm, C. (eds) Automata, Languages and Programming. ICALP 1978. Lecture Notes in Computer Science, vol 62. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-08860-1_29
Download citation
DOI: https://doi.org/10.1007/3-540-08860-1_29
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-08860-8
Online ISBN: 978-3-540-35807-7
eBook Packages: Springer Book Archive