asomiya 0.2.0

JavaScript API

$ npm install asomiya

runSource

The simplest way: run a whole program and get everything it printed. Errors are returned, not thrown.

import { runSource } from 'asomiya';

const { output, error } = runSource('কোৱা(১০ + ২০)');
console.log(output); // "৩০\n"

runSource('kowa(10 + 20)').output; // "30\n"

Interpreter

For full control (streaming output, input, limits), use the interpreter directly:

import { Interpreter, parse, formatDiagnostic, AsomiyaError } from 'asomiya';

const source = 'কোৱা(সোধা("নাম? "))';
const interpreter = new Interpreter({
  write: (text) => process.stdout.write(text),
  readLine: () => 'ৰীতা',
  maxSteps: 1_000_000,
});

try {
  interpreter.run(parse(source));
} catch (e) {
  if (e instanceof AsomiyaError) {
    console.error(formatDiagnostic(e.diagnostic, { lang: 'en', source }));
  } else throw e;
}
OptionMeaning
write(text)Receives printed text
readLine()Supplies one line per সোধা call; null means end of input
maxStepsStep budget (default 10000000)
maxCallDepthCall depth limit (default 500)
digits"auto" (default), "assamese" or "ascii"

The package also exports the lexer (tokenize), parser (parse), the keyword glossary and the error catalogue. It is fully typed and ships ES modules for Node.js 20+.