Skip to content

No Symbol Table for Variable Tracking #5

@SAMBA8695

Description

@SAMBA8695

Description

The compiler currently has no symbol table. As a result, variables declared using let are never stored, and identifiers cannot be resolved during later stages of compilation.

Although the parser builds AST_VAR_DECL and AST_VAR nodes, there is no data structure that tracks variable names and their associated values or IR representations.

Example Input

let x = 1;
let y = x + 2;

Current Behavior

  • Variable declarations (let x = ...) do not store x anywhere
  • Identifier usage (x) cannot be resolved
  • IR generation ignores variable scope and lifetime
  • LLVM output discards computed values
  • No error is reported for undefined variables

Expected Behavior

  • A symbol table should map variable names to their values or IR references
  • Variable declarations should insert entries into the symbol table
  • Identifier usage should look up variables in the symbol table
  • Using an undefined variable should produce a clear error

Suggested Direction

  • Introduce a symbol table data structure (e.g. hash map or scoped table)
  • Integrate symbol table into parsing or IR generation
  • Handle AST_VAR_DECL and AST_VAR using the symbol table
  • Prepare for future scope support (blocks, functions)

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