This project implements a compiler for the Monkey programming language, written in Go. The Monkey language is a simple, interpreted programming language designed for educational purposes.
The entry point of the application. It sets up a REPL (Read-Eval-Print Loop) for interactive use of the Monkey language.
Defines the structure of tokens and their types. Tokens are the smallest units of meaning in the language, such as keywords, identifiers, and operators.
The lexical analyzer that breaks down the input source code into a series of tokens. It implements the following key functions:
New(input string): Creates a new Lexer instance.NextToken(): Reads the next token from the input.readChar(): Advances the lexer to the next character.readIdentifier(): Reads an identifier from the input.readNumber(): Reads a number from the input.
Implements a Read-Eval-Print Loop for interactive use of the Monkey language. It repeatedly:
- Prompts the user for input.
- Lexically analyzes the input using the Lexer.
- Prints out the resulting tokens.
Contains unit tests for the Lexer to ensure it correctly tokenizes various inputs.
Contains detailed explanations of the compiler's phases, including:
- Lexical Analysis
- Syntax Analysis
- Semantic Analysis
- Intermediate Representation Generation
- Optimization
- Code Generation
- Code Linking and Assembly
As of now, the project implements the lexical analysis.