-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdecision_rule.lark
71 lines (55 loc) · 1.23 KB
/
decision_rule.lark
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
62
63
64
65
66
67
68
69
70
71
start: decisionrule+
decisionrule: CNAME "{" rulerow+ "}"
rulerow: when "{" condition "}" then decision
decision: boolean
| numeric
| string
?when: WHEN
?then: THEN
!condition: expression
| [expression (conditional expression)*]
conditional: CONDITIONAL
expression: token in_operator word_list
| token operator value
| token between numeric "and" numeric
| "(" [expression (conditional expression)*] ")"
token: TOKEN_OR_RULE
word_list: WORD
| "(" [WORD ("," WORD)*] ")"
between: "between"
?numeric: SIGNED_NUMBER -> number
?value: SIGNED_NUMBER -> number
| boolean
| string
?in_operator: INLIST
?operator: lt
| gt
| lte
| gte
| eq
string: CNAME
boolean: TRUE | FALSE
lt: "<"
gt: ">"
lte: "<="
gte: ">="
eq: "=="
TRUE: "true"
FALSE: "false"
WHEN: "when"
THEN: "then"
DECISION: ("true" | "false" | SIGNED_NUMBER | CNAME)
CONDITIONAL: "and" | "or"
TOKEN_OR_RULE: CNAME | ("$RULE_" CNAME)
DECISION_RULE: "DecisionRule"
INLIST: "in"
EQ: "=="
%import common.WORD
%import common.INT
%import common.SIGNED_INT
%import common.SIGNED_NUMBER
%import common.FLOAT
%import common.CNAME
%import common.ESCAPED_STRING
%import common.WS
%ignore WS