@ascent-lang/dev
v0.20.0
Published
The Ascent teaching language: CLI and interpreter for running and embedding .asc programs.
Downloads
3,420
Maintainers
Readme
Ascent: The Teaching Language
Ascent is a programming language built to teach programming to complete beginners. The goal is to do it clearly, gently, and from the ground up.
⚠️ Experimental
@ascent-lang/dev is an experimental package intended for rapid development and language exploration.
During this phase, the language syntax, parser, interpreter, APIs, and project structure may change frequently between releases. Breaking changes may occur at any time, and version numbers should not be interpreted as indicators of API stability.
This package is primarily intended for:
- experimenting with new language features,
- testing language design ideas,
- early adopters interested in following development.
Once the language and architecture mature, functionality will be split into dedicated packages such as @ascent-lang/parser, @ascent-lang/interpreter, and @ascent-lang/core, which will follow a more stable versioning and compatibility policy.
Until then, expect frequent changes and be prepared to update your code when upgrading to newer releases.
Installation
npm install -g @ascent-lang/devOr run it once without installing:
npx @ascent-lang/dev path/to/program.ascUsing the CLI
Run a .asc file:
ascent program.ascIf the program declares args, pass them as flags:
ascent program.asc --name Ada --score 95Start the interactive REPL by running ascent with no file:
ascentUsing it as a library
The individual pipeline stages are exported from the package entry point, so you can lex, parse, type-check, and interpret Ascent source from your own tooling:
import { parse, executeProgram } from '@ascent-lang/dev';
const { program } = parse('1 + 2');
const result = executeProgram(program);
console.log(result); // { type: 'Int', value: 3n }executeProgram creates its own Environment. If the program declares
args, build a ProgramInputs from that program's args and pass it as
the second argument. ProgramInputs.set rejects a name that isn't one of
the program's declared args, or a value that doesn't match that arg's
declared type:
import { parse, executeProgram, ProgramInputs } from '@ascent-lang/dev';
const { program } = parse('args (name: String); name');
const inputs = new ProgramInputs(program.args).set('name', { type: 'String', value: 'Ada' });
const result = executeProgram(program, inputs);