Skip to content

abhinav1912/rust-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Interpreter/Compiler in Rust

Create a compiler to parse, evaluate and execute a simple programming language (also custom defined).

Feature set

  • Create a simple language which supports common features such as
    • Variable bindings
    • Arithmetic expressions
    • Functions
    • Strings/Arrays
  • Create an interpreter to parse the source code, including
    • Lexer
    • Parser
    • Abstract Syntax Tree
    • Evaluator for AST
  • Bytecode compiler and virtual machine to execute bytecode

Supported data-types:

  • Booleans
  • Numerals
    • Ints
    • Floats
  • Strings
  • Hash/Dictionary (dynamically typed)

Example of supported programming statements/expressions:

let x = 10; // identifiers
let y = {"key1": "str", "key2": 5}; // dictionary, string

x + 20; // arithmetic, accessing variables
fn compare(a, b) {
    a == b
} // function declaration, comparison operators
compare(3.0, 3.1) // function invokation, floats

Installation

  1. Clone the repository
  2. Install Rust using the steps mentioned here.
  3. Run the project using the following possible commands:
// to run in Compile mode
cargo run compile
// OR, run in Evaluator mode
cargo run eval

About

Rust powered compiler to parse, evaluate and execute a simple programming language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages