monke

command module
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 10 Imported by: 0

README

monke logo (generated by Google Gemini)

Monke

Made with Go Platform GitHub go.mod Go version GitHub Actions CI test License


Monke is a simple, interpreted programming language implemented in Go.

This project is inspired by the book "Writing An Interpreter In Go" by Thorsten Ball.

It features a REPL (Read-Eval-Print Loop), a lexer, parser, AST, and an evaluator, all written from scratch.

Features

  • Lexer: Tokenizes input source code.
  • Parser: Builds an Abstract Syntax Tree (AST) from tokens.
  • AST: Represents the structure of parsed code.
  • Evaluator: Executes the AST, supporting variables, functions, and basic data types.
  • REPL: Interactive shell for running Monke code.
  • Built-in Functions: Includes basic built-in functions for convenience.

Getting Started

Prerequisites

  • Go 1.25 or newer

Installation

To install Monke, you can either clone the repository and build it yourself or install it directly using Go.

Option 1: Install with Go
go install github.com/dr8co/monke@latest
Option 2: Clone and Build
  1. Clone the repository:

    git clone https://github.com/dr8co/monke.git
    cd monke
    go build -o monke
    
  2. Run the binary:

     ./monke
    

You should see a prompt where you can enter Monke code interactively.

For more details and examples, check the documentation.

Project Structure

  • main.go — Entry point, starts the REPL.
  • cmd/profile/ — Profiling tool for performance analysis.
  • lexer/ — Lexical analyzer (tokenizer).
  • parser/ — Parser for Monke language.
  • ast/ — Abstract Syntax Tree definitions.
  • object/ — Object system and environment.
  • evaluator/ — Evaluates the AST.
  • repl/ — REPL implementation.
  • token/ — Token definitions.
  • docs/ — Documentation and tasks.

Example Usage

>> let x = 5;
>> x + 10;
15
>> fn add(a, b) { a + b; }
>> add(2, 3);
5

Testing

To run the tests:

go test ./...

Profiling

Monke includes a profiling tool to analyze performance:

# Build and run the profiling tool
cd cmd/profile
go build
./profile

For more details on profiling options and available test programs, see the profiling tool README.

Contributing

Contributions are welcome! Please open issues or submit pull requests for improvements or bug fixes. See CONTRIBUTIONS.md for guidelines.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Documentation

Overview

Monke is a simple programming language written in Go.

Directories

Path Synopsis
Package ast defines the Abstract Syntax Tree (AST) for the Monke programming language.
Package ast defines the Abstract Syntax Tree (AST) for the Monke programming language.
cmd
profile command
Command profile runs a Monkey program and measures its execution time.
Command profile runs a Monkey program and measures its execution time.
Package evaluator implements the evaluation logic for the Monke programming language.
Package evaluator implements the evaluation logic for the Monke programming language.
Package lexer implements the lexical analyzer for the Monke programming language.
Package lexer implements the lexical analyzer for the Monke programming language.
Package object defines the object system for the Monke programming language.
Package object defines the object system for the Monke programming language.
Package parser implements the syntactic analyzer for the Monke programming language.
Package parser implements the syntactic analyzer for the Monke programming language.
Package repl implements the Read-Eval-Print Loop for the Monke programming language.
Package repl implements the Read-Eval-Print Loop for the Monke programming language.
Package token defines the token types and structures for the Monke programming language.
Package token defines the token types and structures for the Monke programming language.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL