1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
grammar ActionExpression;
expression_main: expression EOF;
expression
: value_expression
| random_range_expression
| parenthesis_expression
| variable_reference_expression
| expression ( PLUS | MINUS ) expression
;
parenthesis_expression: L_PAREN expression R_PAREN;
value_expression
: literal_expression
| vec3d_constructor
;
literal_expression
: FLOAT
| INT
| STRING
;
// variable references are just a list of identifiers instead of being applied to expressions to avoid introducing types
// for all the intermediate parts
variable_reference_expression: IDENTIFIER (DOT IDENTIFIER)*;
random_range_expression: RAND_L_PAREN expression expression R_PAREN;
vec3d_constructor: L_PAREN expression expression expression R_PAREN;
PLUS: '+';
MINUS: '-';
FLOAT
: '-'? ([0-9]+ '.' [0-9]+)
;
INT: '-'? [0-9]+;
// The left parenthesis for the start of a random range
RAND_L_PAREN: '~(';
L_PAREN: '(';
R_PAREN: ')';
IDENTIFIER: [a-zA-Z][a-zA-Z0-9]*;
DOT: '.';
STRING: '"' .*? '"';
SPACE
: [ \t\r\n] -> skip
;
OTHER
: .
;
|