Lightweight Python interpreter in Rust.
Go to file
hkau 74352a5118 [fix] conditionals
TODO: conditionals (second layer and beyond)
2024-04-02 21:38:00 -04:00
src [fix] conditionals 2024-04-02 21:38:00 -04:00
.gitignore [add] interpret: in-place reassignment 2024-02-09 21:20:17 -05:00
Cargo.toml [add] modules::fs 2024-02-22 17:38:32 -05:00
LICENSE Initial 2024-01-25 20:00:23 -05:00 [add] modules::standard::require 2024-02-18 22:38:20 -05:00

🔮🐍 Amethystine

Amethystine (named after the "Amethystine Python") is a lightweight interpretter for a mix of Python and Lua written in Rust. It interprets an AST tree generated by a PEG parser.

Documentation is available at, and can be built locally with cargo doc --no-deps --document-private-items.


amethystine (flags)
amethystine input.lua (flags) # experimental


The Amethystine CLI supports the following flags:

  • --benchmark: log the time between interpretation start and end
  • --ast: log the generated AST to the standard output
  • --text: log the modified text content to the standard output (logs before parsing begins)


Amethystine currently supports the following language features:

  • Variable declaration
  • Function declaration
    • All blocks that are expected to contain body content consisting of other blocks are transformed to contain an ending block during parsing. This block can be manually inserted by adding end after your function/conditional
  • Basic standard functions
    • The type function will return types defined in the grammar file, not Python types (example: string, number, null)
  • (QUICK_CONDITIONAL_IF) Mathematical operations
  • Conditional blocks
  • table values

The features below are planned:

  • for/while loops
  • Support for & (AND) and | (OR) in QUICK_CONDITIONAL_IF
  • Module importing
    • Imported modules will have a RETURN statement at the end, which will be read by the interpreter (reading the value of the return variable)

Amethystine supports the following datatypes:

  • bool
  • string
  • number
  • null
  • array
  • tuple
  • table
  • any

Amethystine also supports using Lua-like syntax as well as Python-like syntax:

# python input
x = "Hello, world!"

def log(y):


# read as
x = "Hello, world!"

def log(y):


-- lua input
local x = "Hello, world!"

function log(y):


-- read as
x = "Hello, world!"

function log(y):


Standard Library

Standard library documentation available at The provided methods and functions differ greatly from Python and Lua in some specific areas, so reading the documentation is advised.