Debug Tools

tape tokens

Dump the raw token stream from the scanner:

bash
tape tokens <file.tape>

Output:

plaintext
  1:1   TOK_AT_IDENT   "@profile"
  1:9   TOK_LPAREN     "("
  1:10  TOK_IDENT      "t1"
  1:12  TOK_RPAREN     ")"
  1:13  TOK_SEMI       ";"
  2:1   TOK_KW_IMPORT  "import"
  2:8   TOK_IDENT      "io"
  2:11  TOK_KW_FROM    "from"
  2:16  TOK_STRING     ""io""

Each line: line:col token_type "lexeme". Scans the entire file without region splitting.

tape ast

Dump the parsed abstract syntax tree:

bash
tape ast <file.tape>

Parses the #code and #view regions and prints the resulting AST. Uses tape_ast_dump() for structured output showing declarations, expressions, and types.

tape deps

Show resolved import paths:

bash
tape deps <file.tape>

Output:

plaintext
io -> src/tape/stdlib/io.tape
str -> src/tape/stdlib/str.tape

Or if a module can’t be found:

plaintext
app.tape:3:1: error: unresolved module 'missing'

Prints (no imports) if the file has no import statements. Exit code 1 if any imports are unresolved.

tape disasm

Compile a source file through the full pipeline (comptime → typecheck → lower) and dump the resulting TAC IR:

bash
tape disasm <file.tape> [--all] [--filter <name>]

Options

FlagDescription
--allShow all functions including stdlib/runtime
--filter <name>Only show functions whose name contains <name>

Default behavior

Without flags, tape disasm shows user-defined functions only — it skips:

  • Extern stubs (no body / block_count == 0)
  • Runtime internals (__tapert_* prefixed)
  • Qualified module functions (names containing .)

Output

plaintext
fn main (params=0, locals=2, regs=8):
  bb0:
    %r0 = const_str  "Hello, world!"
          arg        %r0, 0
    %r1 = call       @io.println, argc=1
    %r2 = const_int  0
          ret        %r2

Supports multi-module files (with imports) — resolves dependencies and compiles the full module graph before dumping.

Combining tools

bash
tape tokens file.tape | less              # page through tokens
tape ast file.tape > ast_dump.txt         # save AST for review
tape disasm file.tape --filter main       # disasm only "main"
tape disasm file.tape --all               # see everything including stdlib
tape deps file.tape                       # check import resolution

Last modified: