From 716d950733212c6c6127f8ae3ec7e7c51e598e7e Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Mon, 4 Nov 2019 17:44:03 +0100 Subject: [PATCH] =?UTF-8?q?:gear:=20ajoute=20la=20possibilit=C3=A9=20d'?= =?UTF-8?q?=C3=A9crire=20des=20nombre=20dans=20les=20noms=20de=20variables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/engine/grammar.ne | 17 ++++++++--------- source/règles/base.yaml | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/source/engine/grammar.ne b/source/engine/grammar.ne index 025a3a6c9..27121c7fc 100644 --- a/source/engine/grammar.ne +++ b/source/engine/grammar.ne @@ -13,12 +13,12 @@ const moo = require("moo"); const letter = '[a-zA-Z\u00C0-\u017F]'; const letterOrNumber = '[a-zA-Z\u00C0-\u017F0-9\']'; const word = `${letter}(?:[\-']?${letterOrNumber}+)*`; -const numberRegExp = '-?(?:[1-9][0-9]+|[0-9])(?:\.[0-9]+)?'; +const wordOrNumber = `(?:${word}|${letterOrNumber}+)` +const words = `${word}(?:[\\s]?${wordOrNumber}+)*` +const numberRegExp = '-?(?:[1-9][0-9]+|[0-9])(?:\\.[0-9]+)?'; const percentageRegExp = numberRegExp + '\\%' - const lexer = moo.compile({ percentage: new RegExp(percentageRegExp), - number: new RegExp(numberRegExp), '(': '(', ')': ')', '[': '[', @@ -26,7 +26,8 @@ const lexer = moo.compile({ comparison: ['>','<','>=','<=','=','!='], additionSubstraction: /[\+-]/, multiplicationDivision: ['*','/'], - word: new RegExp(word), + words: new RegExp(words), + number: new RegExp(numberRegExp), string: /'[ \t\.'a-zA-Z\-\u00C0-\u017F0-9 ]+'/, '€': '€', dot: ' . ', @@ -67,17 +68,15 @@ NonNumericTerminal -> boolean {% id %} | string {% id %} -Words -> %word (%space (%word {% id %} | %letterOrNumber {% id %}) {% join %}):* {% flattenJoin %} - -Variable -> Words (%dot Words {% ([,words]) => words %}):* {% variable %} +Variable -> %words (%dot %words {% ([,words]) => words %}):* {% variable %} BaseUnit -> - %word {% id %} + %words {% id %} | "€" {% id %} Unit -> BaseUnit ("/" BaseUnit {% join %}):? {% join %} -Filter -> "[" Words "]" {% ([,filter]) => filter %} +Filter -> "[" %words "]" {% ([,filter]) => filter %} FilteredVariable -> Variable %space Filter {% filteredVariable %} TemporalTransform -> "[" ("mensuel" | "annuel" {% id %}) "]" {% ([,temporality]) => temporality %} diff --git a/source/règles/base.yaml b/source/règles/base.yaml index f6df1523d..832a9bac8 100644 --- a/source/règles/base.yaml +++ b/source/règles/base.yaml @@ -1114,7 +1114,7 @@ contrat salarié . SMIC temps plein . net imposable: période: mois unité: € description: Montant du SMIC net imposable - formule: 1247,55 + formule: 1247.55 note: Ce montant est codé en dur, il faudrait le calculer à partir du montant du SMIC brut références: barème PAS: https://bofip.impots.gouv.fr/bofip/11255-PGP.html @@ -2310,7 +2310,7 @@ contrat salarié . chômage . taux salarié: formule: 0% contrat salarié . chômage . taux employeur: - formule: 4.05 % + formule: 4.05% contrat salarié . complémentaire santé: