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*
- 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
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
Building
To build, make sure Make is installed. Then, run:
make
Ground can also be embedded as a library in other programs. Run this code to generate library files:
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
- Lexer
- Parser
- Labels
- Instructions
- Values
- References
- Interpreter
- Labels
- Console I/O
- Control flow
- Data
- Variable creation
- Variable access
- Lists
- Creation
- Access
- String operations
- Maths
- Comparisions
- Type conversions
- Functions
- Define functions
- Call functions
- Return values (type checked)
- Arguments for functions
- Jumping within functions
- Custom data structures
- Working with external libraries
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
Description
Languages
C
98.8%
Makefile
1.2%