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