Оберон
Описание подготовлено Н. Шумиловой
Letter = "A"| "B"| "C"| "D"| "E"| "F"| "G"| "H"| "I"| "J"| "K"| "L"| "M"|
"N"| "O"| "P"| "Q"| "R"| "S"| "T"| "U"| "V"| "W"| "X"| "Y"| "Z"| "a"| "b"|
"c"| "d"| "e"| "f"| "g"| "h"| "i"| "j"| "k"| "l"| "m"| "n"| "o"| "p"| "q"|
"r"| "s"| "t"| "u"| "v"| "w"| "x"| "y"| "z".
Ident = Letter {Letter | Digit}.
Number = Integer | Real.
Integer = Digit {Digit} | Digit {HexDigit} "H".
Real = Digit {Digit} "." {Digit} [ScaleFactor].
ScaleFactor = ("E" | "D") ["+" | "-"] Digit {Digit}.
HexDigit = Digit | "A" | "B" | "C" | "D" | "E" | "F".
Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9".
CharConstant = '"' character '"' | Digit {HexDigit} "X".
String = '"' {character} '"' .
Identdef = Ident ["*"].
Qualident = [Ident "."] Ident.
ConstantDeclaration = Identdef "=" ConstExpression.
ConstExpression = Expression.
TypeDeclaration = Identdef "=" Type.
Type = Qualident | ArrayType | RecordType | PointerType | ProcedureType.
ArrayType = ARRAY Length {"," Length} OF Type.
Length = ConstExpression.
RecordType = RECORD ["(" BaseType ")"] FieldListSequence END.
BaseType = Qualident.
FieldListSequence = FieldList {";" FieldList}.
FieldList = [IdentList ":" Type].
IdentList = Identdef {"," Identdef}.
PointerType = POINTER TO Type.
ProcedureType = PROCEDURE [FormalParameters].
VariableDeclaration = IdentList ":" Type.
Designator = Qualident {"." Ident | "[" ExpList "]" | "(" Qualident ")" | "^" }.
ExpList = Expression {"," Expression}.
Expression = SimpleExpression [Relation SimpleExpression].
Relation = "=" | "#" | "<" | "<=" | ">" | ">=" | IN | IS.
SimpleExpression = ["+"|"-"] Term {AddOperator Term}.
AddOperator = "+" | "-" | OR .
Term = Factor {MulOperator Factor}.
MulOperator = "*" | "/" | DIV | MOD | "&" .
Factor = Number | CharConstant | String | NIL | Set |
Designator [ActualParameters] | "(" Expression ")" | "~" Factor.
Set = "{" [Element {"," Element}] "}".
Element = Expression [".." Expression].
ActualParameters = "(" [ExpList] ")" .
Statement = [Assignment | ProcedureCall |
IfStatement | CaseStatement | WhileStatement | RepeatStatement |
LoopStatement | WithStatement | EXIT | RETURN [Expression] ].
Assignment = Designator ":=" Expression.
ProcedureCall = Designator [ActualParameters].
StatementSequence = Statement {";" Statement}.
IfStatement = IF Expression THEN StatementSequence
{ELSIF Expression THEN StatementSequence}
[ELSE StatementSequence] END.
CaseStatement = CASE Expression OF Case {"|" Case}
[ELSE StatementSequence] END.
Case = [CaseLabelList ":" StatementSequence].
CaseLabelList = CaseLabels {"," CaseLabels}.
CaseLabels = ConstExpression [".." ConstExpression].
WhileStatement = WHILE Expression DO StatementSequence END.
RepeatStatement = REPEAT StatementSequence UNTIL Expression.
LoopStatement = LOOP StatementSequence END.
WithStatement = WITH Qualident ":" Qualident DO StatementSequence END .
ProcedureDeclaration = ProcedureHeading ";" ProcedureBody Ident.
ProcedureHeading = PROCEDURE ["*"] Identdef [FormalParameters].
ProcedureBody = DeclarationSequence [BEGIN StatementSequence] END.
ForwardDeclaration = PROCEDURE "^" Ident ["*"] [FormalParameters].
DeclarationSequence = {CONST {ConstantDeclaration ";"} |
TYPE {TypeDeclaration ";"} | VAR {VariableDeclaration ";"}}
{ProcedureDeclaration ";" | ForwardDeclaration ";"}.
FormalParameters = "(" [FPSection {";" FPSection}] ")" [":" Qualident].
FPSection = [VAR] Ident {"," Ident} ":" FormalType.
FormalType = {ARRAY OF} (Qualident | ProcedureType).
ImportList = IMPORT Import {"," Import} ";" .
Import = Ident [":=" Ident].
Module = MODULE Ident ";" [ImportList] DeclarationSequence
[BEGIN StatementSequence] END Ident "." .