v5 Parsing: modules, imports, and member access

  • Build Program.Modules and choose parse mode once.
  • Preserve member/call/index postfix structure and export flags.
  • Reject invalid export forms without performing module resolution.
1 / 6

Readiness

  • Parse v4 statements and repeated postfix expressions.
  • Distinguish module identity, import alias, and exported binding.
2 / 6

Worked reconstruction

Parse module main { import util as u; let x=u.make()[0]; }:

Representation Recorded fields
Program one Module named main
Import Name=util, Alias=u
variable x initializer Index(Call(Member(Ident(u),make)),0)

The parser accepts this shape without proving util exists; the analyzer checks that later. Dot wraps the accumulated postfix expression just like calls and indexes. For m.get(1).x[2], the wrappers are Member, Call, Member, Index in source order. Some resulting member bases may later be rejected by module semantics even though their syntax is valid.

3 / 6

Diagnose before implementing

A parser produces Call(Ident("u.make")) for u.make() and accepts export while(true){}. What structure and grammar boundary were lost?

4 / 6

Independent transfer

Draw ASTs for u.f()[1] and u.f[1]() and explain which value each calls. Construct an implicit-main program and then append an explicit module declaration; predict the fixed-mode parsing failure.

5 / 6

Carry forward

Carry ordered Modules, Imports, Exported flags, and Member nodes into v5 analysis. Keep unresolved-module syntax tests distinct from module-graph validity tests.

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