Code Monkey home page Code Monkey logo

spooky-vm's Introduction

Spoooky!

Spooky is a simple programming language with an accompanying compiler and virtual machine.

Requirements

To run the compiler, you need to have Java 14 installed.

Usage

To compile the source source.spooky into the compiled file exec.spook, run

spooky compile source.spooky exec.spook

To execute the program, run

spooky spooky.jar run exec.spook

Language features

Spooky is a bare-bones C-like language, supporting only basics such as variables, functions, loops, conditionals and simple expressions. While the VM itself is pretty fixed in structure, contributions to the language itself are very welcome. In particular, features such as

  • arrays
  • string literals

would be nice.

External functions

When executing programs, a set of external functions may optionally be provided. These are declared as extern functions in your source and provided by the execution environment.

Example programs

extern void printInt(int i)
extern void print(int ch)

bool isPrime(int n) {
    int p = 1;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }
  }
  return true;
}

void main() {
    for (int n = 90; n < 100; n++) {
        printInt(n);
        print(' ');
        printInt(isPrime(n));
        print('\n');
    }
}

spooky-vm's People

Contributors

jsannemo avatar lokegustafsson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.