Introduction


프로그램은 어디서나 사용된다. 그리고 그 프로그램을 실행하려면 컴파일러가 필요하다.

컴파일러 설계의 원리와 기술은 컴퓨터 과학자의 경력에 여러번 재사용 가능하다.

컴파일러 설계와 컴퓨터 과학이론과 컴파일러 기술 응용에 대한 개요를 배운다.

컴파일러 공부에 필요한 Programming language 키워드에 대해서 짧게 배운다.


1.1 Language Processor


Compiler

- source program  ->  target program

- 에러 찾기 ( source program 변환 과정에서)




Target program이 실행 가능한 machine-language 일 경우

- input  ->  output



Interpreter

- source program+input  ->  output

- input이 생긴 source program에 직접적으로 지정된 작업을 실행함.




compiler가 interpreter 보다 맵핑이 빠르다.

interpreter는 Compiler보다 에러진단이 좋다. 왜냐하면, statement로 source program statement를 실행하기 때문이다.


Java = hybrid Compiler = compiler + interpreter

- Javacode는 bytecode로 먼저 컴파일

- bytecode는 가상 머신에 의해서 해석됨. ( 다른 곳에서 해석 = 여러 플랫폼에 적용 가능한 이유일지도???)

- Java는 속도 높이려고 immediate program 실행 전에 bytecode를 machine-language로 바꿈.

- Just-in-time Compiler



Compiler는 Target program을 만들기 위해서 아래 그림 1.5와 같이 여러 가지 과정이 있음.

Source program은 전처리기가 담당.

전처리기는 매크로를 소스 언어의 상태로 만들고

modified source program은 Compiler로 간다.

Compiler는 assembly language를 만든다.
assembly language는 출력 처리, 디버깅에 좋음.


큰 프로그램은 나눠서 컴파일 되는 경우가 많다.

그래서 relocatable machine code는 실제 기계에서 relocatable object files와 library files와 함께 실행되는 코드가 됨.

링커는 한 파일의 코드가 다른 파일의 위치를 참조 할 수있는 외부 메모리 주소를 확인합니다.

loader는 모든 실행 가능한 오브젝트 파일을 메모리에 집어 넣어 실행합니다.




1.1.1 Execercises for Section 1.1


Exercise 1.1.1 : What is the difference between a compiler and an interpreter?

compiler : source program  ->  target program

interpreter : source program + input  ->  output


Exercise 1.1.2 : What are the advantages of a compiler over an interpreter an interpreter over a compiler?

compiler : 빠름 ( mapping inputs to outputs )

interpreter : 에러진단이 compiler보다 좋음.


Exercise 1.1.3 : What advantages are there to a language-processing system in which the compiler produces assembly language rather than machine language?

Assembly language가 출력 처리, 디버깅에 좋음.


Exercise 1.1.4 : A compiler that translates a high-level language into another high-level language is called a source-to-source translator. What advantages are there to using C as a target language for a compiler?

?????????????????????


Exercise 1.1.5 : Describe some of the tasks that an assembler needs to perform.

Assembly to relocatable machine code.










+ Recent posts