Path

ez components / documentation / api reference / latest / template


eZ Components latest

Template: EBNF

[ Tutorial ] [ EBNF ] [ Functions ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

EBNF

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
                    |   TranslationBlock

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}'
                    |   CaptureStatement
                    |   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' '}'

CaptureStatement    ::= '{' 'capture' Expression '}' Code '{' '/capture' '}'

ReturnStatement     ::= '{' 'return' PrimaryVariable '}'

ExprAsPrimVarList   ::=  ( Expression 'as' PrimaryVariable | PrimaryVariable ) (',' ExprAsPrimVarList)?

PrimVarAsPrimVarList::=  PrimaryVariable ('as' PrimaryVariable)? (',' PrimVarAsPrimVarList)?

Translations

TranslationBlock               ::= TranslationContextStatement | TranslationStatement

TranslationContextStatement    ::= '{' 'tr_context' StringLiteral '}'

TranslationStatement           ::= '{' 'tr' StringLiteral ('context' StringLiteral)? ('comment' StringLiteral)? TranslationVars? '}'

TranslationVars                ::= 'vars' TranslationVarList
TranslationVarList             ::= TranslationVar | TranslationVar ',' TranslationVarList
TranslationVar                 ::= TranslationVarKey? Expression
TranslationVarKey              ::= ( StringLiteral | NumeralLiteral ) '=>'

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    ::= '.' | ':' | ';' | ',' | '~' | '(' | ')' | '[' | ']' | '{' | '}' | '_' | '|' | "'" | '"' | '`' | '#' | '$' | '@'
Last updated: Tue, 02 Dec 2008