1
0
Fork 0
mirror of https://github.com/betagouv/mon-entreprise synced 2025-02-08 19:55:00 +00:00
mon-entreprise/source/engine/grammar.ne
mama c16d0fa823 Toute règle peut donner un simulateur sur /simu/:name
Testé sur les règles du CDD, AGIRC, APEC
TODO :
- finir AGIRC APEC
  - !statut cadre
  - assiette cotisations sociales -> indemnités CDD -> espace CDD -> CDD
booléen
2017-05-09 14:47:55 +02:00

62 lines
1.6 KiB
Text

# Pour éditer ou comprendre ce fichier, utilisez l'éditeur web Nearley : https://omrelli.ug/nearley-playground/
main ->
CalcExpression {% id %}
| Variable {% id %}
| ModifiedVariable {% id %}
| Comparison {% id %}
Comparison -> Comparable _ ComparisonOperator _ Comparable {% d => ({
category: 'comparison',
type: 'boolean',
operator: d[2][0],
explanation: [d[0], d[4]]
}) %}
Comparable -> (int | CalcExpression | Variable) {% d => d[0][0] %}
ComparisonOperator -> ">" | "<" | ">=" | "<=" | "="
ModifiedVariable -> Variable _ Modifier {% d => ({category: 'modifiedVariable', modifier: d[2], variable: d[0] }) %}
Modifier -> "[" TemporalModifier "]" {% d =>d[1][0] %}
TemporalModifier -> "annuel" | "mensuel" | "jour ouvré" {% id %}
CalcExpression -> Term _ ArithmeticOperator _ Term {% d => ({
category: 'calcExpression',
operator: d[2],
explanation: [d[0], d[4]],
type: 'numeric'
}) %}
Term -> Variable {% id %}
| int {% id %}
ArithmeticOperator -> "+" {% id %}
| "-" {% id %}
| "*" {% id %}
| "/" {% id %}
# BooleanVariableExpression -> ("!" _):? Variable {% d => (['BooleanVariableExpression', ...d]) %}
Variable -> VariableFragment (_ Dot _ VariableFragment {% d => d[3] %}):* {% d => ({
category: 'variable',
fragments: [d[0], ...d[1]],
type: 'numeric | boolean'
}) %}
VariableFragment -> VariableWord (_ VariableWord {% d=> ' ' + d[1] %}):* {% d => d[0] + d[1].join('') %}
VariableWord -> [a-zA-Z\u00C0-\u017F]:+ {% d => d[0].join('') %}
Dot -> [\.] {% d => null %}
_ -> [\s] {% d => null %}
int -> [0-9]:+ {% d => ({category: 'value', nodeValue: +d[0].join("")}) %}