40 likes | 183 Views
Ch7. Programming Language and Systems An Introduction to Informatics. 2008. 12. 1 In-Bon Kuh GNU OSLab. Source Program. Lexical Analysis. Tokens. Symbol Tables. Syntax Analysis. Intermediate Form. Code Generation. Target Program. < Compiler Phases >. ... ...
E N D
Ch7. Programming Languageand SystemsAn Introduction to Informatics 2008. 12. 1 In-Bon Kuh GNU OSLab.
Source Program Lexical Analysis Tokens SymbolTables Syntax Analysis Intermediate Form Code Generation Target Program < Compiler Phases > An Introduction to Informatics
... ... ifb = 15 thenx := (a + c) / xelsey := x ... ... ... ... LD B AC B SUB N15 AC AC - 15 BNZ L5 Go to else part, if AC ≠ 0 LD A AC A ADD C AC AC + C DIV X AC AC / X (quotient) ST X X AC B L6 Go to the end of statement L5 LD X AC X ST Y Y X L6 ... ... Compiler < Example of Source and Object Statements > An Introduction to Informatics
b, 15, = {Polish postfix of Boolean expression} IFJUMPL1 {Transfer on false.} x, a, c, +, x, /, := {True part of statement} JUMP L2 {Transfer of end of statement} L1: y, x, := {False part of statement} L2: 1: (=, b, 15, T1) {T1 (b = 15)} 2: (BNZ, T1, 6) {ifT1≠ 0 thengotoquadruple 6} 3: (+, a, c, T2) {T2 a + c} 4: (/, T2, x, x) {x T2 / x} 5: (BR, 7, ,) {gotoquadruple 7} 6: (ST, y, x,) {y x} 7: < Postfix Form > < Quadruples > An Introduction to Informatics