Abstract
“Meaning” may be assigned to a string in a context-free language by defining “attributes” of the symbols in a derivation tree for that string. The attributes can be defined by functions associated with each production in the grammar. This paper examines the implications of this process when some of the attributes are “synthesized”, i.e., defined solely in terms of attributes of thedescendants of the corresponding nonterminal symbol, while other attributes are “inherited”, i.e., defined in terms of attributes of theancestors of the nonterminal symbol. An algorithm is given which detects when such semantic rules could possibly lead to circular definition of some attributes. An example is given of a simple programming language defined with both inherited and synthesized attributes, and the method of definition is compared to other techniques for formal specification of semantics which have appeared in the literature.
Similar content being viewed by others
References
J. W. de Bakker,Formal definition of programming languages, with an application to the definition of ALGOL 60, Math Cent. Tracts16, Mathematisch Centrum, Amsterdam, 1967.
C. Böhm, The CUCH as a formal and description language,Formal Language Description Languages for Computer Programming, pp. 266–294, Proc. IFIP Working Conf., Vienna (1964), North Holland, 1966.
Corrado Böhm andWolf Gross, “Introduction to thecuch,”Automata Theory (ed. by E. R. Caianiello), pp. 35–65, Academic Press, 1966.
C. C. Elgot, “Machine species and their computation languages,”Formal Language Description Languages for Computer Programming, pp. 160–179, Proc. IFIP Working Conf., Vienna (1964), North Holland, 1966.
C. C. Elgot andA. Robinson, “Random-access, stored program machines, an approach to programming languages,”J. ACM 11 (1964), 365–399.
Edgar T. Irons, A syntax directed compiler forAlgol 60,Comm. ACM 4 (1961), 51–55.
Edgar T. Irons, Towards more versatile mechanical translators, Proc. Sympos. Appl. Math., Vol. 15, pp. 41–50, Amer. Math. Soc., Providence, R. I., 1963.
Donald E. Knuth,The Art of Computer Programming, I, Addison-Wesley, 1968.
P. J. Landin, “The mechanical evaluation of expressions,”Comp. J. 6 (1964), 308–320.
P. J. Landin, A formal description ofAlgol 60,Formal Language Description Languages for Computer Programming, pp. 266–294, Proc. IFIP Working Conf., Vienna, (1964), North Holland, 1966.
P. J. Landin, A correspondence betweenAlgol 60 and Church's lambda notation,Comm. ACM 8 (1965), 89–101, 158–165.
John McCarthy, A formal definition of a subset ofAlgol,Formal Language Description Languages for Computer Programming, pp. 1–12, Proc. IFIP Working Conf., Vienna (1964), North Holland, 1966.
John McCarthy andJames Painter, Correctness of a compiler for arithmetic expressions, Proc. Sympos. Appl. Math., Vol. 17, to appear, Amer. Math. Soc., Providence, R. I., 1967.
Robert M. McClure, TMG—A syntax directed compiler,Proc. ACM Nat. Conf. 20 (1965), 262–274.
PL/I Definition Group of the Vienna Laboratory,Formal definition of PL/I, IBM Technical Report TR 25.071 (1966).
Niklaus Wirth andHelmut Weber, Euler: A generalization ofAlgol, and its formal definition,Comm. ACM 9 (1966), 11–23, 89–99, 878.
Author information
Authors and Affiliations
Rights and permissions
About this article
Cite this article
Knuth, D.E. Semantics of context-free languages. Math. Systems Theory 2, 127–145 (1968). https://doi.org/10.1007/BF01692511
Received:
Issue Date:
DOI: https://doi.org/10.1007/BF01692511