|
@@ -1,280 +0,0 @@
|
|
|
-Coco/R - Compiler-Compiler V1.53
|
|
|
|
|
-Released by Pat Terry 17 September 2002
|
|
|
|
|
-Source file: pascal.atg
|
|
|
|
|
-
|
|
|
|
|
-Grammar Tests:
|
|
|
|
|
-
|
|
|
|
|
-Deletable symbols:
|
|
|
|
|
- Statement
|
|
|
|
|
- StatementSequence
|
|
|
|
|
- ReturnType
|
|
|
|
|
- FieldList
|
|
|
|
|
- VarDeclarations
|
|
|
|
|
- TypeDefinitions
|
|
|
|
|
- ConstDefinitions
|
|
|
|
|
- LabelDeclarations
|
|
|
|
|
- DeclarationPart
|
|
|
|
|
-Undefined nonterminals: -- none --
|
|
|
|
|
-Unreachable nonterminals: -- none --
|
|
|
|
|
-Circular derivations: -- none --
|
|
|
|
|
-Underivable nonterminals: -- none --
|
|
|
|
|
-LL(1) conditions:
|
|
|
|
|
- LL(1) error in CaseList: ";" is the start & successor of a deletable structure
|
|
|
|
|
- LL(1) error in IfStatement: "ELSE" is the start & successor of a deletable structure
|
|
|
|
|
- LL(1) error in VariantSelector: identifier is the start & successor of a deletable structure
|
|
|
|
|
- LL(1) error in VariantPart: ";" is the start & successor of a deletable structure
|
|
|
|
|
- LL(1) error in fixedPart: ";" is the start & successor of a deletable structure
|
|
|
|
|
- LL(1) error in FieldList: ";" is the start & successor of a deletable structure
|
|
|
|
|
- LL(1) error in SimpleType: identifier is the start of several alternatives.
|
|
|
|
|
-
|
|
|
|
|
-Listing:
|
|
|
|
|
-
|
|
|
|
|
- 1 COMPILER Pascal
|
|
|
|
|
- 2 (* J & W Pascal - not Turbo Pascal *)
|
|
|
|
|
- 3 (* This grammar is not LL(1) *)
|
|
|
|
|
- 4
|
|
|
|
|
- 5 IGNORE CASE
|
|
|
|
|
- 6
|
|
|
|
|
- 7 CHARACTERS
|
|
|
|
|
- 8 eol = CHR(13) .
|
|
|
|
|
- 9 letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" .
|
|
|
|
|
- 10 digit = "0123456789".
|
|
|
|
|
- 11 noQuote1 = ANY - "'" - eol .
|
|
|
|
|
- 12
|
|
|
|
|
- 13 IGNORE CHR(9) .. CHR(13)
|
|
|
|
|
- 14
|
|
|
|
|
- 15 COMMENTS FROM "(*" TO "*)"
|
|
|
|
|
- 16 COMMENTS FROM "{" TO "}"
|
|
|
|
|
- 17
|
|
|
|
|
- 18 TOKENS
|
|
|
|
|
- 19 identifier = letter { letter | digit } .
|
|
|
|
|
- 20 integer = digit { digit } | digit { digit } CONTEXT ("..") .
|
|
|
|
|
- 21 real = digit { digit } "." digit { digit }
|
|
|
|
|
- 22 [ "E" ["+" | "-"] digit { digit } ]
|
|
|
|
|
- 23 | digit { digit } "E" ["+" | "-"] digit { digit } .
|
|
|
|
|
- 24 string = "'" { noQuote1 | "''" } "'" .
|
|
|
|
|
- 25
|
|
|
|
|
- 26 PRODUCTIONS
|
|
|
|
|
- 27
|
|
|
|
|
- 28 Pascal = "program" NewIdent [ ExternalFiles ] ";"
|
|
|
|
|
- 29 Block "." .
|
|
|
|
|
- 30
|
|
|
|
|
- 31 ExternalFiles = "(" NewIdentList ")" .
|
|
|
|
|
- 32
|
|
|
|
|
- 33 Block = DeclarationPart StatementPart .
|
|
|
|
|
- 34
|
|
|
|
|
- 35 DeclarationPart = LabelDeclarations ConstDefinitions
|
|
|
|
|
- 36 TypeDefinitions VarDeclarations
|
|
|
|
|
- 37 { ProcDeclarations } .
|
|
|
|
|
- 38
|
|
|
|
|
- 39 (* -------------------------------------------------------------------- *)
|
|
|
|
|
- 40
|
|
|
|
|
- 41 LabelDeclarations = [ "label" Labels ";" ] .
|
|
|
|
|
- 42
|
|
|
|
|
- 43 Labels = Label { "," Label } .
|
|
|
|
|
- 44
|
|
|
|
|
- 45 Label = UnsignedInt .
|
|
|
|
|
- 46
|
|
|
|
|
- 47 (* -------------------------------------------------------------------- *)
|
|
|
|
|
- 48
|
|
|
|
|
- 49 ConstDefinitions = [ "const" ConstDef { ConstDef } ] .
|
|
|
|
|
- 50
|
|
|
|
|
- 51 ConstDef = NewIdent "=" Constant ";" .
|
|
|
|
|
- 52
|
|
|
|
|
- 53 Constant = [ "+" | "-" ] ( UnsignedNumber | ConstIdent ) | String .
|
|
|
|
|
- 54
|
|
|
|
|
- 55 UnsignedNumber = UnsignedInt | UnsignedReal .
|
|
|
|
|
- 56
|
|
|
|
|
- 57 ConstIdent = identifier .
|
|
|
|
|
- 58
|
|
|
|
|
- 59 (* -------------------------------------------------------------------- *)
|
|
|
|
|
- 60
|
|
|
|
|
- 61 TypeDefinitions = [ "type" TypeDef { TypeDef } ] .
|
|
|
|
|
- 62
|
|
|
|
|
- 63 TypeDef = NewIdent "=" Type ";" .
|
|
|
|
|
- 64
|
|
|
|
|
- 65 Type = SimpleType | [ "packed" ] StructType | "^" TypeIdent .
|
|
|
|
|
- 66
|
|
|
|
|
- 67 SimpleType = TypeIdent | EnumerationType | SubrangeType .
|
|
|
|
|
- 68
|
|
|
|
|
- 69 TypeIdent = identifier .
|
|
|
|
|
- 70
|
|
|
|
|
- 71 EnumerationType = "(" NewIdentList ")" .
|
|
|
|
|
- 72
|
|
|
|
|
- 73 SubrangeType = Constant ".." Constant .
|
|
|
|
|
- 74
|
|
|
|
|
- 75 StructType = ArrayType | RecordType | SetType | FileType .
|
|
|
|
|
- 76
|
|
|
|
|
- 77 ArrayType = "array" "[" IndexList "]" "of" Type .
|
|
|
|
|
- 78
|
|
|
|
|
- 79 IndexList = SimpleType { "," SimpleType } .
|
|
|
|
|
- 80
|
|
|
|
|
- 81 RecordType = "record" FieldList "end" .
|
|
|
|
|
- 82
|
|
|
|
|
- 83 SetType = "set" "of" SimpleType .
|
|
|
|
|
- 84
|
|
|
|
|
- 85 FileType = "file" "of" Type .
|
|
|
|
|
- 86
|
|
|
|
|
- 87 FieldList = [ ( fixedPart [ ";" VariantPart ] | VariantPart ) [ ";" ] ] .
|
|
|
|
|
- 88
|
|
|
|
|
- 89 fixedPart = RecordSection { ";" RecordSection } .
|
|
|
|
|
- 90
|
|
|
|
|
- 91 RecordSection = NewIdentList ":" Type .
|
|
|
|
|
- 92
|
|
|
|
|
- 93 VariantPart = "case" VariantSelector "of" Variant { ";" Variant } .
|
|
|
|
|
- 94
|
|
|
|
|
- 95 VariantSelector = [ NewIdent ":" ] TypeIdent .
|
|
|
|
|
- 96
|
|
|
|
|
- 97 Variant = CaseLabelList ":" "(" FieldList ")" .
|
|
|
|
|
- 98
|
|
|
|
|
- 99 (* -------------------------------------------------------------------- *)
|
|
|
|
|
- 100
|
|
|
|
|
- 101 VarDeclarations = [ "var" VarDecl { VarDecl } ] .
|
|
|
|
|
- 102
|
|
|
|
|
- 103 VarDecl = NewIdentList ":" Type ";" .
|
|
|
|
|
- 104
|
|
|
|
|
- 105 (* -------------------------------------------------------------------- *)
|
|
|
|
|
- 106
|
|
|
|
|
- 107 ProcDeclarations = ( ProcHeading | FuncHeading ) ";" Body ";" .
|
|
|
|
|
- 108
|
|
|
|
|
- 109 ProcHeading = "procedure" NewIdent [ FormalParams ] .
|
|
|
|
|
- 110
|
|
|
|
|
- 111 FuncHeading = "function" NewIdent [ FormalParams ] ReturnType .
|
|
|
|
|
- 112
|
|
|
|
|
- 113 ReturnType = [ (* empty if forward referenced *) ":" TypeIdent ] .
|
|
|
|
|
- 114
|
|
|
|
|
- 115 Body = Block | "forward" .
|
|
|
|
|
- 116
|
|
|
|
|
- 117 FormalParams = "(" FormalSection { ";" FormalSection } ")" .
|
|
|
|
|
- 118
|
|
|
|
|
- 119 FormalSection = [ "var" ] ParamGroup | ProcHeading | FuncHeading .
|
|
|
|
|
- 120
|
|
|
|
|
- 121 ParamGroup = NewIdentList ":" ParamType .
|
|
|
|
|
- 122
|
|
|
|
|
- 123 ParamType = TypeIdent
|
|
|
|
|
- 124 | "array" "[" IndexSpecList "]" "of" ParamType
|
|
|
|
|
- 125 | "packed" "array" "[" IndexSpec "]" "of" TypeIdent .
|
|
|
|
|
- 126
|
|
|
|
|
- 127 IndexSpecList = IndexSpec { ";" IndexSpec } .
|
|
|
|
|
- 128
|
|
|
|
|
- 129 IndexSpec = NewIdent ".." NewIdent ":" TypeIdent .
|
|
|
|
|
- 130
|
|
|
|
|
- 131 (* -------------------------------------------------------------------- *)
|
|
|
|
|
- 132
|
|
|
|
|
- 133 StatementPart = CompoundStatement .
|
|
|
|
|
- 134
|
|
|
|
|
- 135 CompoundStatement = "begin" StatementSequence "end" .
|
|
|
|
|
- 136
|
|
|
|
|
- 137 StatementSequence = Statement { ";" Statement } .
|
|
|
|
|
- 138
|
|
|
|
|
- 139 Statement = [ Label ":" ]
|
|
|
|
|
- 140 [ AssignmentOrCall
|
|
|
|
|
- 141 | CompoundStatement
|
|
|
|
|
- 142 | GotoStatement
|
|
|
|
|
- 143 | WhileStatement
|
|
|
|
|
- 144 | RepeatStatement
|
|
|
|
|
- 145 | IfStatement
|
|
|
|
|
- 146 | CaseStatement
|
|
|
|
|
- 147 | ForStatement
|
|
|
|
|
- 148 | WithStatement ] .
|
|
|
|
|
- 149
|
|
|
|
|
- 150 AssignmentOrCall = Designator ( ":=" Expression | [ ActualParams ] ) .
|
|
|
|
|
- 151
|
|
|
|
|
- 152 ActualParams = "(" ActualParameter { "," ActualParameter } ")" .
|
|
|
|
|
- 153
|
|
|
|
|
- 154 ActualParameter = Expression [ FieldWidth (* only in i/o *) ] .
|
|
|
|
|
- 155
|
|
|
|
|
- 156 FieldWidth = ":" IntegerExpression [ ":" IntegerExpression ] .
|
|
|
|
|
- 157
|
|
|
|
|
- 158 GotoStatement = "goto" Label .
|
|
|
|
|
- 159
|
|
|
|
|
- 160 WhileStatement = "while" BooleanExpression "do" Statement .
|
|
|
|
|
- 161
|
|
|
|
|
- 162 RepeatStatement = "repeat" StatementSequence "until" BooleanExpression .
|
|
|
|
|
- 163
|
|
|
|
|
- 164 IfStatement = "if" BooleanExpression "then" Statement
|
|
|
|
|
- 165 [ "else" Statement ] .
|
|
|
|
|
- 166
|
|
|
|
|
- 167 CaseStatement = "case" OrdinalExpression "of" CaseList "end" .
|
|
|
|
|
- 168
|
|
|
|
|
- 169 CaseList = OneCase { ";" OneCase } [ ";" ] .
|
|
|
|
|
- 170
|
|
|
|
|
- 171 OneCase = CaseLabelList ":" Statement .
|
|
|
|
|
- 172
|
|
|
|
|
- 173 CaseLabelList = CaseLabel { "," CaseLabel } .
|
|
|
|
|
- 174
|
|
|
|
|
- 175 CaseLabel = Constant .
|
|
|
|
|
- 176
|
|
|
|
|
- 177 ForStatement = "for" ControlVariable ":=" OrdinalExpression
|
|
|
|
|
- 178 ( "to" | "downto" ) OrdinalExpression "do" Statement .
|
|
|
|
|
- 179
|
|
|
|
|
- 180 ControlVariable = identifier .
|
|
|
|
|
- 181
|
|
|
|
|
- 182 WithStatement = "with" RecVarList "do" Statement .
|
|
|
|
|
- 183
|
|
|
|
|
- 184 RecVarList = Designator { "," Designator } .
|
|
|
|
|
- 185
|
|
|
|
|
- 186 (* -------------------------------------------------------------------- *)
|
|
|
|
|
- 187
|
|
|
|
|
- 188 IntegerExpression = Expression .
|
|
|
|
|
- 189
|
|
|
|
|
- 190 BooleanExpression = Expression .
|
|
|
|
|
- 191
|
|
|
|
|
- 192 OrdinalExpression = Expression .
|
|
|
|
|
- 193
|
|
|
|
|
- 194 Expression = SimpleExpression [ RelOp SimpleExpression ] .
|
|
|
|
|
- 195
|
|
|
|
|
- 196 RelOp = "=" | "<" | ">" | "<=" | ">=" | "<>" | "in" .
|
|
|
|
|
- 197
|
|
|
|
|
- 198 SimpleExpression = ( "+" Term | "-" Term | Term ) { AddOp Term } .
|
|
|
|
|
- 199
|
|
|
|
|
- 200 AddOp = "+" | "-" | "or" .
|
|
|
|
|
- 201
|
|
|
|
|
- 202 Term = Factor { MulOp Factor } .
|
|
|
|
|
- 203
|
|
|
|
|
- 204 MulOp = "*" | "/" | "div" | "mod" | "and" .
|
|
|
|
|
- 205
|
|
|
|
|
- 206 Factor = Designator [ ActualParams ]
|
|
|
|
|
- 207 | UnsignedLiteral
|
|
|
|
|
- 208 | SetConstructor
|
|
|
|
|
- 209 | "(" Expression ")"
|
|
|
|
|
- 210 | "not" Factor .
|
|
|
|
|
- 211
|
|
|
|
|
- 212 Designator = identifier { "." identifier | "[" ExpList "]" | "^" } .
|
|
|
|
|
- 213
|
|
|
|
|
- 214 ExpList = Expression { "," Expression } .
|
|
|
|
|
- 215
|
|
|
|
|
- 216 UnsignedLiteral = UnsignedNumber | "nil" | String .
|
|
|
|
|
- 217
|
|
|
|
|
- 218 SetConstructor = "[" Member { "," Member } "]" .
|
|
|
|
|
- 219
|
|
|
|
|
- 220 Member = Expression [ ".." Expression ] .
|
|
|
|
|
- 221
|
|
|
|
|
- 222 (* -------------------------------------------------------------------- *)
|
|
|
|
|
- 223
|
|
|
|
|
- 224 NewIdentList = NewIdent { "," NewIdent } .
|
|
|
|
|
- 225
|
|
|
|
|
- 226 NewIdent = identifier .
|
|
|
|
|
- 227
|
|
|
|
|
- 228 UnsignedInt = integer .
|
|
|
|
|
- 229
|
|
|
|
|
- 230 UnsignedReal = real .
|
|
|
|
|
- 231
|
|
|
|
|
- 232 String = string .
|
|
|
|
|
- 233
|
|
|
|
|
- 234 END Pascal.
|
|
|
|
|
-
|
|
|
|
|
- 0 errors
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-Statistics:
|
|
|
|
|
-
|
|
|
|
|
- nr of terminals: 63 (limit 400)
|
|
|
|
|
- nr of non-terminals: 85 (limit 210)
|
|
|
|
|
- nr of pragmas: 0 (limit 437)
|
|
|
|
|
- nr of symbolnodes: 148 (limit 500)
|
|
|
|
|
- nr of graphnodes: 434 (limit 1500)
|
|
|
|
|
- nr of conditionsets: 5 (limit 100)
|
|
|
|
|
- nr of charactersets: 6 (limit 250)
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|