Giter VIP home page Giter VIP logo

mini-c's People

Contributors

fedjmike avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mini-c's Issues

"You can always add more Tests"

do you think there should be tests that test for IF statement? i saw the example only contains while statements but no IF statement.

also, awesome project! :D

By including <stdio.h> it is not defined fflush neither stdout

main.c

#include <stdio.h>

int main(int argc, char **argv){
    int i=0;
    while(i<1000000){
        printf("\r%i",i);
        fflush(stdout);
	i=i+1;
    }
    printf("\n");
    return 0;
}

Compiling:

mcc ./main.c

Errors:

mcc ./main.c 
./main.c:7: error: no symbol 'fflush' declared
./main.c:7: error: no symbol 'stdout' declared

There is some equivalence to do this?

How to bootstrap it from scratch

Anybody who knows C can use your mini-c as the minimal self-hosting subset of C compiler and can implement the whole C compiler or other languages.

What would also be interesting is to bootstrap mini-c from scratch. Currently you require some kind of a C compiler like gcc to be present on the system.

Here is an example of an approach that doesn't require any compiler at all, it starts from a small hand written machine code and then it goes from there to develop a structured programming language called BCC: http://rano.org/bcompiler.html (I made a mirror at github here: https://github.com/certik/bcompiler/blob/master/bcc.bc)

So the goal would be to write a compiler in BCC that can compile mini-c.

Error when compiling cc.c using ccself; cc.c:719: error: expected ')', found '�'

The selftest test case passes just fine. However, when trying to compile cc.c using the ccself binary, it fails with the following errors.

u@x220 ~/D/c/c/mini-c> make selftest
gcc -m32 -std=gnu11 -Werror -Wall cc.c -o cc
./cc cc.c
gcc -m32 a.s -o ccself
./ccself tests/triangular.c
gcc -m32 a.s -o triangular; ./triangular 5; [ $? -eq 15 ]
u@x220 ~/D/c/c/mini-c> ./ccself cc.c
cc.c:719: error: expected ')', found ''
cc.c:719: error: expected ';', found ''
cc.c:719: error: expected '}', found ''

Note, compiling cc.c with the produced cc binary works just fine, and compiling triangular.c with ccself also works just fine.

Is ccself intended to be able to compile cc.c?

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.