Giter Club home page Giter Club logo

blaze's Introduction

Blaze

Blaze is an embeddable dynamic programming language.
It runs by interpreting bytecode instructions with a stack based interpreter.

Why do we need another language?
Well, we don't. It's a project for college.
Nobody will actually use it for anything serious.
It's not designed to be super fast or efficient.

Documentation (in Serbian): PDF

Usage

Usage: blzc.exe [options]
Options:
    -s [file]       Blaze source file to compile
    -d              Compiles as a debug module

Usage: blzi.exe [options]
Options:
    -m [file]       Module file to execute
    -d              Print the contents of the module file

Example

extern var console;

func main() {
    console.print("Hello World");
}
> .\blzc.exe -s hw.blz
  Compiled to 'hw.blzm'
> .\blzi.exe -m hw.blzm
  Hello World

This is a simple hello world program. Notice that we have to specify that the console variable is external.
Blaze doesn't have a concept of a global environment like most embeddable/scripting languages do.

Blaze works with modules.
Each Blaze source file is compiled to a module, which contains functions, classes and variables.
Variables can be declared as public, private or extern.

The console interface is provided from an internal module in the interpreter.
That might sound like a global environment, but unless you specify that console is extern the interpreter won't be able to see it.

During runtime each module can have multiple children and a parent which make up a hierarchy.

Libraries

Blaze doesn't come with a standard library, that task is up to the developer who's embedding the language into their application.
The developer should keep in mind that goal is to provide the user only with functions they'll actually need.

In the future there might be a system where you can load modules that are made with C# and exported as a C# DLL.
Maybe even a C++ DLL, which would work better in the future if I ever write an interpreter in C++.
When that's possible, then some kind of standard library might appear.

Features

Blaze currently supports:

  • Basic values (Numbers, Strings, Booleans, null)
  • Functions
  • Classes
  • Lists
  • Dictionaries
  • Events
  • All of the expected control flow (if, while, for)

Events

As Blaze is an embeddable language, it has to have some kind of event system.
The host application might expose an event to which you can attach a callback.

// here the application exposes an object that holds multiple events
extern var UserEvent;
extern var console;

event UserEvent.Connect(username) {
    console.print(username, " connected");
}

event UserEvent.Disconnect(username) {
    console.print(username, " disconnected");
}

You can attach multiple callbacks to an event, obviously.

If you want something to happen only if an event parameter is a specific value, you can pass a list of expected values.
If the parameter is not one of these, the callback won't execute.

event UserEvent.Connect(["vladimirdabic", "doofusjack"]) {
    console.print("Specific user connected");
}

This is just syntactic sugar for

event UserEvent.Connect(username) {
    if(!(["vladimirdabic", "doofusjack"].contains(username))) return;

    console.print("Specific user connected");
}

blaze's People

Contributors

vladimirdabic avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

starbound-games

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.