Built a programming language from scratch in C. It has a lexer, parser, AST, bytecode compiler, stack VM, classes with inheritance, string interpolation, break/continue, compound assignment (+=), user modules, and a built-in static analyzer.
class Animal {
fn init(name, sound) {
self.name = name
self.sound = sound
}
fn speak() {
print self.name + " says " + self.sound
}
}
class Dog extends Animal {
fn init(name) {
super(name, "woof")
}
}
let d = Dog("Rex")
d.speak()
Learned more from this than from anything I've read. Compilers are not magic.
Source: github.com/aaka3h/lang
Top comments (0)