Skip to content

Reduce common errors in generative models: incorrect imports, fuzzy asynchrony, unexpected nulls, side effects, ambiguous typing, uncertain evaluation order, and missing tests

License

Notifications You must be signed in to change notification settings

alessbarb/IntentLang

IntentLang

IntentLang (IL) is an early experiment with a minimal parser, type checker and TypeScript transpiler.

Packages

  • @intentlang/core – parser, AST, checker and runtime helpers.
  • @intentlang/cli – command‑line interface intent for checking and building IL files.
  • @intentlang/examples – canonical examples and golden tests.

Getting started

  1. Install dependencies:
    pnpm install
  2. Run the test and lint suites:
    pnpm lint
    pnpm test
    pnpm -w typecheck
  3. Build all packages:
    pnpm -w build

Quick example

uses { random: Random { } }

func add(a: Int, b: Int): Int
  requires a >= 0 && b >= 0
  ensures _ >= a && _ >= b
{ return a + b; }

test add_works { let r = random.int(); }

For loops

Iterate over a list with a for statement:

for x in [1, 2, 3] { }

Deterministic runs

intent can produce reproducible outputs by seeding its runtime:

pnpm --filter @intentlang/cli intent test file.il --seed-rng 1 --seed-clock 0
pnpm --filter @intentlang/cli intent build file.il --seed-rng 1 --seed-clock 0

--seed-rng fixes the pseudo‑random generator; --seed-clock sets the initial time returned by the runtime clock.

Documentation

  • Web (Docusaurus): packages/docs → run pnpm docs:start or pnpm docs:build.
  • Spec/PDF (LaTeX): IntentLang-LaTex → run latexmk (uses LuaLaTeX).

Note: the legacy root docs/ folder is deprecated and kept for history. New content lives under packages/docs and the LaTeX spec includes sources directly from the repo.

Grammar and Parser Notes

  • The Tree‑sitter grammar enforces syntactic purity for pure_expr (no await, throw, or spawn) in contexts like meta.invariants and requires/ensures.
  • Optional chaining cannot be mixed with non‑optional chaining inside a single postfix chain (e.g. a?.b.c is not allowed).
  • Operator precedence follows the canonical EBNF: ?? binds looser than ||, which binds looser than &&, then bitwise, equality, relational, shift, additive, and multiplicative.
  • Numeric tokens are unsigned; unary - is parsed at the expression level.

To rebuild the parser WASM used by the VS Code extension:

pnpm --filter vscode-intentlang run build-parser

About

Reduce common errors in generative models: incorrect imports, fuzzy asynchrony, unexpected nulls, side effects, ambiguous typing, uncertain evaluation order, and missing tests

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •