Presentation is loading. Please wait.

Presentation is loading. Please wait.

C Chuen-Liang Chen, NTUCS&IE / 1 COMPILER Chuen-Liang Chen Department of Computer Science and Information Engineering National Taiwan University Taipei,

Similar presentations


Presentation on theme: "C Chuen-Liang Chen, NTUCS&IE / 1 COMPILER Chuen-Liang Chen Department of Computer Science and Information Engineering National Taiwan University Taipei,"— Presentation transcript:

1 c Chuen-Liang Chen, NTUCS&IE / 1 COMPILER Chuen-Liang Chen Department of Computer Science and Information Engineering National Taiwan University Taipei, TAIWAN

2 c Chuen-Liang Chen, NTUCS&IE / 2 Compiler first compiler -- Fortran, late 1950s, 18 man-years scopes of this course  sequential procedural language  von Neumann machine compiler / interpreter human programming language machine machine language  target –bare machine –virtual machine  format –assembly –relocatable –memory-image analysis language- dependent synthesis machine- dependent  constructions –hand-coded –compiler generator (compiler compiler)

3 c Chuen-Liang Chen, NTUCS&IE / 3 Compiling technology silicon compiler command interpreter of O.S. query lang. interpreter of DBMS and so on compiler / interpreter compiling technology

4 c Chuen-Liang Chen, NTUCS&IE / 4 Analyses lexical –regular expression syntax (structure) –context-free grammar semantics (meaning)  static semantics –attribute grammar  run-time semantics –Vienna definition language,... syntax error a = b + ; static semantic error int a, b ; boolean c ; a = b + c ; run-time semantic error int a, b, c ; b = largest_integer ; c = 1 ; a = b + c ;

5 c Chuen-Liang Chen, NTUCS&IE / 5 Structures of compilers (1/3) syntax-directed translation -- driven by the syntactic structure of source program calling tree (2 passes) machine code main parser scanner semantic routines optimizer code generator symbol table attribute table token SS : syntactic structure (parse tree) IR : intermediate representation source code SS IR pass 1pass 2

6 c Chuen-Liang Chen, NTUCS&IE / 6 Structures of compilers (2/3) calling tree (1 pass) machine code main parser scanner semantic routines optimizer symbol table attribute table token SS : syntactic structure (parse tree) source code SS pass 1 code generator

7 c Chuen-Liang Chen, NTUCS&IE / 7 Structures of compilers (3/3) calling tree (n passes, n > 2)  emphasizing on optimizations  especially for advanced computer architectures, e.g., RISC, VLIW, vector computer, multiprocessor system,... machine code main parser scanner semantic routines code generator symbol table attribute table token SS : syntactic structure (parse tree) IR : intermediate representations source code SS IR opt 2opt 1

8 c Chuen-Liang Chen, NTUCS&IE / 8 Compiler compiler for scanner and parser, based on precise mathematical modeling table-driven, usually lex and yacc  on UNIX  lex.yy.c and y.tab.c include table and driver program  *.l, *.y, yyerror.c and main.c have many common external variables cc as cc as ld yacc lex *.l *.y yyerror.c main.cmain.oyacc lib lex lib compiler yyerror.o y.tab.o lex.yy.o y.tab.h lex.yy.c int yylex() y.tab.c int yyparse() cc / as

9 c Chuen-Liang Chen, NTUCS&IE / 9 About this course text book: Charles N. Fischer and Richard J. LeBlanc, Jr., Crafting a Compiler with C, Benjamin/Cummings, 1991. reference books: many evaluation: 2 examinations + term project term project: a high-level language to byteCode compiler email: clchen@csie.ntu.edu.tw, compiler@csie.ntu.edu.tw slides,... : ntucs?:/usr/course/compiler office hour: Thursday 8:00-9:00, Room 513 (1998 Fall)


Download ppt "C Chuen-Liang Chen, NTUCS&IE / 1 COMPILER Chuen-Liang Chen Department of Computer Science and Information Engineering National Taiwan University Taipei,"

Similar presentations


Ads by Google