Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: modula/modula-3/vinju-storm/extracted
Source used for this grammar: Jurgen Vinju, Tijs van der Storm, Modula-3.sdf
, 13 February 2006 – 19 September 2008 [MetaEnv]
Compilation
, Interface
, Module
, GenInf
, GenMod
, Import
, AsImport
, FromImport
, Block
, Decl
, GenFmls
, GenActls
, ImportItem
, ConstDecl
, TypeDecl
, ExceptionDecl
, VariableDecl
, ProcedureHead
, Signature
, Formals
, Formal
, Mode
, Raises
, Expr
, Id
, Relop
, Addop
, Mulop
, Selector
, Elt
, AnyCons
, Constructor
, Ident
, Stmt
, Stmts
, AssignStmt
, CallStmt
, CaseStmt
, ExitStmt
, EvalStmt
, ForStmt
, IfStmt
, LockStmt
, LoopStmt
, RaiseStmt
, RepeatStmt
, ReturnStmt
, TCaseStmt
, TryXptStmt
, TryFinStmt
, WhileStmt
, WithStmt
, Case
, Label
, Handler
, TCase
, Binding
, Actual
, QualId
, IdList
, TypeName
, Type
, TypeLiteral
, ArrayType
, PackedType
, EnumType
, Ancestor
, ObjectType
, ProcedureType
, RecordType
, RefType
, SetType
, SubrangeType
, Brand
, Fields
, Field
, Methods
, Method
, Overrides
, Override
), 0 root (—), 2 top (Compilation
, Ident
), 2 bottom (Literal
, TextLiteral
).Compilation ::= "UNSAFE" Interface Module GenInf GenMod
Interface ::= "INTERFACE" Id ";" Import Decl "END" Id "."
Interface ::= "INTERFACE" Id "=" Id GenActls "END" Id "."
Module ::= "MODULE" Id "EXPORTS" IdList ";" Import Block Id "."
Module ::= "MODULE" Id "EXPORTS" IdList "=" Id GenActls "END" Id "."
GenInf ::= "GENERIC" "INTERFACE" Id GenFmls ";" Import Decl "END" Id "."
GenMod ::= "GENERIC" "MODULE" Id GenFmls ";" Import Block Id "."
Import ::= AsImport
Import ::= FromImport
AsImport ::= "IMPORT" ImportItem "," ImportItem ";"
FromImport ::= "FROM" Id "IMPORT" IdList ";"
Block ::= Decl"BEGIN" Stmts "END"
Decl ::= "CONST" ConstDecl ";"
Decl ::= "TYPE" TypeDecl ";"
Decl ::= "EXCEPTION" ExceptionDecl ";"
Decl ::= "VAR" VariableDecl ";"
Decl ::= ProcedureHead "=" Block Id ";"
Decl ::= "REVEAL" QualId "=""<:" Type ";"
GenFmls ::= "(" IdList ")"
GenActls ::= "(" IdList ")"
ImportItem ::= Id Id "AS" Id
ConstDecl ::= Id ":" Type "=" Expr
TypeDecl ::= Id "=""<:" Type
ExceptionDecl ::= Id "(" Type ")"
VariableDecl ::= IdList ":" Type ":=" Expr
VariableDecl ::=
IdList ":" Type
VariableDecl ::=
IdList ":=" Expr
ProcedureHead ::=
"PROCEDURE" Id Signature
Signature ::= "(" Formals ")" ":" Type "RAISES" Raises
Formals ::= ";" Formal ";"Formal
Formal ::= Mode":" Type ":=" ExprIdList
Formal ::= Mode":" TypeIdList
Formal ::= Mode":=" ExprIdList
Mode ::= "VALUE" "VAR""READONLY"
Raises ::= "{" QualId "," QualId "}" "ANY"
Expr ::=
Expr "OR" Expr
Expr ::=
Expr "AND" Expr
Expr ::=
"NOT" Expr
Id ::=
"NOT"
Expr ::= Expr Relop Expr
Expr ::= Expr Addop Expr
Expr ::= Expr Mulop Expr
Expr ::=
"+" Expr
Expr ::=
"-" Expr
Expr ::= Expr Selector
Expr ::=
Id
Literal
ConstructorExpr ::= "(" Expr ")"
Relop ::= "=" "#""<""<="">"">=""IN"
Addop ::= "+" "-""&"
Mulop ::= "*" "/""DIV""MOD"
Selector ::=
"^"
Selector ::=
"." Id
Selector ::= "[" Expr "," Expr "]"
Selector ::= "(" Actual "," Actual ")"
Elt ::=
Expr ".." Expr
Elt ::= Expr
Elt ::=
Id ":=" Expr
AnyCons ::= "," Elt "," ".."Elt
Constructor ::= Type "{" AnyCons "}"
Expr ::=
"+" Expr
Expr ::=
"-" Expr
Ident ::=
"ABS"
Ident ::=
"ADDRESS"
Ident ::=
"ADR"
Ident ::=
"ADRSIZE"
Ident ::=
"BITSIZE"
Ident ::=
"BOOLEAN"
Ident ::=
"BYTESIZE"
Ident ::=
"CARDINAL"
Ident ::=
"CEILING"
Ident ::=
"CHAR"
Ident ::=
"DEC"
Ident ::=
"DISPOSE"
Ident ::=
"FALSE"
Ident ::=
"FIRST"
Ident ::=
"FLOAT"
Ident ::=
"FLOOR"
Ident ::=
"INC"
Ident ::=
"INTEGER"
Ident ::=
"ISTYPE"
Ident ::=
"LAST"
Ident ::=
"LONGFLOAT"
Ident ::=
"LONGREAL"
Ident ::=
"LOOPHOLE"
Ident ::=
"MAX"
Ident ::=
"MIN"
Ident ::=
"MUTEX"
Ident ::=
"NARROW"
Ident ::=
"NEW"
Ident ::=
"NIL"
Ident ::=
"NULL"
Ident ::=
"NUMBER"
Ident ::=
"ORD"
Ident ::=
"REAL"
Ident ::=
"REFANY"
Ident ::=
"ROUND"
Ident ::=
"SUBARRAY"
Ident ::=
"TEXT"
Ident ::=
"TRUE"
Ident ::=
"TRUNC"
Ident ::=
"TYPECODE"
Ident ::=
"VAL"
Stmt ::= AssignStmt
Stmt ::= Block
Stmt ::= CallStmt
Stmt ::= CaseStmt
Stmt ::= ExitStmt
Stmt ::= EvalStmt
Stmt ::= ForStmt
Stmt ::= IfStmt
Stmt ::= LockStmt
Stmt ::= LoopStmt
Stmt ::= RaiseStmt
Stmt ::= RepeatStmt
Stmt ::= ReturnStmt
Stmt ::= TryFinStmt
Stmt ::= TryXptStmt
Stmt ::= TCaseStmt
Stmt ::= WhileStmt
Stmt ::= WithStmt
Stmts ::= ";" Stmt ";"Stmt
AssignStmt ::=
Expr ":=" Expr
CallStmt ::= Expr "(" Actual "," Actual ")"
CaseStmt ::= "CASE" Expr "OF" "|" Case "|" Case "ELSE" Stmts "END"
ExitStmt ::=
"EXIT"
EvalStmt ::=
"EVAL" Expr
ForStmt ::= "FOR" Id ":=" Expr "TO" Expr "BY" Expr "DO" Stmts "END"
IfStmt ::= "IF" Expr "THEN" Stmts "ELSIF" Expr "THEN" Stmts "ELSE" Stmts "END"
LockStmt ::= "LOCK" Expr "DO" Stmts "END"
LoopStmt ::= "LOOP" Stmts "END"
RaiseStmt ::= "RAISE" QualId "(" Expr ")"
RepeatStmt ::= "REPEAT" Stmts "UNTIL" Expr
ReturnStmt ::= "RETURN" Expr
TCaseStmt ::= "TYPECASE" Expr "OF" "|" TCase "|" TCase "ELSE" Stmts "END"
TryXptStmt ::= "TRY" Stmts "EXCEPT" "|" Handler "|" Handler "ELSE" Stmts "END"
TryFinStmt ::= "TRY" Stmts "FINALLY" Stmts "END"
WhileStmt ::= "WHILE" Expr "DO" Stmts "END"
WithStmt ::= "WITH" Binding "," Binding "DO" Stmts "END"
Case ::= "," Label "=>" StmtsLabel
Label ::= Expr ".." Expr
Handler ::= "," QualId "(" Id ")" "=>" StmtsQualId
TCase ::= "," Type "(" Id ")" "=>" StmtsType
Binding ::=
Id "=" Expr
Actual ::= TypeLiteral ":=" ExprId
QualId ::= Id "." Id
IdList ::= Id "," Id
TypeName ::= "ROOT" "UNTRACED" "ROOT"
Id ::=
"ROOT"
Type ::= TypeLiteral
Type ::= QualId
TypeLiteral ::= ArrayType
TypeLiteral ::= PackedType
TypeLiteral ::= EnumType
TypeLiteral ::= ObjectType
TypeLiteral ::= ProcedureType
TypeLiteral ::= RecordType
TypeLiteral ::= RefType
TypeLiteral ::= SetType
TypeLiteral ::= SubrangeType
TypeLiteral ::= "(" Type ")"
TypeLiteral ::= TypeName
ArrayType ::= "ARRAY" Type "," Type "OF" Type
PackedType ::= "BITS" Expr "FOR" Type
EnumType ::= "{" IdList "}"
Ancestor ::=
TypeName
ObjectType
QualIdObjectType ::= Ancestor"OBJECT" Fields "METHODS" Methods "OVERRIDES" Overrides "END"Brand
ProcedureType ::=
"PROCEDURE" Signature
RecordType ::= "RECORD" Fields "END"
RefType ::= "UNTRACED" Brand "REF" Type
SetType ::= "SET" "OF" Type
SubrangeType ::= "[" Expr ".." Expr "]"
Brand ::= "BRANDED" TextLiteral
Fields ::= ";" Field ";"Field
Field ::= IdList ":" Type ":=" Expr
Field ::=
IdList ":" Type
Field ::=
IdList ":=" Expr
Methods ::= ";" Method ";"Method
Method ::= Id Signature ":=" Expr
Overrides ::= ";" Override ";"Override
Override ::=
Id ":=" Expr