Code Monkey home page Code Monkey logo

alphacompiler's Introduction

Alpha Compiler

Alpha Compiler is a complete compiler (acc) and virtual machine (avm) for the Alpha programming language. (For the syntax etc. see the examples provided).

Created by Manos Chatzakis ([email protected]) and Nikos Fanourakis ([email protected]).

To compile:

cd build
make

Lexical Analysis

Lexical Analysis is done using Lex program, following the rules of Alpha Programming language.
Supported escaped characters: \ + {n,t,\,"}

Syntax Analysis

The parser uses Lex to detect the tokens ignoring whitespaces, and manipulates the symboltable using the functions provided in "yacc_api.h" file.

The Symboltable library contains the symboltable structure (to store every symbol), the scope list (to keep together symbols of the same scope), the function argument list (to keep the arguments of a function) and the function stack (to check symbol accessibility and to match every formal argument to its corresponding function).

Intermediate Code Generation

The quads are printed by default to output filestream and additionally to the file "quads.txt", only when the input has not compilation errors.

We provide two ways to print the quads (verbose and formal). By defaults the quads are printed using the verbose method, but the formal method can be invoked by setting the printQuad(int flag, FILE* stream) flag to 0, manually.

Note: The above features got disabled on final version. They can be re-enabled manually from the syn_an.y file. The quads produced are printed in stdout using "-p" compiler flag.

Target Code Generation

The instructions are printed in stdout by default and they are written to the specific Alpha binary file (bin.abc). To cover corner cases, hidden variables optimization is disabled for the table members, to avoid resetting bugs.

Alpha Virtual Machine

Alpha applications run on the AVM (Alpha Virtual Machine), which is a complete virtual machine designed to provide a C/C++ based runtime environment.

To compile the AVM executable, use:

cd build
make #"make avm" works as well

Thus, to compile an alpha application, assuming the file is named "code.alpha" (extensions do not matter):

cd build
make
./acc -i code.alpha #produces the binary file called bin.abc
./avm -f bin.abc #use avm to run the code

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.