Skip to main content

Language Theory and Semantics

  • Chapter
  • First Online:
Guide to Discrete Mathematics

Part of the book series: Texts in Computer Science ((TCS))

Abstract

There are two key parts to any programming language, and these are its syntax and semantics . The syntax is the grammar of the language and a program needs to be syntactically correct with respect to its grammar. The semantics of the language is deeper, and determines the meaning of what has been written by the programmer. The compiler preserves the semantics of the language, where a compiler is a program that translates a program that is written in some programming language into another form. It involves syntax analysis and parsing to check the syntactic validity of the program; semantic analysis to determine what the program should do; optimization to improve the speed and performance; and code generation in some target language.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 44.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 59.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    ε denotes the empty word.

  2. 2.

    Recall from chapter 6 that a monoid (M, *, e) is a structure that is closed and associative under the binary operation “*”, and it has an identity element “e”.

  3. 3.

    Chomsky made important contributions to linguistics and the theory of grammars. He is more widely known today as a critic of United States foreign policy.

  4. 4.

    Backus Naur Form is named after John Backus and Peter Naur. It was created as part of the design of the Algol 60 programming language, and is used to define the syntax rules of the language.

  5. 5.

    Of course, what the programmer has written may not be what the programmer had intended.

  6. 6.

    There are attribute (or affix) grammars that extend the syntactic description of the language with supplementary elements covering the semantics. The process of adding semantics to the syntactic description is termed decoration.

  7. 7.

    Hoare was influenced by earlier work by Floyd on assigning meanings to programs using flowcharts [4].

  8. 8.

    Total correctness is expressed using {P}a{Q} amd program fragment a is totally correct for precondition P and postcondition Q if and only if whenever a is executed in any state in which P is satisfied then execution terminates, and the resulting state satisfies Q.

  9. 9.

    This virtual stack based machine was originally designed by Peter Landin to evaluate lambda calculus expressions, and it has since been used as a target for several compilers.

  10. 10.

    This is similar to what a compiler does in that if errors are found during the compilation phase, the compiler halts and displays the errors and does not continue with code generation.

  11. 11.

    This essentially expresses that the names of bound variables is unimportant.

  12. 12.

    This essentially expresses the idea of function application.

  13. 13.

    This essentially expresses the idea that two functions are equal if and only if they give the same results for all arguments.

References

  1. Introduction to the History of Computing. Gerard O’Regan. Springer Verlag. 2016.

    Google Scholar 

  2. Report on the Algorithmic Language, ALGOL 60. Edited by P. Naur. Communications of the ACM, 3(5):299–314, 1960.

    Google Scholar 

  3. An Axiomatic Basis for Computer Programming. C.A.R. Hoare. Communications of the ACM. 12(10):576–585. 1969.

    Google Scholar 

  4. Assigning Meanings to Programs. Robert Floyd. Proceedings of Symposia in Applied Mathematics, (19), 19-32. 1967.

    Google Scholar 

  5. Mathematical Approaches to Software Quality. Gerard O’ Regan. Springer. 2006.

    Google Scholar 

  6. A Structural Approach to Operational Semantics. Gordon Plotkin. Technical Report DAIM FN-19. Computer Science Department. AarhusUniversity, Denmark. 1981.

    Google Scholar 

  7. Introduction to the Theory of Programming Languages. Bertrand Meyer. Prentice Hall. 1990.

    Google Scholar 

  8. Denotational Semantics. The Scott-Strachey Approach to Programming Language Theory. Joseph Stoy. MIT Press. 1977.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Gerard O’Regan .

Rights and permissions

Reprints and permissions

Copyright information

© 2016 Springer International Publishing Switzerland

About this chapter

Cite this chapter

O’Regan, G. (2016). Language Theory and Semantics. In: Guide to Discrete Mathematics. Texts in Computer Science. Springer, Cham. https://doi.org/10.1007/978-3-319-44561-8_12

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-44561-8_12

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-44560-1

  • Online ISBN: 978-3-319-44561-8

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics