2017-03-07 17:25:25 +00:00
|
|
|
@{% function buildNode(type, d){return ({nodeType: type, explanation: d})} %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
main ->
|
|
|
|
CalcExpression {% id %}
|
|
|
|
| Variable {% id %}
|
|
|
|
| ModifiedVariable {% id %}
|
|
|
|
| Comparison {% id %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
Comparison -> Comparable _ ComparisonOperator _ Comparable {% d => ({nodeType: 'Comparison', operator: d[2][0], explanation: [d[0], d[4]]}) %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
Comparable -> (int | CalcExpression | Variable) {% d => d[0][0] %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
ComparisonOperator -> ">" | "<" | ">=" | "<=" | "="
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
ModifiedVariable -> Variable _ Modifier {% d => ({nodeType: 'ModifiedVariable', modifier: d[2], variable: d[0] }) %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
Modifier -> "[" TemporalModifier "]" {% d =>d[1][0] %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
TemporalModifier -> "annuel" | "mensuel" | "jour ouvré" {% id %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
CalcExpression -> Term _ ArithmeticOperator _ Term {% d => ({nodeType: 'CalcExpression', operator: d[2], explanation: [d[0], d[4]]}) %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
Term -> Variable {% id %}
|
|
|
|
| int {% id %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
ArithmeticOperator -> "+" {% id %}
|
|
|
|
| "-" {% id %}
|
|
|
|
| "*" {% id %}
|
|
|
|
| "/" {% id %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
# BooleanVariableExpression -> ("!" _):? Variable {% d => (['BooleanVariableExpression', ...d]) %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
Variable -> VariableFragment (_ Dot _ VariableFragment {% d => d[3] %}):* {% d => ({nodeType: 'Variable', fragments: [d[0], ...d[1]] }) %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
VariableFragment -> VariableWord (_ VariableWord {% d=> ' ' + d[1] %}):* {% d => d[0] + ' ' + d[1].join('') %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
VariableWord -> [a-zA-Z\u00C0-\u017F]:+ {% d => d[0].join('') %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
Dot -> [\.] {% d => null %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
_ -> [\s] {% d => null %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
|
|
|
|
2017-03-07 17:25:25 +00:00
|
|
|
int -> [0-9]:+ {% d => ({nodeType: 'value', value: d[0].join("")}) %}
|