EBNF ~~~~ .. contents:: Table of Contents Program ------- The template language starts with the non-terminal token: "Program". :: Program ::= Code EOF Code ::= ( Text | Block )* Text ::= TextBlock | LiteralBlock | DelimiterBlock Block ::= CommentBlock | DeclarationBlock | ModifyingBlock | OutputBlock | LiteralBlock | CycleBlock | LoopBlock | CodeFlowBlock Text blocks ----------- :: TextBlock ::= ( ~'{' | '\'! '{' )* LiteralBlock ::= '{' 'literal' '}' Graphic* '{' '/literal' '}' DelimiterBlock :== '{ldelim}' | '{rdelim}' Blocks ------ :: CommentBlock ::= '{*' Graphic* '*}' DeclarationBlock ::= '{' 'var' SubDefineBlock '}' | '{' 'cycle' SubDefineBlock '}' | '{' 'use' SubDefineBlock '}' SubDefineBlock ::= PrimaryVariable ( '=' Expression )? ( ',' SubDefineBlock )? ModifyingBlock ::= '{' SubAssignBlock (',' SubAssignBlock)* '}' SubAssignBlock ::= AssignmentExpr | IncrementExpr | DecrementExpr AssignmentExpr ::= PrimaryVariable ( '=' | CombinedAssignment) Expression IncrementExpr ::= ( ( '++' PrimaryVariable ) | ( PrimaryVariable '++' ) ) DecrementExpr ::= ( ( '--' PrimaryVariable ) | ( PrimaryVariable '--' ) ) OutputBlock ::= '{' Expression '}' CycleBlock ::= '{' 'increment' PrimaryVariable ( ',' PrimaryVariable )* '}' | '{' 'decrement' PrimaryVariable ( ',' PrimaryVariable )* '}' | '{' 'reset' PrimaryVariable ( ',' PrimaryVariable )* '}' Loop control ------------ :: LoopBlock ::= ForeachStatement | WhileStatement ForeachStatement ::= '{' 'foreach' Expression 'as' PrimaryVariable ('=>' PrimaryVariable)? (Cycle)* (OffsetAndLimit)? '}' Code '{' '/foreach' '}' WhileStatement ::= '{' 'while' Expression '}' Code '{' '/while' '}' Cycle ::= ('increment' | 'decrement') PrimaryVariable (',' PrimaryVariable)* OffsetAndLimit ::= ('offset' Expression)? ('limit' Expression)? Code flow control ----------------- :: CodeFlowBlock ::= IfStatement | SwitchStatement | IncludeStatement | DelimiterStatement | '{break}' | '{skip}' | '{continue}' | ReturnStatement IfStatement ::= '{' 'if' Expression '}' Code (ElseIf)* (Else)? '{' '/if' '}' ElseIf ::= '{' 'elseif' Expression '}' Code Else ::= '{' 'else' '}' Code SwitchStatement ::= '{' 'switch' Expression '}' (Case)* (DefaultCase)? '{' '/switch' '}' Case ::= '{' 'case' Literal ( ',' Literal)* '}' Code '{' '/case' '}' DefaultCase ::= '{' 'default' '}' Code '{' '/default' '}' IncludeStatement ::= '{' 'include' Expression ('send' ExprAsPrimVarList)? ('receive' PrimVarAsPrimVarList)? '}' DelimiterStatement ::= '{' 'delimiter' (modulo Expression ('is' Expression)? )? '}' Code '{' '/delimiter' '}' ReturnStatement ::= '{' 'return' ExprAsPrimVarList '}' ExprAsPrimVarList ::= ( Expression 'as' PrimaryVariable | PrimaryVariable ) (',' ExprAsPrimVarList)? PrimVarAsPrimVarList::= PrimaryVariable ('as' PrimaryVariable)? (',' PrimVarAsPrimVarList)? Expression ---------- :: Expression ::= PreUnaryExpression (BinaryOperator Expression)? PreUnaryExpression ::= '++' PrimaryVariable | '--' PrimaryVariable | UnaryExpression | Expression 'instanceof' Identifier | ArrayDeclaration ArrayDeclaration ::= 'array' '(' ( (Expression '=>')? Expression ( ',' Expression )* (',')? )? ')' | Expression '..' Expression UnaryExpression ::= ( UnaryOperator )* PostFixExpression PostFixExpression ::= PrimaryVariable ( '++' | '--' )? | Literal | FunctionCall | '(' Expression ')' PrimaryVariable ::= '$' Identifier ( '[' Expression ']' | '->' Expression )* FunctionCall ::= Identifier '(' (ParameterList)? ')' ParameterList ::= Expression ( ',' Expression )* Identifier ::= Letter ( Letter | Digit | '_' )* Basic literals -------------- :: Literal ::= NumeralLiteral | StringLiteral | BooleanLiteral | NullLiteral NumeralLiteral ::= HexLiteral | OctLiteral | FloatLiteral HexLiteral ::= '0x' HexDigit+ OctLiteral ::= '0' OctDigit+ FloatLiteral ::= NonZeroDigit Digit* ( '.' Digit+ )? (('e'|'E') ('+'|'-')? Digit+)? StringLiteral ::= '"' Graphic* '"' | "'" Graphic* "'" BooleanLiteral ::= 'true' | 'false' NullLiteral ::= 'null' Lexicon ------- :: Comment ::= '//' Graphic* ( EOL | '}' ) | '/*' Graphic* '*/' Graphic ::= Digit | Letter | Blank | Operators | Assignment | CombinedAssignment | RemainingCharSet EOL ::= end-of-line EOF ::= end-of-file Blank ::= Tab | Space NewLine ::= '\n' Space ::= ' ' Tab ::= '\t' Letter ::= 'a' ... 'z' | 'A' ... 'Z' Hexdigit ::= '0' .. '9' | 'A' .. 'F' Octdigit ::= '0' .. '8' NonZeroDigit ::= '1' .. '9' Digit ::= '0' | NonZeroDigit Assignment ::= '=' CombinedAssignment ::= '+=' | '-=' | '*=' | '/=' | '%=' | '.=' Operators ::= BinaryOperator | UnaryOperator | '++' | '--' BinaryOperator ::= ArithmeticOperator | ComparisonOperator | BooleanOperator | StringOperator ArithmeticOperator ::= '+' | '-' | '*' | '/' | '%' ComparisonOperator ::= '==' | '===' | '!=' | '!==' | '<' | '<=' | '>' | '>=' BooleanOperator ::= '&&' | '||' StringOperator ::= '.' | '.=' UnaryOperator ::= '+' | '-' | '!' RemainingCharSet ::= '.' | ':' | ';' | ',' | '~' | '(' | ')' | '[' | ']' | '{' | '}' | '_' | '|' | "'" | '"' | '`' | '#' | '$' | '@' .. Local Variables: mode: rst fill-column: 79 End: vim: et syn=rst tw=79