This page defines the FSM Tool specification language grammar.
For the specification language syntax, please see FSM Tool FSM DSL Syntax. |
Below is a formal grammar reference for the FSM Tool Finite State Machine Domain Specific Language (DSL), generated as Extended Backus-Naur Form (EBNF) in ANother Tool for Language Recognition (ANTLR) notation.
fsm
: 'fsm' ID '{' fsm_body '}'
;
fsm_body
: description?
endpoint*
state+
inputdictionary?
actiondictionary?
;
endpoint
: 'endpoint' ID ';'
;
state
: statetype? 'state' ID '{' state_body '}'
;
state_body
: description? entryaction? exitaction? inputaction* transition*
;
description
: 'description' QUOTED ';'
;
statetype
: ('initial' ('final')?|'final')
;
entryaction
: 'entryaction' actionlist ';'
;
exitaction
: 'exitaction' actionlist ';'
;
actionlist
: ID (',' ID )*
;
inputaction
: 'inputaction' 'if' '(' conditionalExpression ')' actionlist ';'
;
parConditionalExpression
: '(' conditionalExpression ')'
;
conditionalExpression
: conditionalAndExpression ('||' conditionalExpression )?
;
conditionalAndExpression
: unaryExpression ( '&&' conditionalAndExpression )?
;
unaryExpression
: '!' primary
| primary
;
primary
: inputname
| parConditionalExpression
;
transition
: 'transition' ( transition_condition )? ID ';'
;
transition_condition
: 'if' '(' conditionalExpression ')'
;
inputdictionary
: 'inputdictionary' '{' input* '}'
;
input
: inputname '{' description? (inputtype)? actionspecification? '}'
;
inputname
: (ID '.')? ID
;
inputtype
: 'type' ('transient' |'durable' ) ';'
;
actiondictionary
: 'actiondictionary' '{' action* '}'
;
action
: ID '{' description? actionspecification? '}'
;
actionspecification
: 'send' inputname (',' inputname)* ';'
WS : (' '|'\r'|'\t'|'\n')+ {skip();}
;
ID
: Letter (Letter|JavaIDDigit)*
;
fragment
Letter
: '\u0024' /* $ */ |
'\u0041'..'\u005a' /* A-Z */ |
'\u005f' /* _ */ |
'\u0061'..'\u007a' /* a-z */ |
'\u00c0'..'\u00d6' |
'\u00d8'..'\u00f6' |
'\u00f8'..'\u00ff' |
'\u0100'..'\u1fff' |
'\u3040'..'\u318f' |
'\u3300'..'\u337f' |
'\u3400'..'\u3d2d' |
'\u4e00'..'\u9fff' |
'\uf900'..'\ufaff'
;
fragment
JavaIDDigit
: '\u0030'..'\u0039' |
'\u0660'..'\u0669' |
'\u06f0'..'\u06f9' |
'\u0966'..'\u096f' |
'\u09e6'..'\u09ef' |
'\u0a66'..'\u0a6f' |
'\u0ae6'..'\u0aef' |
'\u0b66'..'\u0b6f' |
'\u0be7'..'\u0bef' |
'\u0c66'..'\u0c6f' |
'\u0ce6'..'\u0cef' |
'\u0d66'..'\u0d6f' |
'\u0e50'..'\u0e59' |
'\u0ed0'..'\u0ed9' |
'\u1040'..'\u1049'
;
QUOTED
: '"' ( options {greedy=false;} : . )* '"'
;
// comments are ignored initially, and then extracted via the commentsBefore() method
COMMENT
: '/*' ( options {greedy=false;} : . )* '*/'
;