Giter Site home page Giter Site logo

warpengineer / igcc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from starlitghost/igcc

0.0 1.0 0.0 52 KB

Interactive GCC (igcc) is a read-eval-print loop (REPL) for C/C++ programmers. Cloned from http://www.artificialworlds.net/wiki/IGCC/IGCC

License: GNU General Public License v2.0

Shell 0.90% C++ 5.17% Python 91.79% C 1.62% Makefile 0.52%

igcc's Introduction

Interactive GCC
===============

Interactive GCC (igcc) is a read-eval-print loop (REPL) for C/C++ programmers.

It can be used like this:

 $ ./igcc 
 g++> int a = 5;
 g++> a += 2;
 g++> cout << a << endl;
 7
 g++> --a;
 g++> cout << a << endl;
 6
 g++> 

It is possible to include header files you need like this:

 $ ./igcc 
 g++> #include <vector>
 g++> vector<int> myvec;
 g++> myvec.push_back( 17 );
 g++> printf( "%d\n", myvec.size() );
 1
 g++> myvec.push_back( 21 );
 g++> printf( "%d\n", myvec.size() );
 2
 g++> 

It is possible to include your own functions using '.f':

g++> .f
Functions paste mode is ON: Enter ".f" again to return to return to normal editing.

g++> int lastIndexOf(char *str, char c) {
g++>   int ind = -1;
g++>  for (int i=strlen(b)-1;i>=0;i--) {
g++>   if (b[i] == c) {
g++>     ind = i;
g++>     break;
g++>   }
g++>  }
g++>  return ind;
g++> }
g++> .f
Functions paste mode is OFF

You can use '.p' to enter "Paste" mode to enter multi line snippets :

g++> .p
Paste mode is ON: Enter ".p" again to return to return to normal editing.

g++> char c = '_';
g++> char *a = (char *)malloc(80);
g++> char b[] = "a_another_word_there_last";
g++> strcpy(a, b[lastIndexOf('_'));
g++> puts(a);
g++> .p
Paste mode is OFF

[Compile error - type .e to see it.]


Compile errors can be tolerated until the code works:

 $ ./igcc
 g++> #include <map>
 g++> map<string,int> hits;
 g++> hits["foo"] = 12;
 g++> hits["bar"] = 15;
 g++> for( map<string,int>::iterator it = hits.begin(); it != hits.end(); ++it )
 [Compile error - type .e to see it.]
 g++> {
 [Compile error - type .e to see it.]
 g++> 	cout << it->first << " " << it->second << endl;
 [Compile error - type .e to see it.]
 g++> }
 bar 15
 foo 12
 g++> 

Extra include directories can be supplied:

 $ ./igcc -Itest/cpp -Itest/cpp2
 g++> #include "hello.h"
 g++> hello();
 Hello, 
 g++> #include "world.h"
 g++> world();
 world!
 g++> 

Libs can be linked:

 $ ./igcc -lm
 g++> #include "math.h"
 g++> cout << pow( 3, 3 ) << endl; // Actually a bad example since libm.a is already linked in C++
 27
 g++> 

Your own libs can be linked too:

 $ ./igcc -Itest/cpp -Ltest/cpp -lmylib
 g++> #include "mylib.h"
 g++> defined_in_cpp();
 defined_in_cpp saying hello.
 g++> 

The cstdio, iostream and string headers are automatically included, and the std namespace is automatically in scope.

Downloading and using
---------------------

Download the IGCC tarball from the Sourceforge download area:

https://sourceforge.net/projects/igcc/files/

Untar it like so:

 tar -xjf igcc-0.1.tar.bz2

And then start the program like this:

 cd igcc-0.1
 ./igcc

Then type the C++ code you want to execute. It will be compiled with GCC and the results (if any) will be displayed.

Type .h to see some (minimal) help.

Developing
----------

IGCC is a small python wrapper around GCC.

Check out the code here:

 git clone git://igcc.git.sourceforge.net/gitroot/igcc/igcc

Or browse the source here:

http://igcc.git.sourceforge.net/git/gitweb.cgi?p=igcc/igcc;a=tree

Links
-----

IGCC home page:
http://www.artificialworlds.net/wiki/IGCC/IGCC

IGCC Sourceforge page:
http://sourceforge.net/projects/igcc/

Andy Balaam's home page:
http://www.artificialworlds.net

Andy Balaam's blog:
http://www.artificialworlds.net/blog

Contact
-------

Andy Balaam may be contacted on axis3x3 at users dot sourceforge dot net

Copyright
---------

IGCC is Copyright (C) 2009 Andy Balaam

IGCC is Free Software released under the terms of the GNU General Public License version 2 or later.

IGCC comes with NO WARRANTY.

See the file COPYING for more information.

igcc's People

Contributors

andybalaam avatar javadba avatar starlitghost 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.