Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>TableSmithNew to Visual Studio Code? Get it now.
TableSmith

TableSmith

srejv

| (0) | Free
Generate and refresh LUTs from comment directives in C, C++, Rust, JavaScript, TypeScript, and Python.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

TableSmith

Generate lookup tables directly inside your source files from compact comment directives.

TableSmith keeps LUT generation close to the code that consumes it, and can replace an existing generated table in place when the expression changes.

Supported targets today are C, C++, Rust, JavaScript, TypeScript, and Python.

Why TableSmith?

  • Keep generated constant data checked into source control.
  • Regenerate tables without switching to an external script or build step.
  • Use one directive format across multiple languages.
  • Fit embedded, DSP, graphics, parsing, and general precomputed-data workflows.

Features

  • Generate lookup tables from a compact inline directive.
  • Regenerate existing tables without touching unrelated code.
  • Use the active editor language to choose the output form.
  • Support iterator controls such as start, step, and end.
  • Evaluate expressions with a built-in safe math parser rather than arbitrary JavaScript execution.

Quick start

Add a directive comment immediately above the table you want to generate, then run TableSmith: Regenerate LUTs from the command palette.

Common use cases:

  • Sine, cosine, and waveform tables
  • Gamma correction tables
  • Quantization tables
  • CRC or parser lookup tables
  • Precomputed coefficient tables

Example in C or C++:

// @lut uint8_t sine[16]; round((sin((i / 15) * PI * 2) * 0.5 + 0.5) * 255)
uint8_t sine[16] = {
    128, 176, 218, 245, 255, 245, 218, 176,
    128, 79, 37, 10, 0, 10, 37, 79
};

Example in Python:

# @lut gamma[8]; round(pow(i / 7, 2.2) * 255)
gamma = [
    0, 5, 21, 50, 93, 151, 223, 255
]

Directive format

Supported forms:

// @lut TYPE NAME[SIZE]; EXPRESSION; CAST_TYPE; start=0, step=1, end=63
# @lut NAME[SIZE]; EXPRESSION; start=0, step=1, end=63

Rules:

  • @lut is optional, but recommended.
  • TYPE NAME[SIZE] is used for typed targets such as C, C++, and Rust.
  • NAME[SIZE] is used for untyped targets such as JavaScript and Python, and is also valid in TypeScript.
  • CAST_TYPE is optional and supported for C, C++, and Rust outputs.
  • start, step, and end are optional iterator controls.
  • When end is present, the generated iterator must still produce exactly SIZE values.

Expression support

Expressions can reference:

  • i
  • index
  • size
  • start
  • step
  • end
  • PI
  • E
  • Infinity
  • NaN

Supported functions include:

  • sin, cos, tan
  • asin, acos, atan
  • abs, round, floor, ceil
  • min, max, pow, sqrt, log, exp, clamp

Math.sin(...) style expressions are also accepted and normalized automatically.

Generated output by language

  • c: TYPE name[SIZE] = { ... };
  • cpp: static constexpr TYPE name[SIZE] = { ... }; by default
  • rust: const name: [TYPE; SIZE] = [ ... ];
  • javascript: const name = [ ... ];
  • typescript: const name: TYPE[] = [ ... ]; when a type is present
  • python: name = [ ... ]

If a generated table already exists directly under the directive, TableSmith replaces it. If no table exists yet, TableSmith inserts one.

Settings

  • tablesmith.cppDeclarationPrefix: Prefix applied to generated C++ LUTs. Default: static constexpr.

Notes and limitations

  • Generated output style is chosen from the active editor language.
  • The current C++ output uses raw arrays; std::array is not yet implemented.
  • Expressions must evaluate to finite numbers.

Repository

  • Source: github.com/srejv/table-smith
  • Issues: github.com/srejv/table-smith/issues

Development

npm install
npm test
npm run package

Press F5 in VS Code to launch an Extension Development Host.

Publishing

Typical publish flow:

  1. Create or verify your Visual Studio Marketplace publisher.
  2. Authenticate vsce with a personal access token.
  3. Run npm run package to create a .vsix.
  4. Run npm run publish to publish the extension.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft