About this project
MyOpl is an original interpreted programming language designed and implemented from the ground up in Java 25. The project includes a complete language pipeline — a hand-written lexer that tokenises source code, a recursive-descent parser that produces an abstract syntax tree, and a tree-walking interpreter that evaluates the AST.
The language supports a rich set of features: variables (VAR), first-class functions (FUN) with arrow-syntax bodies, control flow (IF/THEN/ELSE, FOR/TO/STEP, WHILE), lists, strings, numbers, single-line and multi-line comments, and BEGIN/END block scoping. It also includes user-defined classes with fields and methods accessed via dot notation, and an IMPORT system for loading external .myopl files.
MyOpl ships with built-in functions for console I/O (PRINT, INPUT, INPUT_NUM), file operations (READ_FILE, WRITE_FILE, APPEND_FILE), and list utilities (LEN). Programs can be executed either by running a .myopl source file or interactively through the built-in REPL shell, making the language practical for both scripting and exploratory use.
Key Features
- Custom hand-written lexer and tokeniser
- Recursive-descent parser producing an AST
- Tree-walking interpreter for evaluation
- Variables, functions, classes, and imports
- Control flow: IF/ELSE, FOR, WHILE
- Built-in console and file I/O functions
- Single-line (#) and multi-line (#* *#) comments
- Interactive REPL and script-file execution