[ModulaWare logo 2.5KB]

LALR-Syntax of the programming language Oberon-2

by Taylor Hutt

Goal -> Module <eof>
Module -> MODULE <ident> ';' [ImportList] DeclSequence [BEGIN StatementSequence] END {ModuleName} '.'
ImportList -> IMPORT Import\';'... ';'
Import -> <ident> [':=' <ident>]
DeclSequence -> [CONST [ConstantDecl ';']... | TYPE [TypeDecl ';']... | VAR [VariableDecl ';']...]... [ProcedureDecl ';' | ForwardDecl ';']...
ProcedureDecl -> ProcedureHeading ';' ProcedureBody <ident> ';'
ProcedureHeading -> PROCEDURE ['*'] IdentDef [FormalParameters]
ProcedureBody -> DeclSequence [BEGIN StatementSequence] END
ForwardDecl -> PROCEDURE '^' IdentDef [FormalParameters]
FormalParameters -> '(' [FPSection [';' FPSection]...] ')' [':' QualIdent]
FPSection -> [VAR] <ident>\','... ':' FormalType
FormalType -> [ARRAY OF]... (QualIdent | ProcedureType)
IdentDef -> <ident> ['*']
QualIdent -> [{ModuleName} '.'] <ident>
ConstantDecl -> IdentDef '=' ConstantExpression
ConstantExpression -> Expression
TypeDecl -> IdentDef '=' Type
Type -> QualIdent -> ArrayType -> RecordType -> PointerType -> ProcedureType
ArrayType -> ARRAY Length\','... OF Type
Length -> ConstantExpression
RecordType -> RECORD ['(' BaseType ')'] FieldList\';'... END
BaseType -> QualIdent
FieldList -> [IdentList ':' Type]
IdentList -> IdentDef\','...
PointerType -> POINTER TO Type
ProcedureType -> PROCEDURE [FormalParameters]
VariableDecl -> IdentList ':' Type
Designator -> QualIdent [ '.' <ident>... | '[' ExpList ']' | '(' QualIdent ')' | '^']...
ExpList -> Expression\','...
Expression -> SimpleExpression [Relation SimpleExpression]...
Relation -> ('=' | '#' | '<' | '<=' | '>' | '>=' | IN | IS)
SimpleExpression -> ['+' | '-'] Term [AddOperator Term]...
AddOperator -> ('+' | '-' | OR)
Term -> Factor [MulOperator Factor]...
MulOperator -> ('*' | '/' | DIV | MOD | '&')
Factor -> <number> -> <charconst> -> <string> -> NIL -> Set -> Designator [ActualParameters] -> '(' Expression ')' -> ' ' Factor
Set -> '{' Element\','... '}'
Element -> Expression ['..' Expression]
ActualParameters -> '(' [ExpList] ')'
StatementSequence -> Statement\';'...
Statement -> [ Assignment | ProcedureCall | IfStatement | CaseStatement | WhileStatement | RepeatStatement | LoopStatement | WithStatement | EXIT | RETURN [Expression]]
Assignment -> Designator ':=' Expression
ProcedureCall -> Designator [ActualParameters]
IfStatement -> IF Expression THEN StatementSequence [ELSIF Expression THEN StatementSequence] [ELSE StatementSequence] END
CaseStatement -> CASE Expression OF Case\'|'... [ELSE StatementSequence] END
Case -> [CaseLabelList ':' StatementSequence]
CaseLabelList -> CaseLabels\','...
CaseLabels -> ConstantExpression ['..' ConstantExpression]
WhileStatement -> WHILE Expression DO StatementSequence END
RepeatStatement -> REPEAT StatementSequence UNTIL Expression
LoopStatement -> LOOP StatementSequence END
WithStatement -> WITH QualIdent ':' QualIdent DO StatementSequence END


Home Site_index Legal OpenVMS_compiler Alpha_Oberon_System ModulaTor Bibliography Oberon[-2]_links Modula-2_links


© (1998) ModulaWare. Last update: 19-Oct-1998
Webdesign by www.otolo.com/webworx