XFA Specification
Chapter 23, FormCalc Specification
Grammar and Syntax
809
The following are keywords and may not be used as identifiers:
15 Keyword ::= 'if' | 'then' | 'elseif' | 'else' | 'endif' | 'or' | 'and' |
'not' | 'eq' | 'ne' | 'le' | 'ge' | 'lt' | 'gt' | 'this' | 'null' | 'nan' |
'infinity'
16 ReservedKeyword ::= | 'while' | 'do' | 'endwhile' | 'end' | 'for' | 'upto' |
'downto' | 'step' | 'endfor' | 'foreach | 'in' | 'break' | 'continue' | 'var' |
'func' | 'endfunc' | 'throw' | 'return' | 'exit'
Operators
FormCalc
defines a number of operators; they include unary operators, multiplicative operators, additive
operators, relational operators, equality operators, logical operators, and the assignment operator.
FormCalc
operators are symbols common to most other scripting languages:
17 Operator ::= '=' | '|' | '&' | '==' | '<>' | '<=' | '>=' | '<' | '>' | '+' |
'-' | '*' | '/'
Several of the
FormCalc
operators have an equivalent mnemonic operator keyword. These keyword
operators are useful whenever
FormCalc
expressions are embedded in HTML and XML source text, where
symbols <, >, and & have predefined meanings and must be escaped. Here's an enumeration of all
FormCalc
operators, illustrating the symbolic and mnemonic forms of various operators.
18
19
20
21
22
23
24
LogicalOrOperator ::= '|' | 'or'
LogicalAndOperator ::= '&' | 'and'
EqualityOperator ::= '==' | '<>' | 'eq' | 'ne'
RelationalOperator ::= '<=' | '>=' | '<' | '>' | 'le' | 'ge' | 'lt' | 'gt'
AdditiveOperator ::= '+' | '-'
MultiplicativeOperator ::= '*' | '/'
UnaryOperator ::= '-' | '+' | 'not'
Tokens
25 Separator ::= '(' | ')' | '[' | ']' | ',' | '.' | '..' | '.#' | '.*'
26 Token ::= Literal | Keyword | Identifier | Operator | Separator
Syntactic Grammar
The syntactic grammar for
FormCalc
has the tokens defined in the preceding lexical grammar as its
terminal symbols. It defines the set of productions, starting from the nonterminal symbol FormCalculation,
to describe how sequences of tokens can form a syntactically valid calculation.
The following subsections describe the expressions in this syntactic grammar.
27 FormCalculation ::= ExpressionList
28 ExpressionList ::= Expression | ExpressionList Expression
29 Expression ::= IfExpression |
WhileExpression |
ForExpression |
ForEachExpression |
AssignmentExpression |