Giter Club home page Giter Club logo

coq-compiler's Introduction

CoQCompiler

CoQ

XJTU-SE Grade 3 Compiler Practice.

-- A fake compiler, implementing a simple language.

'Code to Quads' transformation. No assembly code generation. However, it won't be too much work to transfer the quads to assembly code.

Language features are as follows:

Data types

Supports basic types including integers(int), real numbers(float), characters(char), booleans(bool)

Simple Variables

Expressions

Arithmetic

+, ++, -, --, *

Relation

<, <=, =, !=, >, >=

Boolean

&, |, ! (Nobody is willing to type ∨, ∧, and ⌐, Okay?)

Statements

Assignment

Provides support for multi-dimensional arrays, like "a[1, 2] := 3".

Branch

Provides support for "if-then", "it-then-else" structure and "switch-case" structure

Loop

"while-do" and "do-while" structures will be implemented.

Call

It's not an OOP language, but the basic procedure-calling mechanism is necessary.

Definition

As long as some procedures are called, they are defined. Certainly, variables should also be defined.

With a text file as the input, a sequence of quadruples (which can be easily transferred to assembly language) will be generated. Invalid code in the text file will cause the compiler to report error type and error position. Also, an output file will be generated along with the analyzation result on the screen.

Language Example

function func(int x, int y) {
    x = x + y
};
int a, b;
a := 2;
while (a<20 & b>8) do {
    if a>10 || b<16 then {
        if a<15 then {
            a := 19;
            b := 15
            call func(a, b);
        } else {
            a := 11;
            b := 9
        };
    } else {
        a := 1;
        b := 17
    };
};

coq-compiler's People

Contributors

linkinpark213 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.