Skip to main content
Log in

Semantics of context-free languages

  • Published:
Mathematical systems theory Aims and scope Submit manuscript

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.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Institutional subscriptions

Similar content being viewed by others

References

  1. 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.

  2. 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.

  3. Corrado Böhm andWolf Gross, “Introduction to thecuch,”Automata Theory (ed. by E. R. Caianiello), pp. 35–65, Academic Press, 1966.

  4. 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.

  5. C. C. Elgot andA. Robinson, “Random-access, stored program machines, an approach to programming languages,”J. ACM 11 (1964), 365–399.

    Google Scholar 

  6. Edgar T. Irons, A syntax directed compiler forAlgol 60,Comm. ACM 4 (1961), 51–55.

    Google Scholar 

  7. Edgar T. Irons, Towards more versatile mechanical translators, Proc. Sympos. Appl. Math., Vol. 15, pp. 41–50, Amer. Math. Soc., Providence, R. I., 1963.

    Google Scholar 

  8. Donald E. Knuth,The Art of Computer Programming, I, Addison-Wesley, 1968.

  9. P. J. Landin, “The mechanical evaluation of expressions,”Comp. J. 6 (1964), 308–320.

    Google Scholar 

  10. 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.

  11. P. J. Landin, A correspondence betweenAlgol 60 and Church's lambda notation,Comm. ACM 8 (1965), 89–101, 158–165.

    Google Scholar 

  12. 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.

  13. 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.

    Google Scholar 

  14. Robert M. McClure, TMG—A syntax directed compiler,Proc. ACM Nat. Conf. 20 (1965), 262–274.

    Google Scholar 

  15. PL/I Definition Group of the Vienna Laboratory,Formal definition of PL/I, IBM Technical Report TR 25.071 (1966).

  16. Niklaus Wirth andHelmut Weber, Euler: A generalization ofAlgol, and its formal definition,Comm. ACM 9 (1966), 11–23, 89–99, 878.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints 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

Download citation

  • Received:

  • Issue Date:

  • DOI: https://doi.org/10.1007/BF01692511

Keywords

Navigation