Skip to content

Convert TreeNode from final class to struct #150

@leogdion

Description

@leogdion

Context

TreeNode (introduced in PR #147 at Sources/SyntaxParser/TreeNode.swift) is declared as final class but behaves as a value type:

  • Built up during a single traversal, then read-only
  • Encoded to JSON immediately after construction
  • Equatable conformance compares fields, not identity

The only genuine need for a reference type in this pipeline is the mutable current pointer inside TokenVisitor, which is already a separate internal type.

Proposed Work

Convert TreeNode to a struct. Key considerations:

  • The parent: Int? back-reference is by ID (not object identity), so no reference cycle concerns
  • Codable and Equatable synthesization works the same for structs
  • TokenVisitor builds nodes by mutating a current node — this will need to capture the struct by value and reassign, rather than mutating through a reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions