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 .