1 / 22

Compiler Construction

Compiler Construction. 1 장. 간략한 소개. 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.

Download Presentation

Compiler Construction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Compiler Construction 1장

  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. Compilers and Interpreters • Compilers source program  compiler  target program |__ error messages • Interpreters source program  interpreter  result data __|

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

  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. 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. 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. 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. Fig. 1.3. A language-processing system preprocessor Skeletal source program Source program Target assembly program Relocatable machine code library, relocatable object files Absolute machine code compiler assembler Loader/link-editor

  10. Fig. 1.9. Phases of a compiler

  11. Fig. 1.10. Translation of a statement

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

  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. 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. Syntax Analysis Fig. 1.4 Parse tree for position := initial + rate + 60

  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. Fig. 1.5. Semantic analysis inserts a conversion from integer to real.

  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. Fig. 1.11. The data structure in (b) is for the tree in (a).

  20. (1.3) (1.4) (1.5)

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

More Related