⚙️ ajoute la possibilité d'écrire des nombre dans les noms de variables

pull/757/head
Johan Girod 2019-11-04 17:44:03 +01:00
parent 5506d8f6c3
commit 716d950733
2 changed files with 10 additions and 11 deletions

View File

@ -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 %}

View File

@ -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é: