grammar StepGrammar;
AND: 'and';
OR: 'or';
ARROW: '=>';
COMA: ',';
IF: 'if';
ELSE: 'else';

SINGLE_STRING
    : '\'' ~('\'')+ '\''
    ;

DOUBLE_STRING
    : '"' ~('"')+ '"'
    ;

ID : [a-zA-Z$]+ ;             // match lower-case identifiers
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines

action: ID;

par_step:
    step
    ;

and_step:
    AND step
    ;

or_step:
    OR step
    ;

arrow_step:
    ARROW step
    ;

sequence_step:
    step
    ;

string
    : SINGLE_STRING
    | DOUBLE_STRING
    ;

check:
      IF string step ELSE step
    | IF string step
    ;

step:
    action
    | step sequence_step
    | step and_step
    | step or_step
    | check
    | step arrow_step
    | '(' par_step ')'
    ;

main:
    step EOF;