1 / 10

1. 컴파일러 개론

1. 컴파일러 개론. 1-1. Compiler 정의 1-2. Language Processing System 1-3. 컴파일러 논리적구조 (phase) 1-4. Compiler Organization. compiler. Target program. Source program. error. 1-1. Compiler 정의. A Compiler is a program that reads a program written

cooper
Télécharger la présentation

1. 컴파일러 개론

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. 1. 컴파일러 개론 1-1. Compiler 정의 1-2. Language Processing System 1-3. 컴파일러 논리적구조 (phase) 1-4. Compiler Organization

  2. compiler Target program Source program error 1-1. Compiler 정의 A Compiler is a program that reads a program written in one language – source program – and translates it into an equivalent program in another language – target(object) program

  3. 1-2. Language processing system Skeletal source program(high) preprocessor Front-end 분석 형식이론 (확립) highlevel language compiler IL lowlevel, assembly language Back-end 합성 경험적 이론 assembler Relocatable machine code loader Absolute machine code (executable machine code)

  4. 전 반 부 Lexical analysis (어휘분석) Syntax analysis (구문분석) Symbol table Semantic analysis (의미분석) Error handle Intermediate code generation (중간코드생성) Code optimization (코드 최적화) Code generation (코드 생성) 후 반 부 1-3. 컴파일러 논리적 구조 (phase)

  5. Lexical analysis (어휘분석) • source program을 읽어서 문법의 최소 단위인 token을 생성하는 일 • A := B + 3 ; (token의 개수 : 6개) • A, B (variable), := (assignment symbol), +(plus operator), 3(numeric), ;(delimeter) 특수형태 : keyword, operator, delimeter Token 일반형태 : identifier, 상수

  6. Syntax analysis (구문분석) • token을 읽어 오류를 검색하고 올바른 문장에 대한 구문구조를 만든다. A := B + 3 ; := Top-down 방식 A + B 3

  7. Semantic analysis (의미분석) • type checking(형 검사) • 각 연산자가 원시 언어의 정의에 맞는 피연산자를 가지는가를 검사 • Intermediate code generation (중간코드생성) • 구문구조를 이용하여 코드 생성 또는 문법규칙에 의해 생성 • 예) A := B + 3; load 1 2 loc 3 add str 1 1 U code

  8. Code optimazation (코드 최적화) • 선택적 단계 (공간적, 시간적 효율화를 위해 필수적) • Code generation (코드 생성) • 목적코드 생성 • assemble language, machine code  Cross compiler • 다른 machine에서 실행하기 위한 object program 생성

  9. position := initial + rate * 60 Intermediate code generator Lexical analyzer Symbol Table temp1 := inttoreal(60) temp2 := id3 * temp1 temp3 := id2 + temp2 id1 := temp3 1 2 3 4 position ... initial … id1 := id2 + id3 * 60 Syntax analyzer rate ... Code optimizer temp1 := id3 * 60.0 id1 := id2 + temp1 := id1 + id2 Code generator * Semantic analyzer id3 60 MOVF id3, R2 MOVF #60.0, R2 MOVF id2, R2 ADDF R2, R1 MOVF R1, id1 := id1 + id2 * inttoreal id3 60  Translation of a statement

  10. 1-4. Compiler Organization Compiler organization Logical organization (phase) Physical organization (pass) Single Pass Multi pass 속도 증가 메모리 많이 사용 속도 저하 메모리 적게 사용

More Related