Repository navigation
refactor(interpreter): single scope-carrying evaluator for template generatio - #222
Open
Anbarasu2410 wants to merge 1 commit into
Open
Anbarasu2410 wants to merge 1 commit into
Anbarasu2410 wants to merge 1 commit into
Conversation
…eneration Replaces the multi-pass AST tree generation (evaluateUserCode, generateRecursiveBlocks, generateOptionalBlocks, and traverse.map) in TemplateMarkInterpreter with a single recursive evaluator evaluate(node, scope, ctx) that threads data context scopes down the AST. - Eliminates getJsonPath, path-keyed result dictionaries, and ancestor-walking guards - Binds correct item scope for nested list blocks - Evaluates whenNone cleanly when a list is inside an absent optional block - Evaluates formulas and conditions exactly once per scope instance - Adds test fixtures and snapshots for nested lists and absent optional lists Closes accordproject#216 Signed-off-by: Anbarasu2410 <anbuarasu2017@gmail.com>
5 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #216.
This PR refactors
TemplateMarkInterpreter.generateAgreementfrom multiple independent whole-tree pre-passes (evaluateUserCode,generateRecursiveBlocks,generateOptionalBlocks, andtraverse.map) to a single recursive evaluatorevaluate(node, scope, ctx)that carries the data context scope down the AST.Key Changes
evaluate(node, scope, ctx)insrc/TemplateMarkInterpreter.ts. Each scope-changing node (ListBlockDefinition,ForeachDefinition,JoinDefinition,OptionalDefinition,WithDefinition,ClauseDefinition) creates or updates aScopeinstance and evaluates its children within that scope.getJsonPath, path-keyed dictionary lookups (Record<string, CiceroMarkNode>), and ancestor-walking guards.getEvaluationDatato flatten ancestor scope bindings so compiled TypeScript formula preludes access outer variables acrosschildProcessJavaScriptEvaluationserialization.whenNonewithout error (at root and inside list items).test/templates/good/nested-listandtest/templates/good/optional-list-absentfixtures and snapshots.nested list data contexts.formula and condition evaluation counts.Verification
Commands run and test results:
npm run pretest(licchk, eslint, build): passed with 0 errors.npm test: 19 test suites passed, 200 tests passed, 48 snapshots passed.npm run test:e2e: 6 Playwright E2E browser tests passed.