An interpreter for a subset of the Go programming language, written in Ocaml. This project implements parsing, type checking and inference, evaluation of Go-like code.
- Basic data types:
int,bool,string - Loops:
for - Conditional statements:
if-else - Arrays: accesing elements by indicies
- Regular functions
- Recursive functions
- Closures
- Unbuffered channels:
receive(extract from channel)send(put into channel)closechannel
- Goroutines:
- Lightweight threads
- Context switching on channel operations
breakfuncdefergochanifelsecontinueforreturnvar
truefalsenilmakecloselenpanicprintprintlnrecover
- Parser: Builds Abstract Syntax Tree (AST) from Go source code
- Typechecker : Checks all expressions' types and inferences variable types
- Evaluator: Executes the parsed AST
- REPL: Read-Eval-Print Loop for interactive interpretation
dune exec bin/interpret.exe <options> <filepath>--astDump abstract syntax tree of a program--typecheckTypecheck the program and print result
If filepath isn't specified, REPL will start running and the program will be read from standard input. In REPL mode type:
quit- to quit REPL modehelp- to display help message
- OCaml 4.14+
- Dune 3.8+