scala-0.1.0 has been yanked.
scala
A Scala language implementation written in Rust. An interpreter for a practical subset of Scala, featuring type inference, pattern matching, classes, traits, and a REPL.
Features
- Lexer & Parser — Full tokenization and recursive-descent parsing of Scala syntax
- AST — Typed abstract syntax tree with source location tracking
- Type System — Type checking with local type inference, generics, and trait resolution
- Interpreter — Tree-walking evaluator with environments and closures
- REPL — Interactive read-eval-print loop with multi-line input
- Standard Library — Built-in types:
Int,Long,Double,Float,Boolean,String,Unit,List,Map,Option,Tuple
Supported Scala Subset
// Variables
val x = 42
var y = "hello"
y = "world"
// Functions
def add(a: Int, b: Int): Int = a + b
def greet(name: String): Unit = println(s"Hello, $name!")
// Classes and Traits
(val radius: Double) extends Shape
// Case classes and pattern matching
(x: Int, y: Int)
def describe(p: Point): String = p match
// Collections
val nums = List(1, 2, 3, 4, 5)
val doubled = nums.map(_ * 2)
val sum = nums.foldLeft(0)(_ + _)
// For-comprehensions
val evens = for {
n <- nums
if n % 2 == 0
} yield n
// String interpolation
val name = "Scala"
println(s"Hello from $name!")
Building
Running
# Run a Scala file
# Start the REPL
# Check types only
Running Tests
Project Structure
scala/
├── src/
│ ├── main.rs # CLI entry point
│ ├── lib.rs # Library root
│ ├── lexer.rs # Tokenizer
│ ├── token.rs # Token types
│ ├── ast.rs # Abstract Syntax Tree
│ ├── parser.rs # Recursive-descent parser
│ ├── ty.rs # Type representation
│ ├── typechecker.rs # Type checking & inference
│ ├── interpreter.rs # Tree-walking evaluator
│ ├── repl.rs # Interactive REPL
│ ├── env.rs # Environment / scoping
│ ├── value.rs # Runtime values
│ └── stdlib.rs # Built-in functions & types
├── tests/ # Integration tests
├── SPEC.md # Language specification
├── TODO.md # Implementation roadmap
└── ARCHITECTURE.md # Architecture design
License
MIT