|
| Previous: 5.1 Syntax Description Language | TOC | Index | Back | Next: 6. Quick Reference |
Program:
DeclList CompoundStmt
;
DeclList:
Declaration
| Declaration DeclList
;
Declaration:
'VAR' VarDeclList ';'
| 'CONST' ConstDeclList ';'
| 'DECL' ProtoDeclList ';'
| 'STRUCT' Symbol '=' StructMemList ';'
| ProcDecl
| ClassDecl
| 'PUBLIC' ClassDecl
| 'OBJECT' ObjDeclList ';'
| 'MODULE' Symbol '(' ModList ')' ';'
| 'MODULE' Symbol '(' ')' ';'
;
VarDeclList:
VarDecl
| VarDeclList ',' VarDecl
;
VarDecl:
Symbol
| Symbol '[' ConstValue ']'
| Symbol '::' ConstValue
;
ConstDeclList:
Symbol '=' ConstValue
| Symbol '=' ConstValue ',' ConstDeclList
;
ModList:
Symbol
| Symbol ',' ModList
;
StructMemList:
Symbol
| Symbol ',' StructMemList
;
ClassDecl:
'CLASS' Symbol '(' ModList ')' InstDeclList 'END'
| 'CLASS' Symbol '(' ')' InstDeclList 'END'
| 'ICLASS' Symbol '(' String ')' IClassInstDeclList 'END'
;
IClassInstDeclList:
IClassInstDecl
| IClassInstDecl IClassInstDeclList
;
InstDeclList:
InstDecl
| InstDecl InstDeclList
;
IClassInstDecl:
InterfaceDecl
| InstDecl
;
InstDecl:
'VAR' VarDeclList ';'
| 'CONST' ConstDeclList ';'
| 'DECL' ProtoDeclList ';'
| 'STRUCT' Symbol '=' StructMemList ';'
| ProcDecl
| 'OBJECT' ObjDeclList ';'
| 'PUBLIC' ProcDecl
| 'PUBLIC' 'CONST' ConstDeclList ';'
| 'PUBLIC' 'STRUCT' Symbol '=' StructMemList ';'
;
InterfaceDecl:
'IDECL' InfDeclList
;
InfDeclList:
InfDecl
| InfDecl ',' InfDeclList
;
InfDecl:
Symbol '(' ConstValue ',' ConstValue ')'
;
ObjDeclList:
Symbol '[' Symbol ']'
| Symbol '[' Symbol ']' ',' ObjDeclList
;
ProtoDeclList:
ProtoDecl
| ProtoDecl ',' ProtoDeclList
;
ProtoDecl:
Symbol '(' ConstValue ')'
;
ProcDecl:
Symbol '(' ArgumentList ')' Statement
| Symbol '(' ')' Statement
;
ArgumentList:
Symbol
| Symbol ',' ArgumentList
;
Statement:
CompoundStmt
| Symbol ':=' Expression ';'
| Symbol Subscripts ':=' Expression ';'
| ProcedureCall
| 'CALL' ProcedureCall ';'
| Symbol '.' ProcedureCall ';'
| 'SELF' '.' ProcedureCall ';' /* SELF may be a keyword */
| 'SEND' '(' Symbol ',' Symbol ',' ProcedureCall ')' ';'
| 'IF' '(' Expression ')' Statement
| 'IE' '(' Expression ')' Statement 'ELSE' Statement
| 'WHILE' '(' Expression ')' Statement
| 'FOR' '(' Symbol '=' Expression ',' Expression ')' Statement
| 'FOR' '(' Symbol '=' Expression ',' Expression ',' ConstValue ')'
Statement
| 'LEAVE' ';'
| 'LOOP' ';'
| 'RETURN' ';'
| 'RETURN' Expression ';'
| 'HALT' ';'
| 'HALT' ConstValue ';'
| ';'
;
CompoundStmt:
'DO' 'END'
| 'DO' LocalDeclList 'END'
| 'DO' StatementList 'END'
| 'DO' LocalDeclList StatementList 'END'
;
LocalDeclList:
LocalDecl
| LocalDecl LocalDeclList
;
LocalDecl:
'VAR' VarDeclList ';'
| 'CONST' ConstDeclList ';'
| 'STRUCT' Symbol '=' StructMemList ';'
| 'OBJECT' ObjDeclList ';'
;
StatementList:
Statement
| Statement StatementList
;
ExprList:
Expression
| Expression ',' ExprList
;
Expression:
Disjunction
| Disjunction '->' Expression ':' Expression
;
Disjunction:
Conjunction
| Disjunction '\/' Conjunction
;
Conjunction:
Equation
| Conjunction '/\' Equation
;
Equation:
Relation
| Equation '=' Relation
| Equation '\=' Relation
;
Relation:
BitOperation
| Relation '<' BitOperation
| Relation '>' BitOperation
| Relation '<=' BitOperation
| Relation '>=' BitOperation
| Relation '.<' BitOperation
| Relation '.>' BitOperation
| Relation '.<=' BitOperation
| Relation '.>=' BitOperation
;
BitOperation:
Sum
| BitOperation '&' Sum
| BitOperation '|' Sum
| BitOperation '^' Sum
| BitOperation '<<' Sum
| BitOperation '>>' Sum
;
Sum:
Term
| Sum '+' Term
| Sum '-' Term
;
Term:
Factor
| Term '*' Factor
| Term '/' Factor
| Term '.*' Factor
| Term './' Factor
| Term 'MOD' Factor
;
Factor:
Number
| String
| Table
| 'PACKED' PackedTable
| Symbol
| Symbol Subscripts
| Symbol '.' Symbol
| ProcedureCall
| 'CALL' ProcedureCall
| Symbol '.' ProcedureCall
| 'SELF' '.' ProcedureCall /* SELF may be a keyword */
| 'SEND' '(' Symbol ',' Symbol ',' ProcedureCall ')'
| '@' Symbol
| '-' Factor
| '\' Factor
| '~' Factor
| '(' Expression ')'
;
Subscripts:
'[' Expression ']'
| '::' Factor
| '[' Expression ']' Subscripts
;
Table:
'[' MemberList ']'
;
MemberList:
TableMember
| TableMember ',' MemberList
;
TableMember:
ConstValue
| String
| Table
| 'PACKED' PackedTable
| '@' Symbol
| '(' ExprList ')'
;
PackedTable:
'[' PackedTableMembers ']'
;
PackedTableMembers:
PackedTableMember
| PackedTableMember ',' PackedTableMembers
;
PackedTableMember:
Symbol
| Number
;
ProcedureCall:
Symbol '(' ')'
| Symbol '(' ExprList ')'
;
ConstValue:
SimpleConst
| ConstValue '*' SimpleConst
| ConstValue '+' SimpleConst
| ConstValue '-' SimpleConst
| ConstValue '|' SimpleConst
;
SimpleConst:
Symbol
| Number
| '-' Symbol
| '-' Number
| '~' Symbol
| '~' Number
;
Number:
DecimalNumber
| '%' # DecimalNumber
| '0X' # HexNumber
| '0B' # BinaryNumber
| '%' # '0X' # HexNumber
| '%' # '0B' # BinaryNumber
| '''' # AnyChar # ''''
;
BinaryNumber:
BinaryDigit
| BinaryDigit # BinaryNumber
;
DecimalNumber:
DecimalDigit
| DecimalDigit # DecimalNumber
;
HexNumber:
HexDigit
| HexDigit # HexNumber
;
Symbol:
FirstSymChar
| FirstSymChar # SymbolChars
;
SymbolChars:
FirstSymChar
| DecimalDigit
| FirstSymChar # SymbolChars
| DecimalDigit # SymbolChars
;
FirstSymChar:
'_'
|'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'
;
HexDigit:
DecimalDigit
|'A'|'B'|'C'|'D'|'E'|'F'
|'a'|'b'|'c'|'d'|'e'|'f'
;
DecimalDigit:
'0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
;
BinaryDigit:
'0'|'1'
;
String:
'"' # StringChars # '"'
;
StringChars:
AnyChar
| AnyChar # StringChars
;
AnyChar:
<character>
| '\' # <character>
;
| Previous: 5.1 Syntax Description Language | TOC | Index | Back | Next: 6. Quick Reference |