Oberon-2 (programming Language) - Syntax

Syntax

The development of the ALGOL - Pascal - Modula-2 - Oberon - Component Pascal language family is marked by a reduction in the complexity of the language syntax. The entire Oberon-2 language is described (Mössenböck & Wirth, 1993) using only 33 grammatical productions in the extended Backus–Naur form, as shown below.

Module = MODULE ident ";" DeclSeq END ident ".". ImportList = IMPORT ident {"," ident} ";". DeclSeq = { CONST {ConstDecl ";" } | TYPE {TypeDecl ";"} | VAR {VarDecl ";"}} {ProcDecl ";" | ForwardDecl ";"}. ConstDecl = IdentDef "=" ConstExpr. TypeDecl = IdentDef "=" Type. VarDecl = IdentList ":" Type. ProcDecl = PROCEDURE IdentDef ";" DeclSeq END ident. ForwardDecl = PROCEDURE "^" IdentDef . FormalPars = "(" ")" . FPSection = ident {"," ident} ":" Type. Receiver = "(" ident ":" ident ")". Type = Qualident | ARRAY OF Type | RECORD FieldList {";" FieldList} END | POINTER TO Type | PROCEDURE . FieldList = . StatementSeq = Statement {";" Statement}. Statement = [ Designator ":=" Expr | Designator ")"] | IF Expr THEN StatementSeq {ELSIF Expr THEN StatementSeq} END | CASE Expr OF Case {"|" Case} END | WHILE Expr DO StatementSeq END | REPEAT StatementSeq UNTIL Expr | FOR ident ":=" Expr TO Expr DO StatementSeq END | LOOP StatementSeq END | WITH Guard DO StatementSeq {"|" Guard DO StatementSeq} END | EXIT | RETURN ]. Case = . CaseLabels = ConstExpr . Guard = Qualident ":" Qualident. ConstExpr = Expr. Expr = SimpleExpr . SimpleExpr = Term {AddOp Term}. Term = Factor {MulOp Factor}. Factor = Designator ")"] | number | character | string | NIL | Set | "(" Expr ")" | " ~ " Factor. Set = "{" "}". Element = Expr . Relation = "=" | "#" | "<" | "<=" | ">" | ">=" | IN | IS. AddOp = "+" | "-" | OR. MulOp = " * " | "/" | DIV | MOD | "&". Designator = Qualident {"." ident | "" | " ^ " | "(" Qualident ")"}. ExprList = Expr {"," Expr}. IdentList = IdentDef {"," IdentDef}. Qualident = ident. IdentDef = ident .

Read more about this topic:  Oberon-2 (programming Language)