This section provides the EBNF grammar for TML. Note that the constraint language grammar is also provided, though not actually part of TML.
The grammar is not yet annotated, but should be soon.
The terminal definitions may require explanation. Square brackets are used to indicate character classes (in the style of grep regular expressions). Literals are enclosed in double quotation marks, even in regular expressions (for clarity). The tilde ~ is used to indicate negation, and commas separate elements of character classes. The backslash is used to indicate that a character is to be taken literally.
model_decl ::= (constraint)* "model" ID (label)* (state_decl)* "end"
state_decl ::= (constraint)* STATE_NAME (label)* (arc_decl)*
arc_decl ::= (constraint)* STIMULUS_NAME (label)* destination
destination ::= STATE_NAME
| model_use STATE_NAME
| model_use selector
model_use ::= ID ("." STIMULUS_NAME)*
selector ::= "select" ((STIMULUS_NAME | "default") STATE_NAME)+ "end"
constraint ::= (ID ":")? "($" (constraint_entity)* "$)"
label ::= ID ":" ("{$" LABEL_TEXT "$}" | "|$" EOL_LABEL_TEXT)+
ID ::= ["A"-"Z","a"-"z","0"-"9","_"]+
STATE_NAME ::= "[" (~["\n","]"])+ "]"
STIMULUS_NAME ::= ("\"" ((~["\"","\n"])|("\\" "\""))* "\"")
constraint_entity ::= assignment | expression | directive
assignment ::= ID "=" expression
directive ::= "emax"
| "normalize" "(" expression ")"
| "assume" "(" expression ")"
| "fill" "(" expression ")"
expression ::= atom
| expression "^" atom
| expression "*" expression
| expression "/" expression
| expression "+" expression
| expression "-" expression
atom ::= ID
| REAL
| "(" expression ")"
REAL ::= INTEGER ("." (INTEGER)?)? (EXPONENT)?
EXPONENT ::= "e" (["+","-"])? INTEGER
INTEGER ::= ["0"-"9"]+