The @ Language

A tiny programming language interpreter

Documentation

The main language of this project is still Bau. This here is an experimental language.
  • Minimalistic syntax. Tiny footprint (~450 lines of code).
  • Operator overloading is supported.
  • Ability to minify the code. Each keyword has a single-character shortcut: ? if, : else, * repeat, @ while, + fun, = return, > print.
  • This is also useful for code golfing, and writing programs on the command line, or on a phone.
  • Assignment uses :, and = for comparison.
  • Global variables and constants start with a capital letter.
  • Text literals start and end with '. As in SQL, the only escape character is '' for '. Use free-standing text literals as comments.
  • Commas and semicolons are optional.
  • & and | are logical and bitwise "and" and "or".
  • Arrays of floating point are the only data type.
  • Array indexing uses . instead of [].
  • Zero error philosophy: out-of-bounds array access returns 0, except for entry -1 which returns the length.
  • Text has at least two elements (zero values are ignored).

Why?

  • Low footprint command line programmable calculator
  • Code golfing
  • Language design experiment
  • Educational tool for learning interpreter design
  • Embedded scripting with minimal dependencies
  • Sandboxed execution of user-submitted code
  • Prototyping new language features
  • Resource-constrained environments

Grammar

<program> := <definition> | <expr> ";" ... <definition> := "fun" <id> "(" <id> ... ")" <block> <block> := "{" <expr> [ ";" ... ] "}" <expr> := <primary> | <expr> <op> <expr> <primary> := <literal> | <id> | <call> | <if> | <loop> | <return> | "(" <expr> ")" | "-" <primary> <if> := "if" <expr> <block> [ "else" <block> ] <loop> := ( "while" | "repeat" ) <expr> <block> <return> := "return" <expr> <call> := <id> "(" { <expr> [ "," ... ] } ")" <literal> := digits [ "." digits ] | "'" characters "'" <op> := ":" | "." | "*" | "/" | "%" | "+" | "-" | "=" | "<" | ">" | "<>" | "<=" | ">=" | "&" | "|" <id> := letter { letter | digit | "_" }