2016 | OriginalPaper | Chapter
12. Language Theory and Semantics
Published in:
Guide to Discrete Mathematics
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.