Chapter3: Language Translation issues. Programming language Syntax Key criteria concerning syntax Basic syntactic concepts Overall Program-Subprogram structure Stages in Translation Analysis of the source program Synthesis of the object program Bootstrapping. What is Syntax.
The syntax of a programming language describes the structure of programs without any consideration of their meaning.
Readability – a program is considered readable if the algorithm and data are apparent by inspection.
Writeability – ease of writing the program.
Verifiability – ability to prove program correctness (very difficult issue)
Translatability – ease of translating the program into executable form.
Lack of ambiguity – the syntax should provide for ease of avoiding ambiguous structures
Separate subprogram definitions: Separate compilation, linked at load time E.G. C/C++
Separate data definitions:General approach in OOP.
Nested subprogram definitions: Subprogram definitions appear as declarations within the main program or other subprograms. E.G. Pascal
Separate interface definitions:
C/C++ header files
Data descriptions separated from executable statements. A centralized data division contains all data declarations. E.G. COBOL
Unseparated subprogram definitions: No syntactic distinction between main program statements and subprogram statements.
Three main steps:
Optimization - Removing redundant statements
Code generation - generating assembler commands with relative memory addresses for the separate program modules - obtaining the object code of the program.
Linking and loading - resolving the addresses - obtaining the executable code of the program.
Assembler code not optimized:
Temp1 = B + C
Temp2 = Temp1 + D
A = Temp2
Statements in yellow can be removed