Skip to content

Commit b7ad56a

Browse files
committed
initial import
0 parents  commit b7ad56a

File tree

527 files changed

+116776
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

527 files changed

+116776
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.txt -crlf

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bin
2+
link.txt

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Origins
2+
**pico-c** is a project created by Zik at [https://code.google.com/p/picoc](https://code.google.com/p/picoc/ "Google code").
3+
The projet is now hosted at [https://gitlab.com/zsaleeba/picoc](https://gitlab.com/zsaleeba/picoc/ "Github.com").
4+
5+
**pico-c** intends to be a very light **C** interpreter. **pico-c** is very small, but include many standard libraries.
6+
7+
# The content
8+
Initially those libraries were natively integrated into pico-c:
9+
10+
* ctype.h
11+
* errno.h
12+
* math.h
13+
* stdbool.h
14+
* stdio.h
15+
* stdlib.h
16+
* string.h
17+
* time.h
18+
* unistd.h
19+
20+
Some of them were improved:
21+
22+
* stdio.h
23+
* unistd.h
24+
25+
We have planned to add support for 3 other useful libraries:
26+
27+
* dirent.h
28+
* regex.h
29+
* socket.h
30+
* stat.h
31+
32+
# The pico-c syntax
33+
34+
```
35+
$ pico-c -h
36+
pico-c.exe, A very small C interpreter
37+
Usage: pico-c.exe [-h] [-i] [-m] [-n] [-o] [<filename1>...] [- <arg1>...]
38+
-h: this help message
39+
-i: force interactive mode at the end of scripts
40+
-m: run main() function automaticaly
41+
-n: don't print prompt
42+
-o: the original "old" mode
43+
-v: print version
44+
Exemples:
45+
pico-c.exe script1.pcc script2.pcc
46+
pico-c.exe -i script.pcc
47+
pico-c.exe -m script1.pcc script2.pcc - arg1 agr2}
48+
```
49+
50+
**Cyd**

src/Makefile

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
CC=gcc
2+
CFLAGS=-Wall -pedantic -g -DUNIX_HOST -DVER=\"2.1\" -DPERSOPORT
3+
LIBS=-lm -lreadline
4+
5+
TARGET = picoc
6+
SRCS = picoc.c table.c lex.c parse.c expression.c heap.c type.c \
7+
variable.c clibrary.c platform.c include.c debug.c \
8+
platform/platform_unix.c platform/library_unix.c \
9+
cstdlib/stdio.c cstdlib/math.c cstdlib/string.c cstdlib/stdlib.c \
10+
cstdlib/time.c cstdlib/errno.c cstdlib/ctype.c cstdlib/stdbool.c \
11+
cstdlib2/main.o cstdlib2/types.o cstdlib2/stat.o cstdlib2/dirent.o cstdlib2/popen.o cstdlib2/tools_h.o cstdlib2/various.o cstdlib2/regex.o cstdlib2/socket.o \
12+
cstdlib/unistd.c
13+
OBJS := $(SRCS:%.c=%.o)
14+
15+
all: $(TARGET)
16+
17+
$(TARGET): $(OBJS)
18+
$(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
19+
20+
test: all
21+
(cd tests; make test)
22+
23+
clean:
24+
rm -f $(TARGET) $(OBJS) *~ *.o
25+
26+
count:
27+
@echo "Core:"
28+
@cat picoc.h interpreter.h picoc.c table.c lex.c parse.c expression.c platform.c heap.c type.c variable.c include.c debug.c | grep -v '^[ ]*/\*' | grep -v '^[ ]*$$' | wc
29+
@echo ""
30+
@echo "Everything:"
31+
@cat $(SRCS) *.h */*.h | wc
32+
33+
.PHONY: clibrary.c
34+
35+
picoc.o: picoc.c picoc.h
36+
table.o: table.c interpreter.h platform.h
37+
lex.o: lex.c interpreter.h platform.h
38+
parse.o: parse.c picoc.h interpreter.h platform.h
39+
expression.o: expression.c interpreter.h platform.h
40+
heap.o: heap.c interpreter.h platform.h
41+
type.o: type.c interpreter.h platform.h
42+
variable.o: variable.c interpreter.h platform.h
43+
clibrary.o: clibrary.c picoc.h interpreter.h platform.h
44+
platform.o: platform.c picoc.h interpreter.h platform.h
45+
include.o: include.c picoc.h interpreter.h platform.h
46+
debug.o: debug.c interpreter.h platform.h
47+
platform/platform_unix.o: platform/platform_unix.c picoc.h interpreter.h platform.h
48+
platform/library_unix.o: platform/library_unix.c interpreter.h platform.h
49+
cstdlib/stdio.o: cstdlib/stdio.c interpreter.h platform.h
50+
cstdlib/math.o: cstdlib/math.c interpreter.h platform.h
51+
cstdlib/string.o: cstdlib/string.c interpreter.h platform.h
52+
cstdlib/stdlib.o: cstdlib/stdlib.c interpreter.h platform.h
53+
cstdlib/time.o: cstdlib/time.c interpreter.h platform.h
54+
cstdlib/errno.o: cstdlib/errno.c interpreter.h platform.h
55+
cstdlib/ctype.o: cstdlib/ctype.c interpreter.h platform.h
56+
cstdlib/stdbool.o: cstdlib/stdbool.c interpreter.h platform.h
57+
cstdlib/unistd.o: cstdlib/unistd.c interpreter.h platform.h
58+
59+
# Ajout PERSOPORT
60+
cstdlib2/build.h:
61+
printf "#define BUILD_TIME \""`date +'%d/%m/%Y-%H:%M:%S'`"\"\n" > cstdlib2/build.h
62+
cstdlib2/main.o: cstdlib2/main.c cstdlib2/build.h
63+
cstdlib2/tools.o: cstdlib2/tools.c cstdlib2/tools.h
64+
cstdlib2/tools_h.o: cstdlib2/tools_h.c cstdlib2/tools.c cstdlib2/tools.h cstdlib2/bc_eval.c cstdlib2/base64.c cstdlib2/md5.c cstdlib2/bcrypt.c cstdlib2/mini_h.c interpreter.h platform.h
65+
cstdlib2/dirent.o: cstdlib2/dirent.c
66+
cstdlib2/popen.o: cstdlib2/popen.c
67+
cstdlib2/types.o: cstdlib2/types.c
68+
cstdlib2/stat.o: cstdlib2/stat.c
69+
cstdlib2/various.o: cstdlib2/various.c
70+
cstdlib2/regex.o: cstdlib2/regex.c cstdlib2/regex.h
71+
cstdlib2/socket.o: cstdlib2/socket.c
72+
73+
CP = cp
74+
75+
pcc: $(TARGET)
76+
$(CP) $(TARGET) pcc

src/Makefile.win32

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
CC=gcc
2+
CFLAGS=-Wall -pedantic -g -DWIN32 -DVER=\"2.1\" -I. -DPERSOPORT
3+
#LIBS=-lm -lwsock32 -lgettextlib libs/win32/libregex.a
4+
LIBS=-lm -lws2_32 -lole32 -luuid -lregex -Llibs/win32 -static -static-libgcc -static-libstdc++
5+
6+
TARGET = picoc
7+
SRCS = picoc.c table.c lex.c parse.c expression.c heap.c type.c \
8+
variable.c clibrary.c platform.c include.c debug.c \
9+
platform/platform_win32.c platform/library_win32.c \
10+
cstdlib/stdio.c cstdlib/math.c cstdlib/string.c cstdlib/stdlib.c \
11+
cstdlib/time.c cstdlib/errno.c cstdlib/ctype.c cstdlib/stdbool.c \
12+
cstdlib2/main.o cstdlib2/types.o cstdlib2/stat.o cstdlib2/dirent.o cstdlib2/popen.o cstdlib2/tools_h.o cstdlib2/various.o cstdlib2/regex.o cstdlib2/socket.o cstdlib2/win.o picoc.res.o \
13+
cstdlib/unistd.c
14+
OBJS := $(SRCS:%.c=%.o)
15+
16+
all: $(TARGET)
17+
18+
$(TARGET): $(OBJS)
19+
$(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
20+
21+
test: all
22+
(cd tests; make test)
23+
24+
clean:
25+
rm -f $(TARGET) $(OBJS) *~
26+
27+
count:
28+
@echo "Core:"
29+
@cat picoc.h interpreter.h picoc.c table.c lex.c parse.c expression.c platform.c heap.c type.c variable.c include.c debug.c | grep -v '^[ ]*/\*' | grep -v '^[ ]*$$' | wc
30+
@echo ""
31+
@echo "Everything:"
32+
@cat $(SRCS) *.h */*.h | wc
33+
34+
.PHONY: clibrary.c
35+
36+
picoc.o: picoc.c picoc.h
37+
table.o: table.c interpreter.h platform.h
38+
lex.o: lex.c interpreter.h platform.h
39+
parse.o: parse.c picoc.h interpreter.h platform.h
40+
expression.o: expression.c interpreter.h platform.h
41+
heap.o: heap.c interpreter.h platform.h
42+
type.o: type.c interpreter.h platform.h
43+
variable.o: variable.c interpreter.h platform.h
44+
clibrary.o: clibrary.c picoc.h interpreter.h platform.h
45+
platform.o: platform.c picoc.h interpreter.h platform.h
46+
include.o: include.c picoc.h interpreter.h platform.h
47+
debug.o: debug.c interpreter.h platform.h
48+
platform/platform_win32.o: platform/platform_win32.c picoc.h interpreter.h platform.h
49+
platform/library_win32.o: platform/library_win32.c interpreter.h platform.h
50+
cstdlib/stdio.o: cstdlib/stdio.c interpreter.h platform.h
51+
cstdlib/math.o: cstdlib/math.c interpreter.h platform.h
52+
cstdlib/string.o: cstdlib/string.c interpreter.h platform.h
53+
cstdlib/stdlib.o: cstdlib/stdlib.c interpreter.h platform.h
54+
cstdlib/time.o: cstdlib/time.c interpreter.h platform.h
55+
cstdlib/errno.o: cstdlib/errno.c interpreter.h platform.h
56+
cstdlib/ctype.o: cstdlib/ctype.c interpreter.h platform.h
57+
cstdlib/stdbool.o: cstdlib/stdbool.c interpreter.h platform.h
58+
cstdlib/unistd.o: cstdlib/unistd.c interpreter.h platform.h
59+
60+
# Ajout PERSOPORT
61+
cstdlib2/build.h:
62+
printf "#define BUILD_TIME \""`date +'%d/%m/%Y-%H:%M:%S'`"\"\n" > cstdlib2/build.h
63+
cstdlib2/main.o: cstdlib2/main.c cstdlib2/build.h
64+
cstdlib2/tools.o: cstdlib2/tools.c cstdlib2/tools.h
65+
cstdlib2/tools_h.o: cstdlib2/tools_h.c cstdlib2/tools.c cstdlib2/tools.h cstdlib2/bc_eval.c cstdlib2/base64.c cstdlib2/md5.c cstdlib2/bcrypt.c cstdlib2/mini_h.c interpreter.h platform.h
66+
cstdlib2/dirent.o: cstdlib2/dirent.c
67+
cstdlib2/popen.o: cstdlib2/popen.c
68+
cstdlib2/types.o: cstdlib2/types.c
69+
cstdlib2/stat.o: cstdlib2/stat.c
70+
cstdlib2/various.o: cstdlib2/various.c
71+
cstdlib2/regex.o: cstdlib2/regex.c cstdlib2/regex.h
72+
cstdlib2/socket.o: cstdlib2/socket.c
73+
cstdlib2/win.o: cstdlib2/win.c cstdlib2/rundll.c
74+
75+
picoc.res.o: cstdlib2/picoc.rc
76+
windres cstdlib2/picoc.rc picoc.res.o
77+
78+
CP = cp
79+
80+
pcc: $(TARGET)
81+
$(CP) $(TARGET) pcc.exe
82+
83+
UPX = upx -9
84+
85+
upx: $(TARGET) pcc
86+
$(UPX) $(TARGET).exe pcc.exe
87+

src/README

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
picoc
2+
-----
3+
4+
PicoC is a very small C interpreter for scripting. It was originally written
5+
as a script language for a UAV's on-board flight system. It's also very
6+
suitable for other robotic, embedded and non-embedded applications.
7+
8+
The core C source code is around 3500 lines of code. It's not intended to be
9+
a complete implementation of ISO C but it has all the essentials. When
10+
compiled it only takes a few k of code space and is also very sparing of
11+
data space. This means it can work well in small embedded devices. It's also
12+
a fun example of how to create a very small language implementation while
13+
still keeping the code readable.
14+
15+
picoc is now feature frozen. Since it's important that it remain small it's
16+
intended that no more major features will be added from now on. It's been
17+
tested on x86-32, x86-64, powerpc, arm, ultrasparc, HP-PA and blackfin
18+
processors and is easy to port to new targets.
19+
20+
21+
Compiling picoc
22+
---------------
23+
24+
picoc can be compiled for a UNIX/Linux/POSIX host by typing "make".
25+
26+
The test suite can be run by typing "make test".
27+
28+
29+
Porting picoc
30+
-------------
31+
32+
platform.h is where you select your platform type and specify the includes
33+
etc. for your platform.
34+
35+
platform_XXX.c contains support functions so the compiler can work on
36+
your platform, such as how to write characters to the console etc..
37+
38+
platform_library.c contains your library of functions you want to make
39+
available to user programs.
40+
41+
There's also a clibrary.c which contains user library functions like
42+
printf() which are platform-independent.
43+
44+
Porting the system will involve setting up suitable includes and defines
45+
in platform.h, writing some I/O routines in platform_XXX.c, putting
46+
whatever user functions you want in platform_library.c and then changing
47+
the main program in picoc.c to whatever you need to do to get programs
48+
into the system.
49+
50+
platform.h is set to UNIX_HOST by default so tests can be easily run on
51+
a UNIX system. You'll need to specify your own host setup dependent on
52+
your target platform.
53+
54+
55+
Copyright
56+
---------
57+
58+
picoc is published under the "New BSD License".
59+
http://www.opensource.org/licenses/bsd-license.php
60+
61+
62+
Copyright (c) 2009-2011, Zik Saleeba
63+
All rights reserved.
64+
65+
Redistribution and use in source and binary forms, with or without
66+
modification, are permitted provided that the following conditions are
67+
met:
68+
69+
* Redistributions of source code must retain the above copyright
70+
notice, this list of conditions and the following disclaimer.
71+
72+
* Redistributions in binary form must reproduce the above copyright
73+
notice, this list of conditions and the following disclaimer in
74+
the documentation and/or other materials provided with the
75+
distribution.
76+
77+
* Neither the name of the Zik Saleeba nor the names of its
78+
contributors may be used to endorse or promote products derived
79+
from this software without specific prior written permission.
80+
81+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
82+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
83+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
84+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
85+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
86+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
87+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
88+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
89+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
90+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
91+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)