Giter Club home page Giter Club logo

valhallac's Introduction

valhallac

The Valhalla Compiler

Valhalla Flag

Valhalla Programming Language

This is the parser and compiler for Valhalla, which excludes the virtual machine that the compiled bytecode runs on, which is, Brokkr VM.

IN (HEAVY) DEVELOPMENT

[!!] Planning a complete rewrite, and balancing work.


What's been done so far on the front-end:

  • Parser
    • Lexical analysis, full UTF-8 support, handling: identifiers, symbols, numbers, strings (utf-8 with a good number of escapes), all sorts of braces for: vectors, sets and grouping, etc.
    • Infix, prefix and suffix notation.
    • Correct parsing of precedence, arity and associativity.
    • The base operators for the language.
    • Proper function calls, Currying / partial application of functions is properly implemented (Haskell-like functions).
    • Error messages, with fancy line and column number and read-out of the source line.
    • Constant folding optimisations on trivially deducible numeric computations at compile time.
    • Implicit compile-time type-casting in specific situations.
    • Macros (including macro definitions and macro application).
    • User-defined binary operators as aliases to functions.
  • Compiler (generating bytecode to assemble an executable file).
    • Table of constants and locals with basic PUSH & POP instructions as well as basic arithmetic.
    • Access, assignment and retrieval of local variables within code-block scope.
    • Generating curried functions.
    • Optimise functions to not curry when currying is not neccesary (by tracking arity of function's definition and function's call).
    • Optimise functions to not search globally for variables when they come from nested closures (nested closures implement currying).
    • Optimise functions for tail calls.
    • Track variable and function types.
    • Marshaling, i.e. serialising the bytecode and storing it in a file for future interpretation and execution by the virtual machine.
    • ...

The VM, i.e. the backend for the language, is being developed separately and will progress semi-independently.

Compile & Run

Requires Rust Nightly for now.

In your shell, in the root of this repository, you may write:

cargo run [source-file-to-compile.vh] [-o out-file] [-v]

or, have the compiler print out debug information like token streams, syntax trees, symbol tables, bytecode instructions, &ct., use --features=debug:

cargo run --features=debug [source-file.vh]

For example, you can run.

cargo run test_source.vh -v   # For verbose output.

to demonstrate compilation with the included test-file (test_source.vh). The argument of a source-file to compile is, of course, necessary.

Example of what the compiler currently does:

current_compiler_test.md

Description

This repository contains the front-end (parser and bytecode compilation) which processes the syntax and semantics of the source code. The generated AST is then compiled to Brokkr VM bytecode. The execution of the subsequent bytecode is handled by the language's VM (virtual machine) called Brokkr, which exists separately from this repository.

Valhalla is a set-theoretic programming language. That's to say, it's based on principles from set theory, in a way that all types are just sets, and hence everything is just an element of a set. The language is meant to give a new way to interact with types, and provides an intuitive way to think about them. A goal is that it may also be used to verify proofs and such in and around set theory.

The language is a general purpose, but instead of being totally object-oriented, or functional, etc., it's just set theory based. From what I've gathered, it's not a very popular paradigm... Likely for good reason, but hey, it might be interesting.

Dependencies

To be significantly reduced.

deps

valhallac's People

Contributors

b-coimbra avatar demonstrandum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

isgasho

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.