From f234ebc9acbab8e237310ce3303630648f31bef0 Mon Sep 17 00:00:00 2001 From: Mael Date: Fri, 14 Jun 2019 10:43:09 +0200 Subject: [PATCH] =?UTF-8?q?R=C3=A9solution=20de=20la=20r=C3=A9cursion=20du?= =?UTF-8?q?=20parse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/engine/parseReference.js | 7 +++++-- source/engine/parseRule.js | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/source/engine/parseReference.js b/source/engine/parseReference.js index d23ba7894..bdb9b9b90 100644 --- a/source/engine/parseReference.js +++ b/source/engine/parseReference.js @@ -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 || diff --git a/source/engine/parseRule.js b/source/engine/parseRule.js index faed7ff34..15344aa1a 100644 --- a/source/engine/parseRule.js +++ b/source/engine/parseRule.js @@ -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`.