Clite(抽象语法).ppt_第1页
Clite(抽象语法).ppt_第2页
Clite(抽象语法).ppt_第3页
Clite(抽象语法).ppt_第4页
Clite(抽象语法).ppt_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

clite语法类型的非概要信息和意义 (2014025704-116),Program:Declarations 和一个Compound; Declaration:个体Declaration序列; Declaration:个体变量,其类型和大小; Type:int,bool,float,char集合的部分; Statement:子类Compound,Skip,Assignment,Conditional和Loop; Compound:个体Statement序列,以他们出现的顺序执行。每一个出现在抽象语法树的相同层次。 Skip:跳转语句 Assignment:将表达式赋给变量的语句,conditional:一个表达式(test)和两个语句(thenbranch和elsebranch),其中一个被执行则另一个则跳过。在if-then语句,elsebranch作为一个Skip语句的实例。 Lood:一个表达式(test)和一个只要测试结果是ture就不断重复的语句(循环体)。 Expression:子类Variable,Value,Binary,和Unary; Binary:一个Operater和两个Expression; Unary:一个Operator和两个Expression; Operator: 数学运算符:plus,minus,times,divide,Value:有子类IntValue,FloatValue,BoolValue和CharValue intValue:整数值 FloatValue:浮点数值,描述从计算机近似值到一非整数值。 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/*仔细看一下其实也不难-取决你态度*/,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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论