XFA Specification
Chapter 23, FormCalc Specification
Grammar and Syntax
805
Admittedly, this is a very simple application. A real-world purchase order form would be significantly more
complex, with perhaps several dozen calculations and validations. Hopefully this example will suffice to
introduce some of the capabilities of the
FormCalc
language.
We will now proceed to formalize the definition of this language. More complex language examples will
be presented throughout.
Grammar
The
FormCalc
language is defined in terms of a context-free grammar. This is a specification of the lexical
and syntactic structure of
FormCalc
calculations.
A context-free grammar is defined as a number of productions. Each production has an abstract symbol
called a nonterminal as its left-hand side, and a sequence of one or more nonterminal and terminal
symbols as its right-hand side. The grammar specifies the set of possible sequences of terminal symbols
that can result from repeatedly replacing any nonterminal in the sequence with a right-hand side of a
production in which the nonterminal is the left-hand side.
Notational Conventions
The following convention in notation is used to describe the grammar of
FormCalc:
Metasymbol
::=
Description
Start of the definition of a
nonterminal symbol.
Alternative symbol.
One from the set of enclosed
symbol(s).
Range of symbols.
Syntax example
FormCalculation ::= ExpressionList
defines the production FormCalculation as an
ExpressionList symbol.
'+' | '-'
allows alternate additive operator
symbols.
['E' 'e']
allows one symbol from the set 'E',
'e' of symbols.
['0'–'9']
allows one symbol from the
consecutive set '0', '1', ..., '9' of symbols.
Character \– LineTerminator
allows one
symbol from the set of Characters that is not a
LineTerminator symbol.
|
symbol
[symbol ]
[symbol –symbol ]
symbol
\–symbol
Set difference of symbols.
(symbol )
One occurrence of the enclosed
( '+' | '-' )
allows for one occurrence of
symbol(s).
either alternative symbol.
( ',' SimpleExpression )
*
allows for zero
Zero or more occurrences of the
or more occurrence of the ',' symbol followed by a
enclosed symbol(s).
SimpleExpression symbol.
(symbol )
*
(symbol )
?
At most one occurrence of the
enclosed symbol(s).
( ArgumentList )
?
allows for zero or one
occurrence of the ArgumentList symbol.
The nonterminal symbols of the grammar are always in normal print, often sub scripted by a production
key, e.g., ProductionName
[ProductionKey]
, as in LogicalAndExpression
70
. The terminal symbols of the
grammar are always enclosed in single quotes, as in '=' and 'then'.
Home Index Bookmark Pages
Pages: Home Index All Pages