Registry / serialization / iota-compiler

iota-compiler

JSON →
library0.2.3jsnpmunverified

Io-to-JavaScript source-to-source compiler, version 0.2.3. Originally written for CodeCombat's parser challenge, now used in CodeCombat via Aether. Compiles a minimal subset of Io (messages, objects, methods, prototype chain, infix operators) into JavaScript. Dependencies include Escodegen for code generation and Jison for parsing. The project is in early development; many core constructs and standard library features are missing. Differentiators: direct JavaScript interop, AST conforms to Mozilla Parser API, CLI and library usage.

npm install iota-compiler
INSTALL
IMPORT
SIG · IOTA-COMPILER
I
iota-compiler
serializationjavascriptv0.2.3
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.

default
import iota from 'iota-compiler'
const iota = require('iota-compiler')
ESM import works with bundlers; CJS require also supported but ESM preferred.
parse
import { parse } from 'iota-compiler'
Named export for parsing Io code to AST.
compile
import { compile } from 'iota-compiler'
Named export for compiling Io code to JavaScript string.
eval
import { eval } from 'iota-compiler'
import ev from 'iota-compiler' then ev.eval()
Named export, but avoid shadowing global eval; use iota.eval() or alias.

Shows basic usage of iota eval and compile with Io code to compute a greeting.

import iota from 'iota-compiler'; const ioCode = ` greet := method(name, "Hello, " .. name ) greet("World") `; // Evaluate with convenience method const result = iota.eval(ioCode); console.log(result); // Output: "Hello, World" // Or compile and run manually const compiled = iota.compile(ioCode); eval(compiled);
iota --version
Debug
Known issues
gotchaOnly a minimal subset of Io is implemented; many standard library methods and constructs are missing.
fix
Check the 'Still to come' list in README; avoid using unsupported features.
affects: *
gotchaThe runtime library binding `_io` is required for manual eval; default export's `lib` property must be available.
fix
Always include `var _io = iota.lib;` before calling `eval(iota.compile(code))`.
affects: *
gotchaOptions like `wrapWithFunction` and `useProxy` change the output format; default is standalone code that may pollute global scope.
fix
Set `wrapWithFunction: true` to run within a function context, preventing global leaks.
affects: *
Errors
Common errors & fixes
ReferenceError: _io is not defined
Missing runtime library when manually evaluating compiled JavaScript.
fix
Add `const _io = require('iota-compiler').lib;` before `eval(iota.compile(code))`.
TypeError: iota.eval is not a function
Using older import style (e.g., `import * as iota from 'iota-compiler'`)
fix
Use default import: `import iota from 'iota-compiler'` or `const iota = require('iota-compiler')`.
SyntaxError: Unexpected token
Io code contains unsupported constructs like 'self' or first-class primitive methods.
fix
Review supported features; avoid using 'self' or unsupported operators.
Upgrade
Version history
0.2.3latest on npm
Audit
Dependencies
escodegenrequiredJavaScript code generation from AST
Agent activity
8 hits · last 30 days
node
6
Amazon
1
Resources
iota-compiler — npm install iota-compiler · libregistry