Coco/R - Compiler-Compiler V1.53 Released by Pat Terry 17 September 2002 Source file: blaise_pascal.atg Grammar Tests: Deletable symbols: DeclarationSequence case StatementSequence statement FieldList FieldListSequence Undefined nonterminals: -- none -- Unreachable nonterminals: -- none -- Circular derivations: -- none -- Underivable nonterminals: -- none -- LL(1) conditions: LL(1) error in DeclarationSequence: "PROCEDURE" is the start of several alternatives. LL(1) error in statement: ident is the start of several alternatives. LL(1) error in designator: "(" is the start & successor of a deletable structure LL(1) error in qualident: ident is the start & successor of a deletable structure Listing: 1 (* Tags: BLAISE, BLAISEPASCALE, BLA *) 2 (* Tags: ORIGINAL, OISOberon, Classic, ETHOberon *) 3 COMPILER Oberon 4 (* A grammar for Oberon *) 5 6 CHARACTERS 7 eol = CHR(13) . 8 letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" . 9 digit = "0123456789" . 10 hexDigit = digit + "ABCDEF" . 11 noQuote = ANY - '"' - eol . 12 13 IGNORE CHR(9) .. CHR(13) 14 15 COMMENTS 16 FROM "(*" TO "*)" NESTED 17 18 TOKENS 19 ident = letter { letter | digit } . 20 integer = digit { digit } | digit { hexDigit } "H" . 21 real = digit { digit } "." { digit } 22 [ ("E" | "D") [ "+" | "-" ] digit { digit } ] . 23 CharConstant = digit { hexDigit } "X" . 24 string = '"' { noQuote } '"' . 25 26 PRODUCTIONS 27 Oberon = module . 28 number = integer | real . 29 identdef = ident [ "*" ] . 30 qualident = [ ident "." ] ident . 31 ConstantDeclaration = identdef "=" ConstExpression . 32 ConstExpression = expression . 33 TypeDeclaration = identdef "=" type . 34 type = qualident | ArrayType | RecordType | PointerType | ProcedureType . 35 ArrayType = "ARRAY" length { "," length } "OF" type . 36 length = ConstExpression . 37 RecordType = "RECORD" [ "(" BaseType ")" ] FieldListSequence "END" . 38 BaseType = qualident . 39 FieldListSequence = FieldList { ";" FieldList } . 40 FieldList = [ IdentList ":" type ] . 41 IdentList = identdef { "," identdef } . 42 PointerType = "POINTER" "TO" type . 43 ProcedureType = "PROCEDURE" [ FormalParameters ] . 44 VariableDeclaration = IdentList ":" type . 45 designator = qualident { "." ident | "[" ExpList "]" | "(" qualident ")" | "^" } . 46 ExpList = expression { "," expression } . 47 expression = SimpleExpression [ relation SimpleExpression ] . 48 relation = "=" | "#" | "<" | "<=" | ">" | ">=" | "IN" | "IS" . 49 SimpleExpression = [ "+" | "-" ] term { AddOperator term } . 50 AddOperator = "+" | "-" | "OR" . 51 term = factor { MulOperator factor } . 52 MulOperator = "*" | "/" | "DIV" | "MOD" | "&" . 53 factor = number | CharConstant | string | "NIL" | set 54 | designator [ ActualParameters ] 55 | "(" expression ")" | "~" factor . 56 set = "{" [ element { "," element } ] "}" . 57 element = expression [ ".." expression ] . 58 ActualParameters = "(" [ ExpList ] ")" . 59 statement = [ assignment | ProcedureCall | IfStatement | 60 CaseStatement | WhileStatement | RepeatStatement | 61 LoopStatement | WithStatement | "EXIT" | 62 "RETURN" [ expression ] ] . 63 assignment = designator ":=" expression . 64 ProcedureCall = designator [ ActualParameters ] . 65 StatementSequence = statement { ";" statement } . 66 IfStatement = "IF" expression "THEN" StatementSequence 67 { "ELSIF" expression "THEN" StatementSequence } 68 [ "ELSE" StatementSequence ] "END" . 69 CaseStatement = "CASE" expression "OF" case { "|" case } 70 [ "ELSE" StatementSequence ] "END" . 71 case = [ CaseLabelList ":" StatementSequence ] . 72 CaseLabelList = CaseLabels { "," CaseLabels } . 73 CaseLabels = ConstExpression [ ".." ConstExpression ] . 74 WhileStatement = "WHILE" expression "DO" StatementSequence "END" . 75 RepeatStatement = "REPEAT" StatementSequence "UNTIL" expression . 76 LoopStatement = "LOOP" StatementSequence "END" . 77 WithStatement = "WITH" qualident ":" qualident "DO" StatementSequence "END" . 78 ProcedureDeclaration = ProcedureHeading ";" ProcedureBody ident . 79 ProcedureHeading = "PROCEDURE" [ "*" ] identdef [ FormalParameters ] . 80 ProcedureBody = DeclarationSequence [ "BEGIN" StatementSequence ] "END" . 81 ForwardDeclaration = "PROCEDURE" "^" ident [ "*" ] [ FormalParameters ] . 82 DeclarationSequence = { "CONST" { ConstantDeclaration ";" } 83 | "TYPE" { TypeDeclaration ";" } 84 | "VAR" { VariableDeclaration ";" } } 85 { ProcedureDeclaration ";" 86 | ForwardDeclaration ";" } . 87 FormalParameters = "(" [ FPSection { ";" FPSection } ] ")" [ ":" qualident ] . 88 FPSection = [ "VAR" ] ident { "," ident } ":" FormalType . 89 FormalType = { "ARRAY" "OF" } (qualident | ProcedureType) . 90 ImportList = "IMPORT" import { "," import } ";" . 91 import = ident [ ":=" ident ] . 92 module = "MODULE" ident ";" 93 [ ImportList ] DeclarationSequence 94 [ "BEGIN" StatementSequence ] "END" ident "." . 95 END Oberon. 0 errors Statistics: nr of terminals: 65 (limit 400) nr of non-terminals: 54 (limit 210) nr of pragmas: 0 (limit 435) nr of symbolnodes: 119 (limit 500) nr of graphnodes: 352 (limit 1500) nr of conditionsets: 4 (limit 100) nr of charactersets: 9 (limit 250)