A compiler and interpreter project written in Go and inspired by the books Writing A Compiler In Go and Writing An Interpreter In Go by Thorsten Ball.
Corrosion inherits a few language syntax styles. Some examples:
// Syntax examples
var foo = 100;
func add(left, right) { return left + right; }
add(foo, foo); // 200
func conditional(check) {
if (!check == true) {
return true;
} else {
return false;
}
}
conditional(); // false
func foo() {
func bar() { return 2; }
return bar;
}
foo()(); // 2
git clone https://github.com/freddiehaddad/corrosion
go build -o bin ./...
go test -v ./...
After building the code, the REPL can be launched with:
./bin/corrosion
Go (see go.mod for minimum version) is required for building. In general, any recent version should work.
.
├── bin
│ └── corrosion
├── cmd
│ └── corrosion
│ └── corrosion.go
├── go.mod
├── LICENSE
├── pkg
│ ├── ast
│ │ └── ast.go
│ ├── evaluator
│ │ ├── evaluator.go
│ │ └── evaluator_test.go
│ ├── lexer
│ │ ├── lexer.go
│ │ └── lexer_test.go
│ ├── object
│ │ └── object.go
│ ├── parser
│ │ ├── parser.go
│ │ └── parser_test.go
│ └── token
│ └── token.go
└── README.md
Licensed under the MIT license.