Skip to content

zaknesler/inty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

inty

Basic interpreter written in Rust, not following any particular guides or languages. This is just a fun little project and is not too serious, but all the tests pass. It uses a basic recursive descent parser, but I would like to rewrite it using a grammar such as pest.rs or a parser combinator like nom.

Features

  • Arithmetic, e.g. 3 + 4 * 2
  • Boolean operations, e.g. true || !false
  • Relational operations, e.g. 4 >= 3
  • Variable assignment, e.g. let x = 3
  • Scoping, e.g. { let x = 3; x } => 3
  • Shadowing, e.g. { let x = 3; { let x = 4 }; x } => 3
  • Branching, e.g. if 4 >= 3 then { 1 } else { 2 }
  • Lists, e.g. [0, 1, 2, 3]

Eventually

  • Statements as expressions, e.g. if and { } (not doing this was just an oversight)
  • Variable re-assignment, e.g. { let x = 3; x = 4; x } => 4
  • Pre/post-fix operations, e.g. { let x = 1; x++; --x; x += 2; x } => 3
  • Loops, e.g. for x in [0, 1, 2, 3] { x } or for x = 0; x <= 5; x += 1 { x }
  • Functions, e.g. { fn foo(x) { x + 3 }; foo(1) } => 4

About

A basic interpreter written in Rust

Resources

Stars

Watchers

Forks

Languages