Skip to content

devanknambiar/monolang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MonoLang

A statically-typed programming language and tree-walking interpreter built from scratch in Go.

MonoLang is a personal systems programming project focused on understanding how programming languages work internally. Instead of relying on parser generators or compiler frameworks, every stage of the language is being implemented manually—from lexical analysis to parsing, evaluation, and type checking.

The goal of this project is to gain a deeper understanding of compiler construction, language design, and runtime systems.

Online Interpreter/Playground

Interactive Playground: mono.monotake.com

Current Status

🚧 Active Development

Stage 1: The Lexer (Lexical Analysis)

  • Character Streaming & Position Tracking
  • Tokenizing Identifiers, Digits, & Symbols (=, +, -, !, *, /, ;, ==, !=)
  • Keyword Recognition (let, return, fn, true, false, if, else)

Stage 2: The Parser (Syntactic Analysis)

  • Abstract Syntax Tree (AST) Base Architecture
  • Statement Rules: let and return statements
  • Primitive Expressions: Identifiers, Integer Literals, Boolean Primitives
  • Prefix Operators: -x and !x
  • Infix Operators: +, -, *, /, ==, !=
  • Precedence Override: Grouped Parentheses (x + y)
  • Control Flow Blocks: if / else conditionals
  • Functional Syntax: Function definitions fn(x) {} and call expressions add(x)

Stage 3: The Evaluator (The Engine Room)

  • Object System: Creating internal wrappers for Integers, Booleans, and Functions
  • Tree-Walking Evaluation: Writing the core Eval(node AST) runner
  • Environment Management: Building a hash map memory store for variables
  • Function Stack: Handling scope, arguments, and return unwinding

Stage 4: Edge Deployment & Web Interface (WebAssembly Pipeline)

  • Wasm Interop Bridge: Building a dedicated execution gateway using Go's syscall/js layer.
  • Browser Compilation: Compiling the core engine into a client-side binary footprint (GOOS=js GOARCH=wasm).
  • Interactive IDE Interface: Crafting a highly responsive, polished React/Next.js playground panel featuring text workspaces and a virtual output terminal console.
  • Automated CI/CD Delivery: Building a GitHub Actions pull-based pipeline with a self-hosted runner to automatically build, extract runtime gluings, and update static assets on push.
  • Edge Network Optimization: Configuring Cloudflare Zero Trust secure paths and Nginx compression metrics (gzip_types application/wasm) for high-velocity edge stream execution.

Motivation

Programming languages are often treated as black boxes.

MonoLang is an attempt to understand every layer involved in language implementation by building each component from first principles.

Rather than focusing on performance, this project prioritizes readability, correctness, and learning.

Project Structure

monolang/
├── go.mod
├── main.go         
├── token/
│   └── token.go
├── lexer/
│   └── lexer.go
├── ast/
│   └── ast.go
├── parser/
│   └── parser.go
├── object/
│   └── object.go
├── evaluator/
│   └── evaluator.go
└── LICENSE

Note: The repository structure will evolve as additional compiler stages are implemented.

Tech Stack & References

  • Language: Go
  • Development Platform: Linux Core Systems / Darwin (macOS)
  • Testing Infrastructure: Native Go Unit Testing Framework

References

This project draws inspiration from several excellent resources on compiler and interpreter construction, while being implemented independently as a learning exercise.

  • Writing an Interpreter in Go — Thorsten Ball
  • Crafting Interpreters — Robert Nystrom
  • Compilers: Principles, Techniques, and Tools ("Dragon Book")

License

BSD 3-Clause License

About

Building a statically-typed tree-walking interpreter in Go featuring lexical analysis, parsing, AST evaluation, and an interactive web playground!

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages