陳鍾誠 | 教材 | 程式 | 文章 | 留言版


編譯器設計

編譯器設計


教科書

  • 電子書:Compiler Construction , 作者:Niklaus Wirth - http://www.oberon.ethz.ch/WirthPubl/CBEAll.pdf

  • 相關課程

  • 系統程式 | 作業系統 | C語言程式設計

  • 參考書


  • 編譯器實作-使用C(附光碟), 作者:林邦傑, 出版社:松崗

  • 授課教材

    主題 投影片 說明
    編譯器簡介 Compiler.ppt
    語法理論 Grammar.ppt
    掃描器簡介 Scanner.ppt
    剖析器簡介 Parser.ppt
    程式產生器 CodeGenerator.ppt
    最佳化方法 CodeOptimizer.ppt
    虛擬機器 VirtualMachine.ppt
    自然語言處理 NaturalLanguageProcessing.ppt
    補充:正則表示法 RegularExpression.ppt

    範例程式

  • 正則表達式的用法 (取得網頁中的網址) -- grep.cs
  • 掃描程式 (Regular Expression 版) -- scanner1.cs
  • 掃描程式 (苦力直接判斷版) -- scanner2.cs
  • 剖析器 -- Parser1.cs, test.parser1.c3, 輸入:test99.parser1.c3
  • Block 轉 XML 語法的編譯器 -- BlockToXmlCompiler.cs, 輸入:EditorMenu.block, 輸出:EditorMenu.xml
  • 很小的 P-Code 編譯器 -- Compiler1.cs, Compiler2.cs, 輸入:test99.c3,
  • 很小的 解譯器 -- Interpreter1.cs, 輸入:test99.c3
  • 編譯器 -- C3Compiler.zip

  • 網路資源

    資源說明 下載檔案
    Stanford 的 Compiler 課程 http://www.stanford.edu/class/cs143/
    Tadao Takaoka 的 Compiler課程 http://www.cosc.canterbury.ac.nz/tad.takaoka/cosc230/index.html
    FreeComputerBooks http://freecomputerbooks.com/
    中研院 徐贊生 Compiler 課程 http://www.iis.sinica.edu.tw/~tshsu/compiler2004/index.html
    MSDN 中的 Regular Expression http://msdn2.microsoft.com/en-us/library/az24scfc.aspx
    Java 中的 Regular Expression http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/java/util/regex/Pattern.html
    維基百科 編譯分類
    http://www.scifac.ru.ac.za/compilers/
    http://scifac.ru.ac.za/resourcekit/pdf/
    http://www.cs.princeton.edu/~appel/modern/basic/java/
    http://cs.fit.edu/~ryan/cse4251/
    LOGO 語言 http://www.cs.berkeley.edu/~bh/v3-toc2.html
    http://www.cs.berkeley.edu/~bh/
    Logo

    GCC 的設計方式解說

  • http://en.wikibooks.org/wiki/GNU_C_Compiler_Internals/GNU_C_Compiler_Architecture_4_1
  • http://www.redhat.com/magazine/002dec04/features/gcc/

  • 課程內容


    1. Introduction
    2. Language and Syntax
    2.1. Exercises
    3. Regular Languages
    4. Analysis of Context-free Languages
    4.1. The method of recursive descent
    4.2. Table-driven top-down parsing
    4.3. Bottom-up parsing
    4.4. Exercises
    5. Attributed Grammars and Semantics
    5.1. Type rules
    5.2. Evaluation rules
    5.3. Translation rules
    5.4. Exercises
    6. The Programming Language Oberon-0
    7. A Parser for Oberon-0
    7.1. The scanner
    7.2. The parser
    7.3. Coping with syntactic errors
    7.4. Exercises
    8. Consideration of Context Specified by Declarations
    8.1. Declarations
    8.2. Entries for data types
    8.3. Data representation at run-time
    8.4. Exercises
    9. A RISC Architecture as Target
    10. Expressions and Assignments
    10.1. Straight code generation according to the stack principle
    10.2. Delayed code generation
    10.3. Indexed variables and record fields
    10.4. Exercises
    11. Conditional and Repeated Statements and Boolean Epressions
    11.1. Comparisons and jumps
    11.2. Conditional and repeated statements
    11.3. Boolean operations
    11.4. Assignments to Boolean variables
    11.5. Exercises
    12. Procedures and the Concept of Locality
    12.1. Run-time organization of the store
    12.2. Addressing of variables
    12.3. Parameters
    12.4. Procedure declarations and calls
    12.5. Standard procedures
    12.6. Function procedures
    12.7. Exercises
    5
    13. Elementary Data Types
    13.1. The types REAL and LONGREAL
    13.2. Compatibility between numeric data types
    13.3. The data type SET
    13.4. Exercises
    14. Open Arrays, Pointers and Procedure Types
    14.1. Open arrays
    14.2. Dynamic data structures and pointers
    14.3. Procedure types
    14.5. Exercises
    15. Modules and Separate Compilation
    15.1. The principle of information hiding
    15.2. Separate compilation
    15.3. Implementation of symbol files
    15.4. Addressing external objects
    15.5. Checking configuration consistency
    15.6. Exercises
    16. Code Optimizations and the Frontend/backend Structure
    16.1. General considerations
    16.2. Simple optimizations
    16.3. Avoiding repeated evaluations
    16.4. Register allocation
    16.5. The frontend/backend compiler structure
    16.6. Exercises
    Appendix A: Syntax
    A.1. Oberon-0
    A.2. Oberon
    A.3. Symbol files
    Appendix B: The ASCII character set
    Appendix C: The Oberon-0 compiler
    C.1. The scanner
    C.2. The parser
    C.3. The code generator
    




    作者:陳鍾誠 E-mail:ccc@kmit.edu.tw
    Creative Commons License

    本著作係採用創用 CC 「姓名標示─相同方式分享 2.5 台灣版」授權條款釋出。

    大學課程網 | 手機入口網