blaise_pascal.lst 6.3 KB

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