All Projects → cjneidhart → lua-in-rust

cjneidhart / lua-in-rust

Licence: MIT license
The Lua programming language, implemented in Rust.

Programming Languages

rust
11053 projects
lua
6591 projects

Projects that are alternatives of or similar to lua-in-rust

tiny-lang
tiny-lang — A different programming language. Supports a bunch of spoken languages.
Stars: ✭ 26 (-65.79%)
Mutual labels:  compilers, interpreters
types-and-programming-languages
C++ Implementations of programming languages and type systems studied in "Types and Programming Languages" by Benjamin C. Pierce..
Stars: ✭ 32 (-57.89%)
Mutual labels:  compilers, interpreters
compiler-course-unipi
Lab of the course Languages, Compilers and Interpreters (Cod. 653AA) @ UNIPI
Stars: ✭ 18 (-76.32%)
Mutual labels:  compilers, interpreters
kolasu
Kotlin Language Support – AST Library
Stars: ✭ 45 (-40.79%)
Mutual labels:  compilers, interpreters
AwesomeCompiler
The Big list of the github, open-source compilers.
Stars: ✭ 27 (-64.47%)
Mutual labels:  compilers
go-recipes
🦩 Tools for Go projects
Stars: ✭ 2,490 (+3176.32%)
Mutual labels:  compilers
Cpplinks
Being a part of a few C++ communities, I happen to run across some interesting links -- this is an attempt to categorize them. Thanks to Saurabh Malpani from "C++ Enthusiasts" for the suggestion.
Stars: ✭ 2,935 (+3761.84%)
Mutual labels:  compilers
Writing A Compiler In Ruby
Code from my series on writing a Ruby compiler in Ruby
Stars: ✭ 229 (+201.32%)
Mutual labels:  compilers
pyCompiler
Python Compiler
Stars: ✭ 13 (-82.89%)
Mutual labels:  compilers
sai
Staged Abstract Interpreters
Stars: ✭ 58 (-23.68%)
Mutual labels:  interpreters
LL-Script
Simple script
Stars: ✭ 38 (-50%)
Mutual labels:  compilers
suicide
LLVM pass that detects one undefined behavior, and emits code to delete your hard drive
Stars: ✭ 33 (-56.58%)
Mutual labels:  compilers
jet
A Fast C and Python like Programming Language that puts the Developer first. WIP
Stars: ✭ 41 (-46.05%)
Mutual labels:  compilers
qcor
C++ compiler for heterogeneous quantum-classical computing built on Clang and XACC
Stars: ✭ 78 (+2.63%)
Mutual labels:  compilers
Never
Never: statically typed, embeddable functional programming language.
Stars: ✭ 248 (+226.32%)
Mutual labels:  compilers
build-anywhere
Scripts for building compilers that run anywhere, which build things that run anywhere
Stars: ✭ 72 (-5.26%)
Mutual labels:  compilers
Cs6120
advanced compilers
Stars: ✭ 232 (+205.26%)
Mutual labels:  compilers
Decaf-Compiler
Compiler for Decaf Programming Language
Stars: ✭ 36 (-52.63%)
Mutual labels:  compilers
UniversalQCompiler
Synthesizing arbitrary quantum computations
Stars: ✭ 53 (-30.26%)
Mutual labels:  compilers
save
Universal test framework for cli tools [mainly for code analyzers and compilers]
Stars: ✭ 33 (-56.58%)
Mutual labels:  compilers

lua-in-rust

The Lua programming language, implemented in Rust.

Overview

The code is primarily grouped into three modules:

  • compiler deals with parsing lua code and converting it into bytecode.
    • lexer converts Lua source code into tokens.
    • parser converts those tokens into bytecode.
    • exp_desc and token are type definitions.
  • vm is the largest module. It deals with actually evaluating lua code, and the Rust API.
    • vm itself holds the core functionality of the interpreter.
    • frame deals with evaluating bytecode.
    • lua_val defines the type for values in the VM.
    • object deals with garbage collection.
    • table implements Lua tables.
  • lua_std is where any functions in the lua standard library are implemented.
  • Other modules:
    • error defines the Error type used throughout the crate.
    • instr defines the VM's instruction set.
    • lib and main are the basic entrypoints for the library/interpreter.

Goals

The goals, in rough order of priority, are:

  • Basic comparisons and equality
  • and/or expressions with proper short-circuiting
  • Basic strings
  • if/else/elseif
  • while and repeat ... until loops
  • Local variables with proper scoping
  • Numeric for loops
  • Multiple assignment
  • Single-line comments
  • Function calls
  • Function definition
  • Tables
  • Garbage Collection
  • Full table literals
  • Error when line starts with left paren and parses as function call
  • Multiple return values
  • break and continue
  • Interned strings
  • Unparenthesized function calls
  • Better error messages
  • Closures
  • Lua's next function
  • Generic for loops
  • Metatables
  • Separate array part of tables for integer keys
  • Lua's standard library
  • A Rust API to parallel Lua's C API
  • Coroutines
  • Multi-line comments
  • Use actual bytecode with variable-length instructions
  • Separate luac executable

Building

Like the real Lua, this project currently has zero dependencies. Just run cargo run in the root to launch the interpreter.

Debug options

There are a few environment options which enable debug features. These are all disabled by default. To enable an option, just set it in the environment before compiling (e.g. export LUA_DEBUG_VM=1; cargo build). For details on a debug option, look in the corresponding module.

The options are:

  • LUA_DEBUG_PARSER
  • LUA_DEBUG_VM
  • LUA_DEBUG_GC
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].