16 stable releases

new 1.5.1 Jun 19, 2024
1.5.0 Jun 2, 2024
1.4.0 Mar 26, 2024
1.3.2 Nov 4, 2023
0.1.1 Aug 9, 2023

#77 in Programming languages

Download history 3/week @ 2024-03-02 2/week @ 2024-03-09 124/week @ 2024-03-23 29/week @ 2024-03-30 4/week @ 2024-04-06 1/week @ 2024-04-27 4/week @ 2024-05-04 4/week @ 2024-05-18 153/week @ 2024-06-01 12/week @ 2024-06-08 225/week @ 2024-06-15

391 downloads per month

MIT license

245KB
5K SLoC

Phoenix

Programming Language

Based on the book Crafting Interpreters and this repo

Features

  • Dynamic typing
  • Automatic memory management
  • Garbage collection
  • First-class functions
  • Closures
  • Lexical scoping
  • Tail recursion
  • Pattern matching
  • Algebraic data types
  • Inheritance
  • API for native functions written in Rust

Usage

  • To start the program run:
cargo run -- --help
  • To install phoenix run:
cargo install --path .

Then you can run phoenix with:

phoenix --help

Examples

fun binary_search(list, item) {
  var low = 0;
  var high = list.len() - 1;

  while low <= high {
    var mid = (low + high) / 2;
    var guess = list[mid];
    printf("low: {}, high: {}, mid: {}, guess: {}", low, high, mid, guess);

    if guess == item {
      return mid;
    } else if guess > item {
      high = mid - 1;
    } else {
      low = mid + 1;
    }
  }
  return nil;
}

var elements = [1, 3, 5, 7, 9];
var search = 7;
printf("element {} is at index: {}", search, binary_search([1, 3, 5, 7, 9], 7));

TODO

  • Add more examples
  • Add more tests
  • Add more documentation
  • Add more error handling
  • Fix lists (not working: access of lists in classes eg: c.l[0] = 1;)
  • Fix REPL
  • Fix modules (not working: classes)
  • Implement [+-*/]=, i++ and i--
  • Better "api" for native functions
  • Add LLVM support

Dependencies

~5–14MB
~157K SLoC