1 / 9

The Modular 3 Grammar

The Modular 3 Grammar. Note that: 1. ALL CAPS indicates tokens/terminals 2. MiXeD CaSe indicates non-terminals Compilation --> Interface Module Interface --> T_INTERFACE T_IDENT T_SEMI OptImports OptDecl T_END T_IDENT T_PERIOD

kita
Download Presentation

The Modular 3 Grammar

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Modular 3 Grammar Note that: 1. ALL CAPS indicates tokens/terminals 2. MiXeD CaSe indicates non-terminals Compilation --> Interface Module Interface --> T_INTERFACE T_IDENT T_SEMI OptImports OptDecl T_END T_IDENT T_PERIOD Module --> T_MODULE T_IDENT OptExports T_SEMI OptImports Block T_IDENT T_PERIOD OptImports--> epsilon | ImportList ImportList--> ImportList Import | Import Import --> AsImport | FromImport AsImport --> T_IMPORT ImpItemLst T_SEMI FromImport--> T_FROM T_IDENT T_IMPORT IdList T_SEMI ImpItemLst--> ImpItemLst T_COMMA ImportItem | ImportItem ImportItem--> T_IDENT OptAs OptExports--> epsilon | T_EXPORTS IdList OptAs --> epsilon | T_AS T_IDENT

  2. The Modular 3 Grammar Block --> OptDecl T_BEGIN StmtGroup T_END OptDecl --> epsilon | DeclList T_SEMI DeclList --> DeclList Decl | Decl Decl --> T_CONST OptConDec ConDecLst | T_TYPE OptTypDec TypDecLst | T_VAR OptVarDec VarDecLst | ProcHead OptBlock | T_REVEAL OptReveal OptConDec --> epsilon | ConDecLst ConDecLst --> ConDecLst T_SEMI ConstDecl | ConstDecl ConstDecl --> T_IDENT OptType T_EQ ConstExpr OptType --> epsilon | T_COLON Type OptTypDec --> epsilon | TypDecLst TypDecLst --> TypDecLst T_SEMI TypeDecl | TypeDecl TypeDecl --> T_IDENT TypeSym Type TypeSym --> T_EQ | T_LTCOL

  3. The Modular 3 Grammar OptVarDec --> epsilon | VarDecLst VarDecLst --> VarDecLst T_SEMI VarDecl | VarDecl VarDecl --> IdList VarRest VarRest --> T_COLON Type | T_COLON Type T_ASSIGN Expr | T_ASSIGN Expr ProcHead --> T_PROC T_IDENT Signature Signature --> T_LPAR OptFormals T_RPAR OptType OptFormals--> epsilon | FormalList OptSemi FormalList--> FormalList T_SEMI Formal | Formal Formal --> OptMode IdList FormRest OptMode --> epsilon | Mode Mode --> T_VALUE | T_VAR | T_READONLY FormRest --> T_COLON Type | T_COLON Type T_ASSIGN ConstExpr | T_ASSIGN ConstExpr OptBlock --> epsilon | T_EQ Block T_IDENT OptReveal --> epsilon | RevealList

  4. The Modular 3 Grammar RevealList--> RevealList T_SEMI RevealRest | RevealRest RevealRest--> QualId T_EQ Type Statement --> AssignSt | Block | CallSt | CaseSt | ExitSt | ForSt | IfSt | LoopSt | RepeatSt | ReturnSt | WhileSt StmtGroup --> epsilon | StmtList OptSemi StmtList --> StmtList T_SEMI Statement | Statement AssignSt --> Expr T_ASSIGN Expr CallSt --> Expr T_LPAR ActualSel T_RPAR CaseSt --> T_CASE Expr T_OF OptCase OptElse T_END OptCase --> epsilon | CaseList CaseList --> CaseList T_BAR Case | Case Case --> LabelList T_IMPLIES StmtGroup LabelList --> LabelList T_COMMA Labels | Labels Labels --> ConstExpr OptRange OptRange --> epsilon | T_DOTDOT ConstExpr

  5. The Modular 3 Grammar OptElse --> epsilon | T_ELSE StmtGroup ExitSt --> T_EXIT ForSt --> T_FOR T_IDENT T_ASSIGN Expr T_TO Expr OptBy T_DO StmtGroup T_END OptBy --> epsilon | T_BY Expr IfSt --> T_IF Expr T_THEN StmtGroup OptElseIf OptElse T_END OptElseIf --> epsilon | ElseIfList ElseIfList--> ElseIfList ElseIfSt | ElseIfSt ElseIfSt --> T_ELSEIF Expr T_THEN StmtGroup LoopSt --> T_LOOP StmtGroup T_END RepeatSt --> T_REPEAT StmtGroup T_UNTIL Expr ReturnSt --> T_RETURN OptReturn OptReturn --> epsilon | Expr WhileSt --> T_WHILE Expr T_DO StmtGroup T_END

  6. The Modular 3 Grammar Type --> TypeName | ArrayType | PackedType | EnumType | ProcType | RecordType | SetType | SubRangeTy | ObjType | T_LPAR Type T_RPAR ArrayType --> T_ARRAY OptArrTyp1 T_OF Type OptArrTyp1--> epsilon | OptTypList OptTypList--> OptTypList T_COMMA Type | Type PackedType--> T_BITS ConstExpr T_FOR Type EnumType --> T_LCB OptIdList T_RCB OptIdList --> epsilon | IdList ProcType --> T_PROC Signature RecordType--> T_RECORD OptFields T_END OptFields --> epsilon | FieldList OptSemi FieldList --> FieldList T_SEMI Field | Field Field --> IdList FieldRest FieldRest --> FieldRest1 | FieldRest2 MoreField FieldRest1--> T_ASSIGN ConstExpr

  7. The Modular 3 Grammar FieldRest2--> T_COLON Type MoreField --> epsilon | FieldRest1 SetType --> T_SET T_OF Type SubRangeTy--> T_LSB ConstExpr T_DOTDOT ConstExpr T_RSB ObjType --> OptName OptBrand T_OBJECT OptFields ObjMethods ObjOverRi T_END OptName --> epsilon | ObjType | TypeName OptBrand --> epsilon | T_BRANDED ObjMethods--> epsilon | T_METHODS OptMethods ObjOverRi --> epsilon | T_OVERRIDES OptOverRid OptMethods--> epsilon | MethodList OptSemi MethodList--> MethodList T_SEMI Method | Method Method --> T_IDENT Signature MethodRest MethodRest--> epsilon | T_ASSIGN ConstExpr OptOverRid--> epsilon | OverRiList OptSemi

  8. The Modular 3 Grammar OverRiList--> OverRiList T_SEMI OverRide | OverRide OverRide --> T_IDENT T_ASSIGN ConstExpr ConstExpr --> Expr Expr --> Expr T_OR Expr1 | Expr1 Expr1 --> Expr1 T_AND Expr2 | Expr2 Expr2 --> OptNot Expr3 OptNot --> epsilon | OptNot T_NOT Expr3 --> Expr3 Relop Expr4 | Expr4 Expr4 --> Expr4 Addop Expr5 | Expr5 Expr5 --> Expr5 Mulop Expr6 | Expr6 Expr6 --> OptPM Expr7 OptPM --> epsilon | OptPM PorM PorM --> T_PLUS | T_MINUS Expr7 --> Expr8 OptSelect

  9. The Modular 3 Grammar OptSelect --> epsilon | OptSelect Selector Expr8 --> T_IDENT | T_NUM | T_CHARLIT | T_TEXTLIT | T_LPAR Expr T_RPAR Relop --> T_EQ | T_SHRP | T_LT | T_LE | T_GT | T_GE | T_IN Addop --> T_PLUS | T_MINUS | T_AMP Mulop --> T_TIMES | T_QUOT | T_DIV | T_MOD Selector --> T_CARAT | T_PERIOD T_IDENT | T_LSB ExprSel T_RSB | T_LPAR ActualSel T_RPAR ExprSel --> ExprSel T_COMMA Expr | Expr ActualSel --> epsilon | ActualList ActualList--> ActualList T_COMMA Actual | Actual Actual --> Type | OptId Expr OptId --> epsilon | T_IDENT T_ASSIGN IdList --> IdList T_COMMA T_IDENT | T_IDENT QualId --> T_IDENT OptQual OptQual --> epsilon | T_PERIOD T_IDENT TypeName --> QualId | T_ROOT | T_UNTRACED T_ROOT OptSemi --> epsilon | T_SEMI

More Related