-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b7ad56a
Showing
527 changed files
with
116,776 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.txt -crlf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin | ||
link.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Origins | ||
**pico-c** is a project created by Zik at [https://code.google.com/p/picoc](https://code.google.com/p/picoc/ "Google code"). | ||
The projet is now hosted at [https://gitlab.com/zsaleeba/picoc](https://gitlab.com/zsaleeba/picoc/ "Github.com"). | ||
|
||
**pico-c** intends to be a very light **C** interpreter. **pico-c** is very small, but include many standard libraries. | ||
|
||
# The content | ||
Initially those libraries were natively integrated into pico-c: | ||
|
||
* ctype.h | ||
* errno.h | ||
* math.h | ||
* stdbool.h | ||
* stdio.h | ||
* stdlib.h | ||
* string.h | ||
* time.h | ||
* unistd.h | ||
|
||
Some of them were improved: | ||
|
||
* stdio.h | ||
* unistd.h | ||
|
||
We have planned to add support for 3 other useful libraries: | ||
|
||
* dirent.h | ||
* regex.h | ||
* socket.h | ||
* stat.h | ||
|
||
# The pico-c syntax | ||
|
||
``` | ||
$ pico-c -h | ||
pico-c.exe, A very small C interpreter | ||
Usage: pico-c.exe [-h] [-i] [-m] [-n] [-o] [<filename1>...] [- <arg1>...] | ||
-h: this help message | ||
-i: force interactive mode at the end of scripts | ||
-m: run main() function automaticaly | ||
-n: don't print prompt | ||
-o: the original "old" mode | ||
-v: print version | ||
Exemples: | ||
pico-c.exe script1.pcc script2.pcc | ||
pico-c.exe -i script.pcc | ||
pico-c.exe -m script1.pcc script2.pcc - arg1 agr2} | ||
``` | ||
|
||
**Cyd** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
CC=gcc | ||
CFLAGS=-Wall -pedantic -g -DUNIX_HOST -DVER=\"2.1\" -DPERSOPORT | ||
LIBS=-lm -lreadline | ||
|
||
TARGET = picoc | ||
SRCS = picoc.c table.c lex.c parse.c expression.c heap.c type.c \ | ||
variable.c clibrary.c platform.c include.c debug.c \ | ||
platform/platform_unix.c platform/library_unix.c \ | ||
cstdlib/stdio.c cstdlib/math.c cstdlib/string.c cstdlib/stdlib.c \ | ||
cstdlib/time.c cstdlib/errno.c cstdlib/ctype.c cstdlib/stdbool.c \ | ||
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 \ | ||
cstdlib/unistd.c | ||
OBJS := $(SRCS:%.c=%.o) | ||
|
||
all: $(TARGET) | ||
|
||
$(TARGET): $(OBJS) | ||
$(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(LIBS) | ||
|
||
test: all | ||
(cd tests; make test) | ||
|
||
clean: | ||
rm -f $(TARGET) $(OBJS) *~ *.o | ||
|
||
count: | ||
@echo "Core:" | ||
@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 | ||
@echo "" | ||
@echo "Everything:" | ||
@cat $(SRCS) *.h */*.h | wc | ||
|
||
.PHONY: clibrary.c | ||
|
||
picoc.o: picoc.c picoc.h | ||
table.o: table.c interpreter.h platform.h | ||
lex.o: lex.c interpreter.h platform.h | ||
parse.o: parse.c picoc.h interpreter.h platform.h | ||
expression.o: expression.c interpreter.h platform.h | ||
heap.o: heap.c interpreter.h platform.h | ||
type.o: type.c interpreter.h platform.h | ||
variable.o: variable.c interpreter.h platform.h | ||
clibrary.o: clibrary.c picoc.h interpreter.h platform.h | ||
platform.o: platform.c picoc.h interpreter.h platform.h | ||
include.o: include.c picoc.h interpreter.h platform.h | ||
debug.o: debug.c interpreter.h platform.h | ||
platform/platform_unix.o: platform/platform_unix.c picoc.h interpreter.h platform.h | ||
platform/library_unix.o: platform/library_unix.c interpreter.h platform.h | ||
cstdlib/stdio.o: cstdlib/stdio.c interpreter.h platform.h | ||
cstdlib/math.o: cstdlib/math.c interpreter.h platform.h | ||
cstdlib/string.o: cstdlib/string.c interpreter.h platform.h | ||
cstdlib/stdlib.o: cstdlib/stdlib.c interpreter.h platform.h | ||
cstdlib/time.o: cstdlib/time.c interpreter.h platform.h | ||
cstdlib/errno.o: cstdlib/errno.c interpreter.h platform.h | ||
cstdlib/ctype.o: cstdlib/ctype.c interpreter.h platform.h | ||
cstdlib/stdbool.o: cstdlib/stdbool.c interpreter.h platform.h | ||
cstdlib/unistd.o: cstdlib/unistd.c interpreter.h platform.h | ||
|
||
# Ajout PERSOPORT | ||
cstdlib2/build.h: | ||
printf "#define BUILD_TIME \""`date +'%d/%m/%Y-%H:%M:%S'`"\"\n" > cstdlib2/build.h | ||
cstdlib2/main.o: cstdlib2/main.c cstdlib2/build.h | ||
cstdlib2/tools.o: cstdlib2/tools.c cstdlib2/tools.h | ||
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 | ||
cstdlib2/dirent.o: cstdlib2/dirent.c | ||
cstdlib2/popen.o: cstdlib2/popen.c | ||
cstdlib2/types.o: cstdlib2/types.c | ||
cstdlib2/stat.o: cstdlib2/stat.c | ||
cstdlib2/various.o: cstdlib2/various.c | ||
cstdlib2/regex.o: cstdlib2/regex.c cstdlib2/regex.h | ||
cstdlib2/socket.o: cstdlib2/socket.c | ||
|
||
CP = cp | ||
|
||
pcc: $(TARGET) | ||
$(CP) $(TARGET) pcc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
CC=gcc | ||
CFLAGS=-Wall -pedantic -g -DWIN32 -DVER=\"2.1\" -I. -DPERSOPORT | ||
#LIBS=-lm -lwsock32 -lgettextlib libs/win32/libregex.a | ||
LIBS=-lm -lws2_32 -lole32 -luuid -lregex -Llibs/win32 -static -static-libgcc -static-libstdc++ | ||
|
||
TARGET = picoc | ||
SRCS = picoc.c table.c lex.c parse.c expression.c heap.c type.c \ | ||
variable.c clibrary.c platform.c include.c debug.c \ | ||
platform/platform_win32.c platform/library_win32.c \ | ||
cstdlib/stdio.c cstdlib/math.c cstdlib/string.c cstdlib/stdlib.c \ | ||
cstdlib/time.c cstdlib/errno.c cstdlib/ctype.c cstdlib/stdbool.c \ | ||
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 \ | ||
cstdlib/unistd.c | ||
OBJS := $(SRCS:%.c=%.o) | ||
|
||
all: $(TARGET) | ||
|
||
$(TARGET): $(OBJS) | ||
$(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(LIBS) | ||
|
||
test: all | ||
(cd tests; make test) | ||
|
||
clean: | ||
rm -f $(TARGET) $(OBJS) *~ | ||
|
||
count: | ||
@echo "Core:" | ||
@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 | ||
@echo "" | ||
@echo "Everything:" | ||
@cat $(SRCS) *.h */*.h | wc | ||
|
||
.PHONY: clibrary.c | ||
|
||
picoc.o: picoc.c picoc.h | ||
table.o: table.c interpreter.h platform.h | ||
lex.o: lex.c interpreter.h platform.h | ||
parse.o: parse.c picoc.h interpreter.h platform.h | ||
expression.o: expression.c interpreter.h platform.h | ||
heap.o: heap.c interpreter.h platform.h | ||
type.o: type.c interpreter.h platform.h | ||
variable.o: variable.c interpreter.h platform.h | ||
clibrary.o: clibrary.c picoc.h interpreter.h platform.h | ||
platform.o: platform.c picoc.h interpreter.h platform.h | ||
include.o: include.c picoc.h interpreter.h platform.h | ||
debug.o: debug.c interpreter.h platform.h | ||
platform/platform_win32.o: platform/platform_win32.c picoc.h interpreter.h platform.h | ||
platform/library_win32.o: platform/library_win32.c interpreter.h platform.h | ||
cstdlib/stdio.o: cstdlib/stdio.c interpreter.h platform.h | ||
cstdlib/math.o: cstdlib/math.c interpreter.h platform.h | ||
cstdlib/string.o: cstdlib/string.c interpreter.h platform.h | ||
cstdlib/stdlib.o: cstdlib/stdlib.c interpreter.h platform.h | ||
cstdlib/time.o: cstdlib/time.c interpreter.h platform.h | ||
cstdlib/errno.o: cstdlib/errno.c interpreter.h platform.h | ||
cstdlib/ctype.o: cstdlib/ctype.c interpreter.h platform.h | ||
cstdlib/stdbool.o: cstdlib/stdbool.c interpreter.h platform.h | ||
cstdlib/unistd.o: cstdlib/unistd.c interpreter.h platform.h | ||
|
||
# Ajout PERSOPORT | ||
cstdlib2/build.h: | ||
printf "#define BUILD_TIME \""`date +'%d/%m/%Y-%H:%M:%S'`"\"\n" > cstdlib2/build.h | ||
cstdlib2/main.o: cstdlib2/main.c cstdlib2/build.h | ||
cstdlib2/tools.o: cstdlib2/tools.c cstdlib2/tools.h | ||
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 | ||
cstdlib2/dirent.o: cstdlib2/dirent.c | ||
cstdlib2/popen.o: cstdlib2/popen.c | ||
cstdlib2/types.o: cstdlib2/types.c | ||
cstdlib2/stat.o: cstdlib2/stat.c | ||
cstdlib2/various.o: cstdlib2/various.c | ||
cstdlib2/regex.o: cstdlib2/regex.c cstdlib2/regex.h | ||
cstdlib2/socket.o: cstdlib2/socket.c | ||
cstdlib2/win.o: cstdlib2/win.c cstdlib2/rundll.c | ||
|
||
picoc.res.o: cstdlib2/picoc.rc | ||
windres cstdlib2/picoc.rc picoc.res.o | ||
|
||
CP = cp | ||
|
||
pcc: $(TARGET) | ||
$(CP) $(TARGET) pcc.exe | ||
|
||
UPX = upx -9 | ||
|
||
upx: $(TARGET) pcc | ||
$(UPX) $(TARGET).exe pcc.exe | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
picoc | ||
----- | ||
|
||
PicoC is a very small C interpreter for scripting. It was originally written | ||
as a script language for a UAV's on-board flight system. It's also very | ||
suitable for other robotic, embedded and non-embedded applications. | ||
|
||
The core C source code is around 3500 lines of code. It's not intended to be | ||
a complete implementation of ISO C but it has all the essentials. When | ||
compiled it only takes a few k of code space and is also very sparing of | ||
data space. This means it can work well in small embedded devices. It's also | ||
a fun example of how to create a very small language implementation while | ||
still keeping the code readable. | ||
|
||
picoc is now feature frozen. Since it's important that it remain small it's | ||
intended that no more major features will be added from now on. It's been | ||
tested on x86-32, x86-64, powerpc, arm, ultrasparc, HP-PA and blackfin | ||
processors and is easy to port to new targets. | ||
|
||
|
||
Compiling picoc | ||
--------------- | ||
|
||
picoc can be compiled for a UNIX/Linux/POSIX host by typing "make". | ||
|
||
The test suite can be run by typing "make test". | ||
|
||
|
||
Porting picoc | ||
------------- | ||
|
||
platform.h is where you select your platform type and specify the includes | ||
etc. for your platform. | ||
|
||
platform_XXX.c contains support functions so the compiler can work on | ||
your platform, such as how to write characters to the console etc.. | ||
|
||
platform_library.c contains your library of functions you want to make | ||
available to user programs. | ||
|
||
There's also a clibrary.c which contains user library functions like | ||
printf() which are platform-independent. | ||
|
||
Porting the system will involve setting up suitable includes and defines | ||
in platform.h, writing some I/O routines in platform_XXX.c, putting | ||
whatever user functions you want in platform_library.c and then changing | ||
the main program in picoc.c to whatever you need to do to get programs | ||
into the system. | ||
|
||
platform.h is set to UNIX_HOST by default so tests can be easily run on | ||
a UNIX system. You'll need to specify your own host setup dependent on | ||
your target platform. | ||
|
||
|
||
Copyright | ||
--------- | ||
|
||
picoc is published under the "New BSD License". | ||
http://www.opensource.org/licenses/bsd-license.php | ||
|
||
|
||
Copyright (c) 2009-2011, Zik Saleeba | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in | ||
the documentation and/or other materials provided with the | ||
distribution. | ||
|
||
* Neither the name of the Zik Saleeba nor the names of its | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Oops, something went wrong.