2025-11-23 16:32:54 +11:00
# Ground, but written in C this time
This repo houses the new Ground interpreter, which will replace the old C++ interpreter.
Features of this interpreter:
* Written in C instead of C++
* Somewhat organised and readable codebase
* Not super buggy (yet)
* Uses standard, portable C*
2025-12-06 14:44:59 +11:00
* Actually speedy (typically 3-5x faster than Python, similar results to C)
* 95% more memory efficient than original Ground
* Up to 5x faster than original Ground
* 90% smaller binary than original Ground
2025-11-23 16:32:54 +11:00
Now that Ground's features have mostly been finalised, this interpreter can be built with care to many features not initially planned, like functions and data structures
*so far, only tested on Linux, but hopefully should work on other platforms as well
2025-12-08 15:06:29 +11:00
## Building
To build, make sure Make is installed. Then, run:
```bash
make
```
Ground can also be embedded as a library in other programs. Run this code to generate library files:
```bash
make library
```
File structure of the build directory:
```
build
├── bin
│ └── ground
├── include
│ └── groundvm.h
├── lib
│ └── libgroundvm.so
└── obj
├── exe_interface.o
├── exe_interpreter.o
├── exe_lexer.o
├── exe_main.o
├── exe_parser.o
├── exe_types.o
├── lib_interface.o
├── lib_interpreter.o
├── lib_lexer.o
├── lib_parser.o
└── lib_types.o
```
## Progress marker
2025-11-23 16:32:54 +11:00
- [x] Lexer
- [x] Parser
- [x] Labels
- [x] Instructions
- [x] Values
- [x] References
- [ ] Interpreter
2025-11-23 19:18:10 +11:00
- [x] Labels
2025-11-24 13:19:37 +11:00
- [x] Console I/O
2025-11-23 19:18:10 +11:00
- [x] Control flow
2025-12-01 12:28:15 +11:00
- [x] Data
2025-11-24 13:19:37 +11:00
- [x] Variable creation
- [x] Variable access
2025-12-01 12:28:15 +11:00
- [x] Lists
- [x] Creation
- [x] Access
- [x] String operations
2025-11-24 13:19:37 +11:00
- [x] Maths
- [x] Comparisions
2025-11-23 16:32:54 +11:00
- [ ] Type conversions
2025-12-11 14:24:11 +11:00
- [x] Functions
2025-12-06 14:44:59 +11:00
- [x] Define functions
- [x] Call functions
2025-12-11 14:24:11 +11:00
- [x] Return values (type checked)
- [x] Arguments for functions
- [x] Jumping within functions
2025-11-23 16:32:54 +11:00
- [ ] Custom data structures
- [ ] Working with external libraries
2025-12-06 14:44:59 +11:00
2025-12-11 13:07:37 +11:00
## Debugger
Ground now has an inbuilt debugger. To access this debugger, insert the `PAUSE` instruction (no arguments required) into the program. This should bring you to an interactive prompt.
Commands:
* continue: Continues execution of the program
* exit: Stops execution of the program early
* dump: Shows all variables and their contents
* inspect (variable): Shows the contents of a variable
* eval (code): Runs Ground code in the current scope
* help: Shows a help message
2025-12-06 14:44:59 +11:00