Résolution de la récursion du parse

pull/481/head
Mael 2019-06-14 10:43:09 +02:00
parent 9b4a3b9e57
commit f234ebc9ac
2 changed files with 7 additions and 2 deletions

View File

@ -16,7 +16,7 @@ export let parseReference = (rules, rule, parsedRules, filter) => ({
let partialReference = fragments.join(' . '),
dottedName = disambiguateRuleReference(rules, rule, partialReference)
let variable =
let parsedRule =
parsedRules[dottedName] ||
(console.log('uncached : from `', rule.dottedName, '` to `', dottedName) ||
parseRule(rules, findRuleByDottedName(rules, dottedName), parsedRules))
@ -28,7 +28,10 @@ export let parseReference = (rules, rule, parsedRules, filter) => ({
cached = cache[cacheName]
if (cached) return cached
let variableHasFormula = variable.formule != null,
let variable =
typeof parsedRule === 'object' ? parsedRule : parsedRules[dottedName],
variableHasFormula = variable.formule != null,
variableHasCond =
variable['applicable si'] != null ||
variable['non applicable si'] != null ||

View File

@ -9,6 +9,8 @@ import { parse } from 'Engine/parse'
export default (rules, rule, parsedRules) => {
if (parsedRules[rule.dottedName]) return parsedRules[rule.dottedName]
parsedRules[rule.dottedName] = 'being parsed'
/*
The parseRule function will traverse the tree of the `rule` and produce an AST, an object containing other objects containing other objects...
Some of the attributes of the rule are dynamic, they need to be parsed. It is the case of `non applicable si`, `applicable si`, `formule`.