
Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: modula/modula-3/dagenais-cordy/extracted
Source used for this grammar: Michel Dagenais, James R. Cordy, Modula-3 Grammar for TXL-3, Adapted to TXL 10. Rev 21.3.01, March 2001 [TGZ]
program, Interface, IInterface, Module, IModule, GInterface, GModule, Exports, Import, AsImport, ComaImportItem, FromImport, Block, Decl, EqualBlock, GenFmls, GenActls, ImportItem, AsId, ConstDecl, ColonType, TypeDecl, RevealDecl, ExceptionDecl, ParenthesizedType, VariableDecl, EqualExpr, ProcedureHead, Signature, Raises, Formals, SemicolonFormal, Formal, EqualConstExpr, Mode, RaisesList, Stmts, OptStmts, SemiColonStmt, Stmt, AssignStmt, CallStmt, CaseStmt, VerticalCase, ElseStmts, ExitStmt, EvalStmt, ForStmt, ByExpr, IfStmt, Elsif, LockStmt, LoopStmt, RaiseStmt, ParenthesizedExpr, RepeatStmt, ReturnStmt, TypecaseStmt, VerticalTCase, TryStmt, ExceptOrFinally, VerticalHandler, WhileStmt, WithStmt, Case, Labels, DotDotConstExpr, Handler, ParenthesizedId, TCase, Binding, Actual, Type, ArrayType, PackedType, EnumerationType, ObjectType, ObjectOrTypeName, TheMethods, TheOverrides, ProcedureType, RecordType, RefType, SetType, SubrangeType, Brand, Fields, FieldList, SemiColonField, Field, Methods, MethodList, SemiColonMethod, Method, Overrides, OverrideList, SemiColonOverride, Override, ConstExpr, Expr, OrE1, E1, AndE2, E2, E3, RelOpE4, E4, AddOpE5, E5, MulOpE6, E6, E7, E8, SignOp, RelOp, AddOp, MulOp, Selector, ComaExpr, Constructor, AnyCons, SetCons, SetElt, DotDotExpr, RecordCons, RecordElt, ArrayCons, ComaDotDot, IdList, QualId, DotId, TypeName), 1 root (program), 0 top (—), 7 bottom (NL 55, EX 12, Number, stringlit, IN 12, charlit, id 34).program ::= Interface Module GInterface GModule IInterface IModule
Interface ::= "UNSAFE" "INTERFACE" id ";" NL NL Import Decl NL "END" id "." NL
IInterface ::= "UNSAFE" "INTERFACE" id "=" id GenActls "END" id "." NL
Module ::= "UNSAFE" "MODULE" id Exports ";" NL NL Import Block id "." NL
IModule ::= "UNSAFE" "MODULE" id Exports "=" id GenActls "END" id "." NL
GInterface ::= "GENERIC" "INTERFACE" id GenFmls ";" Import Decl NL "END" id "." NL
GModule ::= "GENERIC" "MODULE" id GenFmls ";" NL NL Import Block id "." NL
Exports ::=
"EXPORTS" IdListImport ::= AsImport FromImport NL NL
AsImport ::= "IMPORT" ImportItem ComaImportItem ";" NL NL
ComaImportItem ::=
"," ImportItemFromImport ::= "FROM" id "IMPORT" IdList ";" NL NL
Block ::= Decl "BEGIN" Stmts "END"
Decl ::= ProcedureHead EqualBlock ";" NL NL "VAR" IN NL VariableDecl EX "TYPE" IN NL TypeDecl EX NL "CONST" IN NL ConstDecl EX NL "EXCEPTION" IN NL ExceptionDecl EX NL "REVEAL" IN NL RevealDecl EX NL
EqualBlock ::= "=" IN NL Block id EX
GenFmls ::= "(" IdList ")"
GenActls ::= "(" IdList ")"
ImportItem ::=
id AsIdAsId ::=
"AS" idConstDecl ::= id ColonType "=" ConstExpr ";" NL
ColonType ::=
":" TypeTypeDecl ::= id "=" Type ";" NL id "<:" Type ";" NL
RevealDecl ::= QualId "=" Type ";" NL QualId "<:" Type ";" NL
ExceptionDecl ::= id ParenthesizedType ";" NL
ParenthesizedType ::= "(" Type ")"
VariableDecl ::= IdList ColonType EqualExpr ";" NL
EqualExpr ::=
":=" ExprProcedureHead ::=
"PROCEDURE" id SignatureSignature ::= "(" Formals ")" ColonType Raises
Raises ::=
"RAISES" RaisesListFormals ::= Formal SemicolonFormal ";"
SemicolonFormal ::=
";" FormalFormal ::= Mode IdList ColonType EqualConstExpr
EqualConstExpr ::=
":=" ConstExprMode ::= "VALUE" "VAR" "READONLY"
RaisesList ::= "{" QualId "," "}" "ANY"
Stmts ::= IN NL OptStmts EX
OptStmts ::= Stmt SemiColonStmt ";" NL
SemiColonStmt ::=
";" NL StmtStmt ::= IfStmt ForStmt ReturnStmt WhileStmt AssignStmt CallStmt Block CaseStmt ExitStmt EvalStmt LockStmt LoopStmt RaiseStmt RepeatStmt TypecaseStmt TryStmt WithStmt
AssignStmt ::=
Expr ":=" ExprCallStmt ::= Expr "(" Actual "," ")"
CaseStmt ::= "CASE" Expr "OF" NL Case VerticalCase ElseStmts "END"
VerticalCase ::=
"|" CaseElseStmts ::=
"ELSE" StmtsExitStmt ::=
"EXIT"EvalStmt ::=
"EVAL" ExprForStmt ::= "FOR" id ":=" Expr "TO" Expr ByExpr "DO" Stmts "END"
ByExpr ::=
"BY" ExprIfStmt ::= "IF" Expr "THEN" Stmts Elsif ElseStmts "END"
Elsif ::= "ELSIF" Expr "THEN" Stmts
LockStmt ::= "LOCK" Expr "DO" Stmts "END"
LoopStmt ::= "LOOP" Stmts "END"
RaiseStmt ::= "RAISE" QualId ParenthesizedExpr
ParenthesizedExpr ::= "(" Expr ")"
RepeatStmt ::= "REPEAT" Stmts "UNTIL" Expr
ReturnStmt ::= "RETURN" Expr
TypecaseStmt ::= "TYPECASE" Expr "OF" NL TCase VerticalTCase ElseStmts "END"
VerticalTCase ::=
"|" TCaseTryStmt ::= "TRY" Stmts ExceptOrFinally "END"
ExceptOrFinally ::= "EXCEPT" NL Handler VerticalHandler ElseStmts "FINALLY" Stmts
VerticalHandler ::=
"|" HandlerWhileStmt ::= "WHILE" Expr "DO" Stmts "END"
WithStmt ::= "WITH" Binding "DO" Stmts "END"
Case ::= Labels "," "=>" Stmts
Labels ::=
ConstExpr DotDotConstExprDotDotConstExpr ::=
".." ConstExprHandler ::= QualId "," ParenthesizedId "=>" Stmts
ParenthesizedId ::= "(" id ")"
TCase ::= Type "," ParenthesizedId "=>" Stmts
Binding ::=
id "=" ExprActual ::=
Type
Expr
id ":=" ExprType ::= TypeName ArrayType EnumerationType RecordType ObjectType ProcedureType RefType SetType SubrangeType PackedType "(" Type ")"
ArrayType ::= "ARRAY" Type "," "OF" Type
PackedType ::= "BITS" ConstExpr "FOR" Type
EnumerationType ::= "{" IdList "}"
ObjectType ::= ObjectOrTypeName Brand "OBJECT" IN NL Fields TheMethods TheOverrides "END" EX
ObjectOrTypeName ::= TypeName ObjectType
TheMethods ::=
"METHODS" NL MethodsTheOverrides ::=
"OVERRIDES" NL OverridesProcedureType ::=
"PROCEDURE" SignatureRecordType ::= "RECORD" IN NL Fields "END" EX
RefType ::= "UNTRACED" Brand "REF" Type
SetType ::= "SET" "OF" Type
SubrangeType ::= "[" ConstExpr ".." ConstExpr "]"
Brand ::= "BRANDED" ConstExpr
Fields ::=
FieldListFieldList ::= IN Field SemiColonField ";" EX NL
SemiColonField ::=
";" NL FieldField ::= IdList ColonType EqualConstExpr
Methods ::=
MethodListMethodList ::= IN Method SemiColonMethod ";" EX NL
SemiColonMethod ::=
";" NL MethodMethod ::=
id Signature EqualConstExprOverrides ::=
OverrideListOverrideList ::= IN Override SemiColonOverride ";" EX NL
SemiColonOverride ::=
";" NL OverrideOverride ::=
id ":=" ConstExprConstExpr ::= Expr
Expr ::=
E1 OrE1OrE1 ::=
"OR" E1E1 ::=
E2 AndE2AndE2 ::=
"AND" E2E2 ::= "NOT" E3
E3 ::=
E4 RelOpE4RelOpE4 ::= RelOp E4
E4 ::=
E5 AddOpE5AddOpE5 ::= AddOp E5
E5 ::=
E6 MulOpE6MulOpE6 ::= MulOp E6
E6 ::=
SignOp E7E7 ::=
E8 SelectorE8 ::= id Number charlit stringlit "(" Expr ")" Constructor
SignOp ::= "+" "-"
RelOp ::= "=" "#" "<" "<=" ">" ">=" "IN"
AddOp ::= "+" "-" "&"
MulOp ::= "*" "/" "DIV" "MOD"
Selector ::= "." id "[" Expr ComaExpr "]" "(" Actual "," ")" "^"
ComaExpr ::=
"," ExprConstructor ::= Type "{" AnyCons "}"
AnyCons ::= SetCons RecordCons ArrayCons
SetCons ::= SetElt ","
SetElt ::=
Expr DotDotExprDotDotExpr ::=
".." ExprRecordCons ::= RecordElt ","
RecordElt ::=
Expr EqualExprArrayCons ::= Expr "," ComaDotDot
ComaDotDot ::= "," ".."
IdList ::= id ","
QualId ::=
id DotIdDotId ::=
"." idTypeName ::= QualId "ROOT" "UNTRACED" "ROOT"