Feeny is a dynamic programming language that runs on a self-constructed virtual machine. This implementation includes a bytecode compiler and interpreter, demonstrating core concepts of language implementation.
- Dynamic typing system with primitive types and objects
- Object-oriented programming support with inheritance
- Garbage collection
- NaN boxing optimization for efficient value representation
- Python-like indentation-based syntax
# Clone the repository
git clone https://github.com/HaleOIC/FeenyLanguage.git
cd feeny
# Build the interpreter
make compileAfter running the above commands, an executable file is located in ./bin directory.
-
Create a file
hello.feeny:printf("Hello, World!\n") -
Run it, there are two versions of interpretation, one is ast-level interpretation with flag
-a, the other is bytecode-level interpretation with flag-f:./bin/cfeeny -a hello.feeny # ast interpreter ./bin/cfeeny -f hello.feeny # bytecode compiler on vm
-
Variables and Functions
var x = 42 ;Global variable defn add(a, b): ; Function definition a + b -
Objects and Methods
object: var x = 10 var y = 20 method sum(): this.x + this.y -
Control Flow
; If statement if x < 10: printf("Less than 10\n") else: printf("Greater or equal to 10\n") ; While loop while i < 10: printf("i = ~\n", i) i = i + 1
More syntax can be found in ./docs
defn three():
3
defn hello(i):
printf("Hello ~ ", i)
defn world(j, k):
printf("World ~ ~\n", j, k)
defn main():
var i = three()
hello(i)
i = 10
world(4, i)
main()
cd test
./run_test_bytecode_compiler.sh
./run_test_ast_interpreter.sh