2017-03-07 17:25:25 +00:00
|
|
|
main ->
|
2019-05-02 13:58:39 +00:00
|
|
|
AS {% id %}
|
|
|
|
| Comparison {% id %}
|
|
|
|
| NonNumericTerminal {% id %}
|
|
|
|
|
|
|
|
NumericTerminal ->
|
|
|
|
Variable {% id %}
|
2018-11-13 15:14:57 +00:00
|
|
|
| TemporalVariable {% id %}
|
2017-06-22 16:03:12 +00:00
|
|
|
| FilteredVariable {% id %}
|
2017-09-19 11:17:43 +00:00
|
|
|
| percentage {% id %}
|
2019-05-02 13:58:39 +00:00
|
|
|
| number {% id %}
|
|
|
|
|
2019-05-15 12:47:24 +00:00
|
|
|
Parentheses -> "(" AS ")" {% ([,e]) => e %}
|
2019-05-02 13:58:39 +00:00
|
|
|
| NumericTerminal {% id %}
|
|
|
|
|
2019-05-14 17:40:47 +00:00
|
|
|
ComparisonOperator -> ">" | "<" | ">=" | "<=" | "=" | "!="
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2019-05-14 17:40:47 +00:00
|
|
|
Comparison -> Comparable _ ComparisonOperator _ Comparable {% ([A, , operator, , B]) => ({
|
|
|
|
[operator]:
|
2019-05-15 08:52:20 +00:00
|
|
|
{
|
|
|
|
type: 'comparison',
|
|
|
|
explanation:
|
2019-05-14 17:40:47 +00:00
|
|
|
[A, B]
|
2019-05-15 08:52:20 +00:00
|
|
|
}
|
2019-05-14 17:40:47 +00:00
|
|
|
}) %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2019-05-14 17:40:47 +00:00
|
|
|
Comparable -> ( AS | NonNumericTerminal) {% ([[e]]) => e %}
|
2019-05-02 13:58:39 +00:00
|
|
|
|
|
|
|
NonNumericTerminal ->
|
|
|
|
Boolean {% id %}
|
|
|
|
| String {% id %}
|
|
|
|
| NegatedVariable {% id %}
|
|
|
|
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2019-05-15 08:52:20 +00:00
|
|
|
NegatedVariable -> "≠" _ Variable {% ([,,{variable}]) => ({'≠': {explanation: variable} }) %}
|
2017-05-09 13:39:42 +00:00
|
|
|
|
2019-05-15 13:43:56 +00:00
|
|
|
FilteredVariable -> Variable _ Filter {% ([{variable},,filter],l,reject) => ['mensuel', 'annuel'].includes(filter) ? reject : ({filter: {filter, explanation: variable}}) %}
|
2017-06-22 16:03:12 +00:00
|
|
|
|
2019-05-15 13:43:56 +00:00
|
|
|
Filter -> "[" VariableFragment "]" {% ([,filter]) => filter %}
|
2017-06-22 16:03:12 +00:00
|
|
|
|
2019-05-15 08:52:20 +00:00
|
|
|
TemporalVariable -> Variable _ TemporalTransform {% ([{variable},,temporalTransform]) => ({'temporalTransform': {explanation: variable, temporalTransform} }) %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2019-05-14 17:40:47 +00:00
|
|
|
TemporalTransform -> "[" Temporality "]" {% d =>d[1] %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2019-05-14 17:40:47 +00:00
|
|
|
Temporality -> "annuel" | "mensuel" {% id %}
|
2017-05-09 13:39:42 +00:00
|
|
|
#-----
|
|
|
|
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2019-05-02 13:58:39 +00:00
|
|
|
# Addition and subtraction
|
2019-05-14 17:40:47 +00:00
|
|
|
AS -> AS _ ASOperator _ MD {% ([A, , operator, , B]) => ({
|
|
|
|
[operator]:
|
2019-05-15 08:52:20 +00:00
|
|
|
{
|
|
|
|
type: 'calculation',
|
|
|
|
explanation:
|
2019-05-14 17:40:47 +00:00
|
|
|
[A, B]
|
2019-05-15 08:52:20 +00:00
|
|
|
}
|
2017-03-08 16:47:12 +00:00
|
|
|
}) %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2019-05-02 13:58:39 +00:00
|
|
|
| MD {% id %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2019-05-02 13:58:39 +00:00
|
|
|
|
|
|
|
ASOperator -> "+" {% id %}
|
2017-03-07 17:25:25 +00:00
|
|
|
| "-" {% id %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2019-05-02 13:58:39 +00:00
|
|
|
MDOperator -> "*" {% id %}
|
|
|
|
| "/" {% id %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2019-05-02 13:58:39 +00:00
|
|
|
# Multiplication and division
|
2019-05-15 08:52:20 +00:00
|
|
|
MD -> MD _ MDOperator _ Parentheses {%
|
2019-05-14 17:40:47 +00:00
|
|
|
([A, , operator, , B]) => ({
|
|
|
|
[operator]:
|
2019-05-15 08:52:20 +00:00
|
|
|
{
|
|
|
|
type: 'calculation',
|
|
|
|
explanation:
|
2019-05-14 17:40:47 +00:00
|
|
|
[A, B]
|
2019-05-15 08:52:20 +00:00
|
|
|
}
|
2019-05-02 13:58:39 +00:00
|
|
|
}) %}
|
|
|
|
|
2019-05-15 08:52:20 +00:00
|
|
|
| Parentheses {% id %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2019-05-02 13:58:39 +00:00
|
|
|
Term -> Variable {% id %}
|
|
|
|
| FilteredVariable {% id %}
|
|
|
|
| number {% id %}
|
|
|
|
| percentage {% id %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2019-05-14 17:40:47 +00:00
|
|
|
Variable -> VariableFragment (_ Dot _ VariableFragment {% ([,,,fragment]) => fragment %}):*
|
2019-05-15 13:43:56 +00:00
|
|
|
{% ([firstFragment, nextFragments], l, reject) => {
|
|
|
|
let fragments = [firstFragment, ...nextFragments]
|
|
|
|
if (fragments.length === 1 && ['oui', 'non'].includes(fragments[0]))
|
|
|
|
return reject
|
|
|
|
return ({variable: {
|
|
|
|
fragments
|
|
|
|
}}) }%}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2019-05-15 08:52:20 +00:00
|
|
|
String -> "'" [ .'a-zA-Z\-\u00C0-\u017F ]:+ "'" {% d => ({constant: {
|
2019-05-14 17:40:47 +00:00
|
|
|
|
2017-09-07 14:52:14 +00:00
|
|
|
type: 'string',
|
2019-05-15 08:52:20 +00:00
|
|
|
nodeValue: d[1].join(''),
|
|
|
|
rawNode: d[1].join('')
|
2019-05-14 17:40:47 +00:00
|
|
|
}}) %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
2017-03-08 16:47:12 +00:00
|
|
|
VariableFragment -> VariableWord (_ VariableWord {% d=> ' ' + d[1] %}):* {% d => d[0] + d[1].join('') %}
|
2017-03-06 16:35:30 +00:00
|
|
|
|
|
|
|
|
2019-02-18 18:31:00 +00:00
|
|
|
VariableWord -> [a-zA-Z\u00C0-\u017F] [\-'a-zA-Z\u00C0-\u017F]:* {% d => d[0] + d[1].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
|
|
|
|
|
|
|
|
2019-05-15 08:52:20 +00:00
|
|
|
number -> [0-9]:+ ([\.] [0-9]:+):? {% d => ({constant:{
|
2019-05-14 17:40:47 +00:00
|
|
|
|
2019-05-15 14:31:33 +00:00
|
|
|
rawNode: d,
|
2019-05-15 08:52:20 +00:00
|
|
|
nodeValue: parseFloat(d[0].join("")+(d[1]?(d[1][0]+d[1][1].join("")):""))}}) %}
|
|
|
|
|
|
|
|
percentage -> [0-9]:+ ([\.] [0-9]:+):? [\%] {% d => ({ 'constant':{
|
|
|
|
|
2019-05-15 14:31:33 +00:00
|
|
|
rawNode: d,
|
2019-05-15 08:52:20 +00:00
|
|
|
type: 'percentage', nodeValue: parseFloat(d[0].join("")+(d[1]?(d[1][0]+d[1][1].join("")):""))/100}}) %}
|
2017-09-19 11:17:43 +00:00
|
|
|
|
2018-08-07 18:46:26 +00:00
|
|
|
|
2019-05-14 17:40:47 +00:00
|
|
|
Boolean -> ("oui"
|
2019-05-15 08:52:20 +00:00
|
|
|
| "non" ) {% ([val])=> ({constant:{
|
|
|
|
|
|
|
|
rawNode: val,
|
|
|
|
type: 'boolean', nodeValue: {'oui': true, 'non': false}[val]}}) %}
|
2019-05-02 13:58:39 +00:00
|
|
|
|