summaryrefslogtreecommitdiff
path: root/old/minie.ebnf
blob: c6767803a3e651ded04fe2872b74e2f57760f31e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Digit			= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" .
Letter			= "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" .
Special			= "_" .
Character		= Digit | Letter | "!" | " " | "#" | "$" | "%" | "'" | "(" | ")" | "*" | "+" | "," | "," | "-" | "."  | "/" | "[" | "]" | "\" | "^" | "_" | "`" | "{" | "|" | "}" | "~" .
Number			= Digit { Digit } .
String			= """ { Character | """ """ } """ | "'" .
Identifier		= Letter { Letter | Digit | Special } .
QualifiedIdentifier	= Identifier [ "." Identifier ] .
Factor			= [ "+" | "-" ]  Number | String | Designator | "(" Expression ")" | ( "not" Factor ) .
Designator		= QualifiedIdentifier { Selector } .
Selector		= ArrayDereference .
ArrayDereference	= "[" Expression "]" .
Term			= Factor { ( "*" | "/" | "and" ) Factor } .
SimpleExpression	= Term { ( "+" | "-" | "or" ) Term } .
RelationalOperator	= "=" | "<>" | "<" | ">" | "<=" | ">=" .
Expression		= SimpleExpression [ RelationOperator SimpleExpression ].
VariableName		= Identifier .
Assignment		= Designator ":=" Expression .
StatementList		= Statement { ";" Statement }
IfStatement		= "if" Condition "do" StatementList "else" StatementList "end" .
ParameterList		= "(" [ Expression { "," Expression } ] ")" .
ProdecureCall		= QualifiedIdentifier ParameterList .
ForStatement		= "for" identifier ":=" Expression "to" Expression "do" StatementList "end" .
WhileStatement		= "while" expression "do" StatementList "end" .
ReturnStatement		= "return" expression .
Statement		= Assignment | IfStatement | ForStatement | WhileStatement | ProcedureCall | ReturnStatement .
StatementBlock		= "begin" StatementList "end" .
VariableName		= Identifier .
SimpleType		= Identifier .
ArrayType		= "array" [ Number ] "of" Type .
Type			= SimpleType | ArrayType .
VariableDeclaration	= VariableName ":" Type .
VariableBlock		= "var" { VariableDeclaration ";" } .
ConstExpression		= Expression .
ConstDeclaration	= Identifier "=" ConstExpression .
ConstBlock		= "const" { ConstDeclaration ";" } .
ImportBlock		= "import" Identifier { "," Identifier } .
ParameterDeclaration	= [ "(" [ Parameter { ";" Parameter } ] ")" ] [ ":" SimpleType ] .
Parameter		= ident ":" ParameterType .
ParameterType		= [ "array" "of" ] Type .
ProcedureDeclaration	= "procedure" Identifier [ ParameterDeclaration ] ";" DeclarationBlock StatementBlock .
DeclarationBlock	= [ ConstBlock ] [ VariableBlock ] { ProcedureDeclaration ";" } .
Module			= "module" Identifier ";" [ ImportBlock ] DeclarationBlock StatementBlock .