Clite(抽象語法).ppt_第1頁
Clite(抽象語法).ppt_第2頁
Clite(抽象語法).ppt_第3頁
Clite(抽象語法).ppt_第4頁
Clite(抽象語法).ppt_第5頁
已閱讀5頁,還剩4頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

clite語法類型的非概要信息和意義 (2014025704-116),Program:Declarations 和一個Compound; Declaration:個體Declaration序列; Declaration:個體變量,其類型和大小; Type:int,bool,float,char集合的部分; Statement:子類Compound,Skip,Assignment,Conditional和Loop; Compound:個體Statement序列,以他們出現(xiàn)的順序執(zhí)行。每一個出現(xiàn)在抽象語法樹的相同層次。 Skip:跳轉語句 Assignment:將表達式賦給變量的語句,conditional:一個表達式(test)和兩個語句(thenbranch和elsebranch),其中一個被執(zhí)行則另一個則跳過。在if-then語句,elsebranch作為一個Skip語句的實例。 Lood:一個表達式(test)和一個只要測試結果是ture就不斷重復的語句(循環(huán)體)。 Expression:子類Variable,Value,Binary,和Unary; Binary:一個Operater和兩個Expression; Unary:一個Operator和兩個Expression; Operator: 數(shù)學運算符:plus,minus,times,divide,Value:有子類IntValue,FloatValue,BoolValue和CharValue intValue:整數(shù)值 FloatValue:浮點數(shù)值,描述從計算機近似值到一非整數(shù)值。 BoolValue:Boolean值,也就是說不是ture就是false; Char Value:單個字符值;,Clite程序抽象語法樹: Program=Declarations decpart; Statements body; Declaration=Declaration* Declaration=VarableDecl | ArrayDecl VariableDecl=Variable v;Type t ArrayDecl=Variable v;Typt t;Integer size Type= int | bool | float | char Statements=Statemment* statement=Skip | Block |Assignment |Conditional |Loop Skip= Block=Statements Conditionnal=Expression test ;Statement thenbranch,elsebranch Loop=Expression test;Statement body Assignment=VariableRef target;Expression source Expression=VariableRef | Value | Binary |Unary,Variable Ref=Variable | ArrayRef Binary=Operator op;Expression term1,term2 Unary=UnaryOp op;Expression term Operator=BooleanOp | RelationnalOp | ArithmeticOp BooleanlOp= Expression index Value = IntValue | BoolValue | FloatValue | CharValue IniValue =Integer intValue FloatValue=Float floatvalue BoolValue =Boolean boolvalue CharValue = Character charvalue/*仔細看一下其實也不難-取決你態(tài)度*/,A.1 Clite 詞匯和具體句法 /*所有引用變量必須聲明*/ Program int main () Declarations Statements Declarations Declaration Declaration Type Identifier integer .Identifier integer; Type int | bool | float | char Statements-Statement Statement: | Block | Assignment | If Statement | WhileStatement Block -Statement Assignment -Identifier Expression =Expression; If Statementif (Expression) Statement else Statement WhileStatement while (Expression) Statement ExpressionConjunction |Conjunction Conjunction Equality& Equality EqualityRelationEquOp Relation ,EquOp-= | != RelationAdditionRelOp Addition RelOp | = Addition Term AddOp Term AddOp+ | - Term Factor MulOp Factor MuiOp* | / | % FactorUnaryOpPrimary UnaryOp - | ! PrimaryIdentifier Expression | Literal | (Expression ) | Type (Expression) Identifier Letter Letter | Digit Boolean-true | false FloatInteger .Integer Char ASCIIChar,A.2 Clite 的抽象句法 /*所有聲明變量必須唯一*/ Program =Declarations decpart; Statements body; Declaration =Declaration* Declarations =VariableDecl | ArrayDecl VariableDecl = Variable V ; Type t ArrayDecl = Variable v;Type t;Integer size Type= int | bool | float | char Statements =Statement* Statement =Skip | Block | Assignment | Conditional | Loop Skip = Block=Statements Conditional=Experssion test;Statement thenbranch, elsebranch Loop=Expression test ;Statement body Assignment=VariableRef target ; Expression source Expression =VariableRef | Value |Binary | Unary VariableRef =Variable | ArrayRef,Binary=BinaryOp op;Expression term1,term2 Unary=UnaryOp op;Expression term1,term2 Operator=BooleanOp | RelationalOp | ArithmeticOp | UnaryOp BooleanlOp= Expression index

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論