Abstract

본 연구에서는 Haskell의 모나드 기법을 이용한 명령형 언어의 컴파일러 구현에 대해 논의한다. 이 컴파일러는 한 생성 룰이 입력 스트링의 파싱을 실패할 때 다른 생성 룰로써 파싱하는 backtracking 기능의 비 결정적 Recursive Descent Parser를 포함한다. Haskell은 파싱에 필요한 우수한 기능들을 가지고 있다. Haskell의 대수적 타입은 추상구문트리를 자연스럽게 표현할 수 있으며, 모나드 파싱을 적용한 프로그램 코드는 매우 간결하여 가독성이 좋고, 타 언어에 의해 구현된 것에 비해 코드의 양이 획기적으로 감소된다. 이 컴파일러의 목적 코드는 스택 머신을 기반으로 한 Stack-Assembly 언어로서 이것을 위한 코드 생성과 어셈블러 실행 환경에 대해서도 논의한다. We discuss the implementation of a compiler for an imperative programming language, using monad in Haskell. This compiler involves a recursive-descent parser conducting nondeterministic parsing, in which backtracking occurs to try with other rules when the application of a production rule fails to parse an input string. Haskell has some strong facilities for parsing. Its algebraic types represent abstract syntax trees in a smooth way, and program codes by monad parsing are so concise that they are highly readable and code size is reduced significantly, comparing with other languages. We also deal with the runtime environment of the assembler and code generation whose target is the Stack-Assembly language based on a stack machine.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call