1. 程式人生 > >High-level structure of a simple compiler高級結構的簡單編譯器

High-level structure of a simple compiler高級結構的簡單編譯器

dir rms table and ctu http err analyze mage

技術分享圖片

技術分享圖片

1.lexical analysis,which analyzes the character string presented to it and divides it up into tokens that are legal members of the vocabulary of the language in which the program is written (and may produce error messages if the character string is not parseable into a string of legal tokens);

2.syntactic analysis or parsing,which processes the sequence of tokens and produces an intermediate-level representation,such as a parse tree or a sequential intermediate code,and a symbol table that records the identifiers used in the program and their attibutes.

3.checking of the program for static-semantic validity

(or semantic checking),which takes as input the intermediate code and symbol table and determines whether the program satisfiers the staic-semantic properties required by the source language.

4.code generation,which transforms the intermediate code into equivalent machine code in the form of a relocatable object module or directly runnable object code.


1.詞法分析,它分析呈現給它的字符串,並將其劃分為令牌,這些令牌是編寫程序的語言詞彙的合法成員(如果字符串不能解析成字符串,則可能產生錯誤消息。一串合法代幣);

2.語法分析或解析,它處理令牌序列並產生中間級表示,例如解析樹或順序中間代碼,以及記錄程序中使用的標識符及其屬性的符號表。

3.檢查程序的靜態語義有效性(或語義檢查),它將中間代碼和符號表作為輸入,並確定程序是否滿足源語言所需的基本語義屬性。

4.代碼生成,它以可重定位目標模塊或直接可運行目標代碼的形式將中間代碼轉換為等效的機器代碼。

High-level structure of a simple compiler高級結構的簡單編譯器