OberonSyntax.Text 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9".
  2. hexDigit = digit | "A" | "B" | "C" | "D" | "E" | "F".
  3. ident = letter {letter | digit}.
  4. qualident = [ident "."] ident.
  5. identdef = ident ["*"].
  6. integer = digit {digit} | digit {hexDigit} "H".
  7. real = digit {digit} "." {digit} [ScaleFactor].
  8. ScaleFactor = ("E" |"D") ["+" | "-"] digit {digit}.
  9. number = integer | real.
  10. string = "'" {character} "'" | digit {hexdigit} "X".
  11. ConstDeclaration = identdef "=" ConstExpression.
  12. ConstExpression = expression.
  13. TypeDeclaration = identdef "=" StrucType.
  14. StrucType = ArrayType | RecordType | PointerType | ProcedureType.
  15. type = qualident | StrucType.
  16. ArrayType = "ARRAY" length {"," length} "OF" type.
  17. length = ConstExpression.
  18. RecordType = "RECORD" ["(" BaseType ")"] [FieldListSequence] "END".
  19. BaseType = qualident.
  20. FieldListSequence = FieldList {";" FieldList}.
  21. FieldList = IdentList ":" type.
  22. IdentList = identdef {"," identdef}.
  23. PointerType = "POINTER" "TO" type.
  24. ProcedureType = "PROCEDURE" [FormalParameters].
  25. VariableDeclaration = IdentList ":" type.
  26. expression = SimpleExpression [relation SimpleExpression].
  27. relation = "=" | "#" | "<" | "<=" | ">" | ">=" | "IN" | "IS".
  28. SimpleExpression = ["+" | "-"] term {AddOperator term}.
  29. AddOperator = "+" | "-" | "OR".
  30. term = factor {MulOperator factor}.
  31. MulOperator = "*" | "/" | "DIV" | "MOD" | "&".
  32. factor = number | string | "NIL" | "TRUE" | "FALSE" |
  33. set | designator [ActualParameters] | "(" expression ")" | "~" factor.
  34. designator = qualident {selector}.
  35. selector = "." ident | "[" ExpList "]" | "^" | "(" qualident ")".
  36. set = "{" [element {"," element}] "}".
  37. element = expression [".." expression].
  38. ExpList = expression {"," expression}.
  39. ActualParameters = "(" [ExpList] ")" .
  40. statement = [assignment | ProcedureCall | IfStatement | CaseStatement |
  41. WhileStatement | RepeatStatement | ForStatement].
  42. assignment = designator ":=" expression.
  43. ProcedureCall = designator [ActualParameters].
  44. StatementSequence = statement {";" statement}.
  45. IfStatement = "IF" expression "THEN" StatementSequence
  46. {"ELSIF" expression "THEN" StatementSequence}
  47. ["ELSE" StatementSequence] "END".
  48. CaseStatement = "CASE" expression "OF" case {"|" case} "END".
  49. Case = CaseLabelList ":" StatementSequence.
  50. CaseLabelList = LabelRange {"," LabelRange}.
  51. LabelRange = label [".." label].
  52. label = integer | string | ident.
  53. WhileStatement = "WHILE" expression "DO" StatementSequence
  54. {"ELSIF" expression "DO" StatementSequence} "END".
  55. RepeatStatement = "REPEAT" StatementSequence "UNTIL" expression.
  56. ForStatement = "FOR" ident ":=" expression "TO" expression ["BY" ConstExpression]
  57. "DO" StatementSequence "END".
  58. ProcedureDeclaration = ProcedureHeading ";" ProcedureBody ident.
  59. ProcedureHeading = "PROCEDURE" identdef [FormalParameters].
  60. ProcedureBody = DeclarationSequence ["BEGIN" StatementSequence]
  61. ["RETURN" expression] "END".
  62. DeclarationSequence = ["CONST" {ConstDeclaration ";"}]
  63. ["TYPE" {TypeDeclaration ";"}]
  64. ["VAR" {VariableDeclaration ";"}]
  65. {ProcedureDeclaration ";"}.
  66. FormalParameters = "(" [FPSection {";" FPSection}] ")" [":" qualident].
  67. FPSection = ["CONST" | "VAR"] ident {"," ident} ":" FormalType.
  68. FormalType = ["ARRAY" "OF"] qualident.
  69. module = "MODULE" ident ";" [ImportList] DeclarationSequence
  70. ["BEGIN" StatementSequence] "END" ident "." .
  71. ImportList = "IMPORT" import {"," import} ";".
  72. import = ident [":=" ident].