Skip to content

A toy tree walking interpreter πŸŒ²πŸšΆπŸ»β€β™‚οΈ

License

Notifications You must be signed in to change notification settings

nankeen/sauvignon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

47 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Sauvignon

CI lint & build GitHub last commit GitHub GitHub code size in bytes

ForTheBadge powered-by-electricity ForTheBadge made-with-crayons

Sauvignon is a tree walking interpreter written in Rust.

Building

Rust 2018 is required to compile this project. Currently, there are no additional dependencies.

$ cargo build

Quick start syntax

Start the REPL using

$ cargo run

or

$ cargo build
$ ./target/debug/sauvignon

Data Types

Supported data types

  • Integer
  • Boolean
  • String

Mathematical expressions

Do integer arithmetic using +, -, *, and /.

(3+2) * 3
(6 - 1) / 5
20 / 4 - 5

Variable binding

Objects can be assigned to identifiers using let <ident> = <object>.

let thirty = 30;

Functions

Declare functions using the fn keyword.

let add = fn (a, b) {
   return a + b
}

After declaring, you can call the functions.

add(5, 2)

Conditionals

Conditional control flow can be achieved using if statements.

let a = 5;
if ( a != 5 ) {
  return false;
} else {
  return true;
}

String

String concatenation works using the + infix operator.

"I like " + "CHEESECAKE!"

TODO:

  • Basic Lexer
  • Extended Lexer
  • REPL
  • AST constructor
  • Parser
  • Internal object system
  • Evaluator
  • Built-in functions
  • Arrays
  • Hash maps
  • Module import

About

A toy tree walking interpreter πŸŒ²πŸšΆπŸ»β€β™‚οΈ

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages