Registry / testing / parser-tml

parser-tml

JSON →
library2.0.6jsnpmunverified

A parser for Turing Machine Language (TML) programs. Version 2.0.6 ships TypeScript types and provides both synchronous and streaming parsing. It is actively maintained with regular releases. Key differentiators include a callback-based parsing API and support for reading TML from files or strings. The package is designed for educational and experimental use in simulating Turing machines.

npm install parser-tml
INSTALL
IMPORT
SIG · PARSER-TML
P
parser-tml
testingjavascriptv2.0.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Parser
import { Parser } from 'parser-tml'
import Parser from 'parser-tml'
Parser is a named export, not a default export.
parse
import { parse } from 'parser-tml'
const { parse } = require('parser-tml')
The package is ESM-only; CommonJS require does not work.
TMLProgram
import type { TMLProgram } from 'parser-tml'
import { TMLProgram } from 'parser-tml'
TMLProgram is a type export for TypeScript, not a runtime value.

Parses a TML program from a string using the streaming parser with callbacks, and alternatively uses the simple parse function.

import { Parser } from 'parser-tml'; import { readFileSync } from 'fs'; const source = readFileSync('program.tml', 'utf-8'); const parser = new Parser(); parser.on('instruction', (inst) => { console.log(inst); }); parser.on('end', () => { console.log('Parsing complete'); }); parser.parse(source); // Alternatively, use parse() for a simple string result: import { parse } from 'parser-tml'; const result = parse('start: read -> write, move'); console.log(result);
Debug
Known issues
breakingThe synchronous parse() function in v2.0.0 returns an object instead of a string.
fix
Update code to expect an object with parsed structure instead of a raw string.
affects: >=2.0.0
gotchaParser.parse() method is asynchronous and expects callbacks; using it synchronously will cause errors.
fix
Attach event listeners before calling .parse() on the Parser instance.
affects: >=1.0.0
deprecatedThe 'instruction' event from Parser is deprecated in favor of 'step' event.
fix
Change event name from 'instruction' to 'step'.
affects: >=2.0.0
Errors
Common errors & fixes
SyntaxError: Unexpected token
Invalid TML syntax in input string.
fix
Validate the TML program against the TML specification before parsing.
TypeError: parser.parse is not a function
Importing Parser incorrectly (e.g., as default import).
fix
Use named import: import { Parser } from 'parser-tml'
Error: Cannot find module 'parser-tml'
Package not installed or not in node_modules.
fix
Run npm install parser-tml
Upgrade
Version history
2.0.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
parser-tml — npm install parser-tml · libregistry