Git Product home page Git Product logo

alphalang_hy340's Introduction

Alpha

Complete Compiler and Virtual Machine for Alpha

Made in 2020 with Labis Anargyrou for Languages & Compilers (hy340) at CSD

alpha2

alpha3

Linux Installation

The Alpha compiler requires GNU Bison & Flex:

sudo apt install bison
sudo apt install flex

Download & build Alpha:

git clone "https://github.com/PhivPap/AlphaLang_hy340.git"
cd AlphaLang_hy340
make

Usage

Compile an Alpha source file with:

./alphac <source.a> -o <bytecode.abc>

Execute an Alpha binary file with:

./alpha <bytecode.abc>

Alternatively, do both in one line:

./alphac <source.a> --run

Print the quads and human readable byte code with:

./alphac <source.a> --quads --instructions

In other news

While the language is sadly not described in this repo, you can try guessing with the provided testfiles. You can, however, know the following:

  • The Alpha compiler has:
    • compile-time expression evaluation
    • dead code elimination
    • temporary variable reuse optimization
    • minimal evaluation
  • The Alpha virtual machine has:
    • the following library functions:
      • print(...) - Variadic print function. Catches direct or indirect object self reference loops
      • input() - Returns line from console. Implicit convertion to other-than-string possible types.
      • objectmemberkeys(t) - Returns a table with the keys of t indexed from 0 and up.
      • objecttotalmembers(t) - Returns the number of entries in t.
      • objectcopy(t) - Returns a shalow copy of t.
      • totalarguments() - Returns argc of the calling function.
      • argument(i) - Returns the ith argument of the function from where this was called in. Can be used with totalarguments() to create an Alpha variadic function.
      • typeof(x) - Returns the type of x as a string.
      • strtonum(s) - Converts string s to num.
      • sqrt(n) -
      • cos(n) -
      • sin(n) -
    • table functors (double dot ".." operator)
    • tables which are implemented as expanding open addressing linearly probed hash tables
    • tables which receive any type as key and value
    • string concat (ikr damn)
    • perfectly hashed library functions (i.e. they are called in O(1))
    • complete garbage collection

alphalang_hy340's People

Contributors

phivpap avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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.