-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.txt
409 lines (320 loc) · 12 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
Interactive TCC
===============
Make programming fun like Python.
An command-line shell for C, C++, Rust, Hare, Go, Zig, and the concise, regex-aware
CPP (CRAP). Also known as an evaluation context, or read-eval-print loop (REPL), this revolutionary shell tool allows programmers to type commands in a variety of compiled
langauges and see immediate results.
About this project. Interactive TCC (itcc) is a small python3 utility originally
forked from Interactive GCC (igcc). And we keep adding other languages to it. We do
our best to make the code work for us, but it comes with NO Warranties. You are free
to share and modify free software in according with the GNU General Public License
(GPL) Version 2. See the notice at the bottom of this page and COPYING.txt for
details. Get ITCC from GitHub https://github.com/themanyone/itcc
Dependencies. Build the optional TINYCC compiler (tcc) (or skip down to the C++ section
ad use GCC). The experimental MOB branch of tcc accepts random contributions from
anyone, so check it over carefully! Join the active mailing list, contribute fixes,
and update often. git clone https://repo.or.cz/tinycc.git/
Now with color listings. Install Colorama Highlight (required). Available through your
distro package manager, conda, or pip.
The main reason we like tcc is instant gratification. Owing to its small download
size, and the smallness of the resulting executables, tcc's one-pass build ensures
virtually no compiler delays between entering code and seeing the results! Tcc
supports Windows, Linux, Android and other targets with many common GCC extensions.
But it might lack some of the optimizations of GCC. Also, tcc is a C compiler, not a
C/C++ compiler suite like GCC.
Use our Interactive tcc shell, like this:
$ ./itcc
Released under GNU GPL version 2 or later, with NO WARRANTY.
Type ".h" for help.
tcc> int a = 5;
tcc> a -= 2;
tcc> if (a < 4) {
tcc> printf("a is %i\n", a);
tcc> }
a is 3
tcc> |
Pass arguments to Interactive TCC and operate on them.
$ ./itcc -- foo bar baz
tcc> puts(argv[2]);
bar
tcc> |
Interactive Crap
================
Interactive, concise, regex-aware preprocessor (icrap) *is standard C* (using tcc in
the background), without most of the semicolons, curly braces, and parenthesis. Like
Python, use tab or indent 4 spaces instead of adding curly braces. Use two spaces
instead of parenthesis. Since braces are added automatically, it saves typing. There
are also some exciting, new go-like language features that really simplify C coding.
Get crap from https://themanyone.github.io/crap/ Released under GNU GPL
version 2 or later, with NO WARRANTY. Type ".h" for help.
$./icrap -lm
crap> #include "math.h"
crap> for int x=0;x<5;x++
crap> printf "%i squared is %0.0f\n", x, pow(x, 2.0)
0 squared is 0
1 squared is 1
2 squared is 4
3 squared is 9
4 squared is 16
crap> |
Supply includes and libs on the command line. You can link against glib-2.0, plugins,
etc. Test code without the compile step. Add extra CFLAGS and args. It's all free.
icrap $(pkg-config --cflags --libs glib-2.0) -std=c11 -g -Wall -- foo myargs
crap> .l
#include <glib.h>
#include <glib/gprintf.h>
crap> GDateTime *dt=g_date_time_new_now_local ();
crap> int yyyy,mm,dd
crap> g_date_time_get_ymd dt, &yyyy, &mm, &dd
crap> g_print "date: %.4d-%.2d-%.2d\n", yyyy, mm, dd
date: 2024-02-14
crap> puts argv[2]
myargs
crap> |
Interactive Tcc and Interactive Crap build upon the original Interactive GCC (igcc),
which is also included in this package. Those who have no problem converting C++ to C,
might even be able to struggle through some of following examples using itcc, or
icrap.
Interactive GCC
===============
Use Interactive GCC for C++ programming, 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++> |
Start igcc with the -e option to see every compiler error notification, even a missing
closing brace from an unfinished block of code. These types of error notices are not
useful for interactive sessions, so we hide them. You can always use .e to check for
errors even without such warnings.
$ ./igcc -e
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 )
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 # bad example since libm.a is already linked in C++
g++> #include "math.h"
g++> cout << pow( 3, 3 ) << endl;
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 already in scope.
Interactive Rust
================
We can now run rust interactively. Get rustup from http://rust-lang.org or your
distro's package manager. Use the nightly build for cutting-edge development.
rustup toolchain install nightly
rustup default nightly
Typing .h [std] or any such rust idiom brings up a local copy of the documentation
from https://rust-cli.github.io/book/tutorial/cli-args.html, which should be installed
when you install rust using the above method.
Now we can invoke irust. Arguments after the `--` are passed along to the interactive
session for us to play with.
$ ./irust -- foo bar baz
irust 0.3
Released under GNU GPL version 2 or later, with NO WARRANTY.
Type ".h" for help.
rust> use std::env;
rust> let args: Vec<String> = env::args().collect();
rust> for arg in args.iter() {
rust> println!("{}", arg);
rust> }
foo
bar
baz
rust> |
Interactive Hare
================
Hare is a systems programming language with a static type system, manual memory
management, and a small runtime. It's well-suited for low-level, high-performance
tasks like operating systems, system tools, compilers, and networking software. Now
you can play with it interactively.
Hare Website: https://git.sr.ht/~sircmpwn/harelang.org
Hare compiler: git clone https://git.sr.ht/~sircmpwn/harec
Hare std libs: git clone https://git.sr.ht/~sircmpwn/hare
Depends on QBE: https://c9x.me/compile/code.html
Requires scdoc: https://git.sr.ht/~sircmpwn/scdoc
Compile everything from the latest sources. Once installed, it will work with our
interactive demo here. Also, be sure and get more help, libraries, and resources
below.
Interactive hare session:
$./ihare
ihare 0.3
Released under GNU GPL version 2 or later, with NO WARRANTY.
Get hare from https://sr.ht/~sircmpwn/hare/sources
Type ".h" for help.
hare> const greetings = [
hare> "Hello, world!",
hare> "¡Hola Mundo!",
hare> "Γειά σου Κόσμε!",
hare> "Привіт, світ!",
hare> "こんにちは世界!",
hare> ];
hare> for (let i = 0z; i < len(greetings); i += 1) {
hare> fmt::println(greetings[i])!;
hare> };
Hello, world!
¡Hola Mundo!
Γειά σου Κόσμε!
Привіт, світ!
こんにちは世界!
hare>
hare> // get help on rt::timespec
hare> .h rt::timespec
type timespec = struct {
tv_sec: time_t,
tv_nsec: i64,
};
hare> |
Interactive Zig
===============
$ izig
izig 0.3
Released under GNU GPL version 2 or later, with NO WARRANTY.
Get zig from distro package or https://ziglang.org/
Type ".h" for help.
zig> const stdout = std.io.getStdOut().writer();
zig> try stdout.print("Hello, {s}!\n", .{"world"});
Hello, world!
zig> |
Interactive Go
==============
$ igo
igo 0.3
Released under GNU GPL version 2 or later, with NO WARRANTY.
Get go from https://go.dev/
Type ".h" for help.
go> fmt.Println("Welcome to the playground!")
Welcome to the playground!
go> import "time"
go> fmt.Println("The time is", time.Now())
The time is 2024-03-02 10:28:25
go> .L
package main
import "fmt"
import "time"
func main() {
fmt.Println("Welcome to the playground!")
fmt.Println("The time is", time.Now())
}
go> |
FAQ. Issues.
============
How does it work? Does it re-run the entire code block each time?
Yes. Although it runs all the code each time, it only prints the new output.
Supposedly. There appears to be some bugs with detecting what was already printed,
causing some new lines to produce no output. In that case, just press CTRL-C or CTRL-D
and restart it. We're working on that...
Your Editor Is Now a REPL
=========================
Our replacement is here. Any language. Any editor.
We made a REPL maker! This command is all you need.
$ repl.sh [compiler] -run [sources]
It watches `test.c` for changes. If it detects any, it compiles and runs.
Compiler options supported. After `--` my args are available inside script.
$ repl.sh tcc $CFLAGS $LIBS -run test.c -- my args
Use `runner` if your compiler does not have a -run option.
$ repl.sh runner gcc $CFLAGS $LIBS test.c -- my args
The `hare` build system.
$ repl.sh runner hare build hello.ha -- my args
Some new Smurf language? Smurfy.
$ repl.sh smurf run papa.smurf -- my args
Get REPL Ace free from https://github.com/themanyone/REPLace
Updating This Package
=====================
itcc is published on GitHub. Get it from https://github.com/themanyone/itcc where
developers can submit bug reports, fork, and pull requests with code contributions.
Other REPLs
-----------
REPLAce: a REPL for all languages https://github.com/themanyone/REPLace
various languages in the browser http://repl.it
csharp: included with monodevelop http://www.csharphelp.com/
psysh: comes with php for php code http://php.net
evcxr: another Rust REPL https://github.com/evcxr/evcxr
ipython: interactive python https://github.com/ipython/ipython
rep.lua: a lua REPL https://github.com/hoelzro/lua-repl
re.pl: perl command line https://github.com/daurnimator/rep
d8-314: from V8, JavaScript https://developers.google.com/v8/
csi: from chicken, a scheme REPL http://call-cc.org/
RStudio: interactive R coding https://rstudio.com/
Ruby IRB: REPL tool for Ruby https://ruby-doc.org/stdlib-2.7.2/libdoc/irb/rdoc/IRB.html
numerous bash-like shells and interpreters
Legacy Code
-----------
For Python2, you may opt to download Andy Balaam's original 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
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.
This fork is maintained with updated code, which is Copyright (C) 2024 by Henry Kroll
III under the same license. Blame him if there are problems with these updates. Issues
for this fork are maintained on GitHub.
Browse Themanyone
- GitHub https://github.com/themanyone
- YouTube https://www.youtube.com/themanyone
- Mastodon https://mastodon.social/@themanyone
- Linkedin https://www.linkedin.com/in/henry-kroll-iii-93860426/
- [TheNerdShow.com](http://thenerdshow.com/)