0% found this document useful (0 votes)
48 views25 pages

Cclec01 PDF

This document provides an introduction and overview of a compilers course being taught at Azad University of Mashhad. It includes the course structure, topics to be covered, textbook references, and the instructor's contact information. The document then gives a brief overview of the major components of a compiler and how they work, including lexical analysis, syntax analysis, semantic analysis, and intermediate code generation.

Uploaded by

Jone Kaky
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views25 pages

Cclec01 PDF

This document provides an introduction and overview of a compilers course being taught at Azad University of Mashhad. It includes the course structure, topics to be covered, textbook references, and the instructor's contact information. The document then gives a brief overview of the major components of a compiler and how they work, including lexical analysis, syntax analysis, semantic analysis, and intermediate code generation.

Uploaded by

Jone Kaky
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

- 1386

)([email protected]


Compilers: Principles, Techniques, and Tools,

2/E, Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman

Publisher: Addison-Wesley

[email protected]




:
http://Khademzadeh.mshdiau.ac.ir

[email protected]

1 Lexical analysis, regular expressions


2 Formal grammars, Top-down parsing, LL(1)
3 Bottom-up parsing, shift-reduce, SLR(1), LR
and LALR parsing
4 Error repair/recovery, syntax directed
translation, Attribute grammars
5 Semantic analysis, type systems
6 Intermediate representation, three address
code
7 Runtime environments, code generation

[email protected]

[email protected]

[email protected]

[email protected]

front end ( analysis)


(scanning) ( lexical analysis)
( syntax analysis) ( )
(parsing)
(semantic analysis)
(Intermediate code generation)

[email protected]



(token)
(lexeme)

[email protected]


int a;
a = a + 2;
int
T_INT
a
T_IDENTIFIER
;
T_SPECIAL
";")
a
T_IDENTIFIER
=
T_OP
a
T_IDENTIFIER
+
T_OP
2
T_INTCONSTANT
;
T_SPECIAL
";")
[email protected]

(reserved word)
(variable name)
(special symbol with value of
(variable name)
(operator with value of "=")
(variable name)
(operator with value of "+")
(integer constant with value of 2)
(special symbol with value of



CFG
LHS RHS


)(derivation

[email protected]


Expression Expression + Expression |
Expression Expression |
...
Variable |
Constant |
...
Variable
T_IDENTIFIER
Constant
T_INTCONSTANT |
T_DOUBLECONSTANT

[email protected]

( )
X + 19
Expression Expression + Expression
Variable + Expression
T_IDENTIFIER + Expression
T_IDENTIFIER + Constant
T_IDENTIFIER + T_INTCONSTANT

[email protected]




) (

[email protected]


;int arr[2], c
;c = arr * 10


[email protected]




: )(TAC
:
a=b*c+b*d
_t1 = b * c
_t2 = b * d
_t3 = _t1 + _t2
a = _t3

[email protected]

-

if (a <= b)
a = a - c;
c = b * c;
_t1 = a > b
if _t1 goto L0
_t2 = a c
a = _t2
L0: _t3 = b * c
c = _t3
[email protected]

back end ( synthesize)


(Intermediate code
optimization)
(Object code generation)
(Object code optimization)
.

[email protected]






[email protected]

) - (

_t1 = b * c
_t2 = _t1 + 0
_t3 = b * c
_t4 = _t2 + _t3
a = _t4
_t1 = b * c
_t2 = _t1 + _t1
a = _t2

[email protected]

_t1 = b * c
_t2 = _t1 + _t1
a = _t2
ld [%fp-16], %l1
ld [%fp-20], %l2
smul %l1, %l2, %l3
add %l3, %l3, %l0
st %l0, [%fp-24]

[email protected]

# load
# load
# mult
# add
# store

[email protected]

)(symbol table

[email protected]

[email protected]



Multi-pass
One-pass

[email protected]

You might also like