v3 Parsing: Postfix, Maps, and Arrays

  • Build repeated postfix wrappers in left-to-right order.
  • Separate assignable syntax from runtime index validity.
  • Distinguish map expressions from statement blocks by context.
1 / 6

Readiness

  • Parse v2 statements and understand v3 callable/container values.
2 / 6

Worked reconstruction

Start with primary factory in factory(2)[0](5):

Consumed suffix New root Prior expression retained as
(2) Call callee Left = Ident(factory)
[0] Index target Left = previous Call
(5) Call callee Left = previous Index

A postfix loop keeps wrapping the accumulated expression until the next token is not ( or [. All suffixes bind more tightly than unary and binary operators. Thus -a[0] is Neg(Index(a,0)), not Index(Neg(a),0).

3 / 6

Diagnose before implementing

A parser accepts factory(2) then returns before [0](5), and represents a call by putting factory’s text in Value. Identify the two v2 assumptions that no longer hold.

4 / 6

Independent transfer

Draw the tree for build()[pick(1)] = source()[0];, labeling target, index, and RHS. Change only the target root to make it syntactically invalid, then create a different target that parses but is invalid at runtime.

5 / 6

Carry forward

Carry the postfix tree and explicit assignment target into v3 analysis. Store one chain with three suffixes as a regression against accidental one-suffix parsing.

6 / 6
←/→ or click edges to navigate · ? help · N notes · F fullscreen