Formal Grammar
The formal grammar presented below defines variable values in Extended BNF (Bakus-Naur Form):
— ' ' - literal value
— ( ) - group of values
— | - choice
— ? - multiplicity 0 or 1
— * - multiplicity 0 or more
— + - multiplicity 1 or more
— #xnnnn - 16 bit hexadecimal value
| Variable | Value | Comments |
| variable-value ::== | ( literal-string | variable-evaluation | function)* | |
| literal-string ::== | ( unicode-character | character-escape )+ |
/* allows $VAR or $FUNC(...) or ${VAR} */ |
| variable-evaluation :== | '$' ( variable-name | '{' variable-name '}') | |
| variable-name :== | identifier | |
| function :== | function-name '(' parameters ') | |
| function-name :== | ( '$Bates' | '$RomanNum' | '$RomanLowerNum' ) | |
| parameters :== | variable-evaluation ( ',' digit+ )? | variable-evaluation must resolve to a numeric value |
| identifier :== | letter ( letter | digit )* | |
| character-escape ::== | '\' ( '$' | '\' | '(' | ')' ) | |
| letter ::== | [ 'a' - 'z' ] | [ 'A' - 'Z' ] | '_' | |
| digit :== | ['0'-'9'] |
| Variable | Value | Comments |
| unicode-character ::== |
[ #x0020 - #x0023 ] | [ #x0025 - #x0026 ] | [ #x0029 - #x005B ] | [ #x005D - #x007F ] | [ #x00A0 - #xD7FF ] | [#xE000 - #xFFFD ] |
