Skip to content

Make the compiler use a Packed AST (PAST) internally #1

Open
@Araq

Description

@Araq

See the code in compiler/past.nim and compiler/bitabs.nim for a rather precise outline of the structure. The plan is to use NimTree throughout the compiler which is a linearized representation of the AST that only supports in-place mutation in strategic places. In order to support Nim's VM / macro system there will be two operations:

proc fromTree(t: NimTree): PNode
proc toTree(n: PNode): NimTree

Instead of mutating an AST, you create a fresh one. The number of allocations is very low because a full tree is essentially stored as a single string/blob in memory.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions