Builds scope tree by walking the syntax tree; maintains a stack of scope IDs.
Records the sequence of scope IDs pushed (in walk order) so Validator can use the same IDs.
Collects diagnostics and maintains scope stack (replaying scope structure from first pass).
Uses the same scope ID sequence as ScopeBuilder so resolve() looks up the correct scope.
Analyze the program with the root scope pre-seeded from signature files (e.g. stdlib constants and functions).
This allows references to global constants and built-in functions to resolve without errors.
Also seeds built-in type/class names (e.g. Class, bool) so that common LeekScript code validates.
Returns the right-hand side expression of a NodeBinaryExpr.
Prefers the named field “rhs” when present; otherwise uses the last node child.
When the grammar labels RHS, it may wrap it in NodeExpr; we unwrap so the returned node is the inner expression.
Build list of (ScopeId, extent) where extent is (start_byte, end_byte).
Root scope (ScopeId(0)) is always first with extent (0, source_len).
Remaining entries are in walk order, matching scope_id_sequence.
Number of argument expressions in a NodeCallExpr. Used for type inference so the call
is inferred as the function’s return type. The grammar uses lparen, optional(expr, zero_or_more(comma, expr)), rparen;
the optional may be one node (with 0, 1, or more children) or optional + zero_or_more as siblings.
Field name, optional declared type, and whether it’s static from a NodeClassField.
Returns (name, type, is_static) where type is None if the field has no type annotation.
Visibility of a class member from the preceding modifier. Public by default when no modifier.
The modifier that applies is the last visibility keyword before this member that is not “consumed” by another member (i.e. no other member’s range contains that keyword).
Returns the receiver name (identifier or keyword before the dot) from a NodeMemberExpr.
For Cell.getCell returns Some("Cell"), for this.update returns Some("this").
Name to use for type/scope resolution from a primary expr: identifier, or “this”/“super” when
the single token is the corresponding keyword (class methods don’t use the function keyword).
Seed the root scope from a program AST (top-level classes, functions, globals only).
Also registers class fields and methods so member access (e.g. myCell.x) infers types.
Used when building scope from included files so the main file sees their declarations.
Seed the root scope from parsed signature file(s). Each element of signature_roots
should be the root node returned by parse_signatures() (may be a wrapper or NodeSigFile).
Returns the declaration kind and name from a NodeVarDecl.
For “var x”, “global T x”: name is the first identifier after the keyword.
For typed form “Array arr” or “integer? y”: name is the last identifier before “=” (type names come first).