FSM Guarded Tokens - RopleyIT/GLRParser GitHub Wiki
In conventional state machines, transitions between states are caused by events that are valid input events for the starting state. However, a common extension is for the transition to only be fired if the event occurs, and an associated guard condition is true at the time the event fires. The state machine generator used in the off-line parser (parselr.exe) and the inline state machines support the specification of a boolean guard expression attached to any event.
A guard expression is always enclosed in square brackets, and consists of guard function names and the boolean operators for not (!), and (&) and or (|). Parentheses can be included in the boolean expressions to make ultra clear the expected precedence of the boolean operations. Hence the following transition guard has a sensible meaning:
Unattached : MEETSPARTNER[(!Married) & ((Tall & Dark & Handsome) | Rich)] Attached;
As standard precedence is enforced, with the not (!) operator being higher precedence than and (&), and both being higher precedence than or (|), the following guard has the same meaning, albeit slightly less readable:
Unattached : MEETSPARTNER[!Married & (Tall & Dark & Handsome | Rich)] Attached;
Warning: No offence is intended in the content of this example!