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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
ε denotes the empty word.
- 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.
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.
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.
Of course, what the programmer has written may not be what the programmer had intended.
- 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.
Hoare was influenced by earlier work by Floyd on assigning meanings to programs using flowcharts [4].
- 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.
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.
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.
This essentially expresses that the names of bound variables is unimportant.
- 12.
This essentially expresses the idea of function application.
- 13.
This essentially expresses the idea that two functions are equal if and only if they give the same results for all arguments.
References
Introduction to the History of Computing. Gerard O’Regan. Springer Verlag. 2016.
Report on the Algorithmic Language, ALGOL 60. Edited by P. Naur. Communications of the ACM, 3(5):299–314, 1960.
An Axiomatic Basis for Computer Programming. C.A.R. Hoare. Communications of the ACM. 12(10):576–585. 1969.
Assigning Meanings to Programs. Robert Floyd. Proceedings of Symposia in Applied Mathematics, (19), 19-32. 1967.
Mathematical Approaches to Software Quality. Gerard O’ Regan. Springer. 2006.
A Structural Approach to Operational Semantics. Gordon Plotkin. Technical Report DAIM FN-19. Computer Science Department. AarhusUniversity, Denmark. 1981.
Introduction to the Theory of Programming Languages. Bertrand Meyer. Prentice Hall. 1990.
Denotational Semantics. The Scott-Strachey Approach to Programming Language Theory. Joseph Stoy. MIT Press. 1977.
Author information
Authors and Affiliations
Corresponding author
Rights 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)