Presentation is loading. Please wait.

Presentation is loading. Please wait.

Compiler Construction 1장1장. 2 간략한 소개  Aho, Sethi and Ullman  Kenneth C. Louden  Thomas W. Parsons  관련 과목 –Theories of programming languages –Automata.

Similar presentations


Presentation on theme: "Compiler Construction 1장1장. 2 간략한 소개  Aho, Sethi and Ullman  Kenneth C. Louden  Thomas W. Parsons  관련 과목 –Theories of programming languages –Automata."— Presentation transcript:

1 Compiler Construction 1장1장

2 2 간략한 소개  Aho, Sethi and Ullman  Kenneth C. Louden  Thomas W. Parsons  관련 과목 –Theories of programming languages –Automata theory –System programming (including O.S) –Assembly language –Data structures and File structures –Programming techniques

3 3 Compilers and Interpreters  Compilers source program  compiler  target program |__ error messages  Interpreters source program  interpreter  result data __|

4 4 역사  컴파일러 역사 –John Backus : FORTRAN compiler –Backus-Naur Form and Algol –N. Wirth : Pascal –C : System programming language –Ada : Language Environment –Java, C#, ….

5 5 인터프리터  Basic …. Bill Gates  APL … an intolerable complexity  Smalltalk … Object oriented languages  LISP … lambda calculus …. Incremental programming  Java … for ubiquitous computing, Internet  Embedded systems

6 6 New paradigm  For Internet, Home computing, Ubiquitous computing, embedded systems and so on  Languages and Compilers that are Small, Smart and Safe  Hybrid approach with concepts of compilers and interpreters –Java, C#  Virtual machine –Free University, Tannenbaum – 개념 설명

7 7 Java  Simple, Robust, Object-oriented, Platform-independent, multithreaded, dynamic, general-purpose programming environment  Write-once, Run Anywhere  Java virtual machine –Bytes codes : portability and platform independent  Java Runtime Environment

8 8 Software tools related to compilers  Structure editors  Pretty printers  Static checkers  Interpreters  Text formatters … tex, nroff, troff  Silicon compilers … System on chip  Query interpreter  Interpreters for HTML, XML, SGML

9 9 Skeletal source program Source program Target assembly program Relocatable machine code library, relocatable object files Absolute machine code preprocessor compiler assembler Loader/link-editor Fig. 1.3. A language-processing system

10 10 Fig. 1.9. Phases of a compiler

11 11 Fig. 1.10. Translation of a statement

12 12 Lexical Analysis  Finite state machine  Regular expression  Regular grammar  Kleen closure  O(n)  Lex  Editor, pattern search  Perl : $x =~ thing

13 13 Lexical Analysis In a compiler, linear analysis is called lexical analysis or scannning. For example,in lexical analysis the characters in the assignment statement position := initial + rate * 60 Would be grouped into the following tokens: 1. The identifier position. 2. The assignment symbol := 3. The identifier initial. 4. The plus sign. 5. The identifier rate. 6. The multiplication sign. 7. The number 60. The blanks separating the characters of these tokens would normally be eliminated during lexical analysis.

14 14 Syntax Analysis(Parsing)  Push-down automata  Context-free grammar  BNF(Backus-Naur Form)  O(n3)  LL, LR parsing  PLs, XML, HTML …  Interpretation framework  YACC … syntax-directed translation engine

15 15 Syntax Analysis Fig. 1.4 Parse tree for position := initial + rate + 60

16 16 Semantic Analysis  Context-sensitive grammar  bounded Turing machine  Unrestricted grammar  Turing machine  Unsolvable problem …. Heuristic rules  Type checking, resolving overload, scope rule, binding, ….  Syntax-directed translation engine

17 17 Fig. 1.5. Semantic analysis inserts a conversion from integer to real.

18 18 Code optimization and generation  Speed, space  Data-flow analysis  data flow engines  Two pass optimization –Pseudo code level : P-code, Bytes code –Target code level : register allocation, select efficient operations, efficient pipelining …  RISC machine 의 실패 (????) –Alpha chip  Free University ’ s approach, down loading  Automatic code generators

19 19 Fig. 1.11. The data structure in (b) is for the tree in (a).

20 20 (1.3) (1.4) (1.5)

21 21 Others  Portability –A 라는 컴파일러가 M 에서 수행될 때, N 이라는 기계에 이식하 는 방법 : 먼저 M 에서 intermediate code 에서 N 기계의 machine code 로 바꾸는 루틴을 작성하고, A 로 A 컴파일러를 작성한 후, 이를 컴파일하고, intermediate code 로 만든 후 N 기계의 기계어를 생성한다. 그리고 이를 down load 하여 사용 … – 컴파일러 개발에서 사용하는 방법  Multi-passes or single pass

22 22 Term project  Compiler 작성 –Java, C, XML, … 선택 가능 – 최대한 도와줄 것임 … 조교가 직접 자신이 짠 프로그램을 설 명하고, code generation part 는 강의에 포함하여 짤 수 있게 함 –Bytes code 는 설명할 것임 –Java 를 추천


Download ppt "Compiler Construction 1장1장. 2 간략한 소개  Aho, Sethi and Ullman  Kenneth C. Louden  Thomas W. Parsons  관련 과목 –Theories of programming languages –Automata."

Similar presentations


Ads by Google