Skip to content

Parser: WHEN clause should support AND chaining #3

@semanticintent

Description

@semanticintent

Summary

The WHEN clause inside DIVE INTO currently accepts only a single Condition per the PEG.js grammar. It should support AND chaining (a ConditionList) like WHERE does.

Current behaviour

DIVE INTO entity_raiders
WHEN cap_savings_evaporated = 30000000
  AND fa_commitments > 300000000      -- ❌ parse error
TRACE raiders_financial_cascade
EMIT acute_financial_cascade

Only the first condition is parsed; AND is not recognised inside WHEN.

Expected behaviour

DIVE INTO entity_raiders
WHEN cap_savings_evaporated = 30000000
  AND fa_commitments > 300000000      -- ✅ parsed as ConditionList
TRACE raiders_financial_cascade
EMIT acute_financial_cascade

Grammar reference

In src/parser/grammar.pegjs, WHEN maps to Condition while WHERE maps to ConditionList. Changing WHEN to also accept ConditionList would unify the two.

Workaround

Use a single WHEN condition and document the additional context in a comment:

WHEN cap_savings_evaporated = 30000000  -- $30M hole, $300M+ committed, trade value diminished

Applied this workaround to UC-045, UC-046, and UC-047.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions