Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Feeny Language

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.

Features

  • 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

Quick Start

Installation

# Clone the repository
git clone https://github.com/HaleOIC/FeenyLanguage.git
cd feeny

# Build the interpreter
make compile

After running the above commands, an executable file is located in ./bin directory.

Running Your First Feeny Program

  1. Create a file hello.feeny:

    printf("Hello, World!\n")
    
  2. 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

Basic Syntax

  1. Variables and Functions

     var x = 42          ;Global variable
     defn add(a, b):     ; Function definition
         a + b
    
  2. Objects and Methods

     object:
         var x = 10
         var y = 20
         method sum():
             this.x + this.y
    
  3. 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

Example Code

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()

Test

cd test
./run_test_bytecode_compiler.sh
./run_test_ast_interpreter.sh

About

Dynamic typed object-oriented language on self-designed virtual machine

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages