aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2010-05-21 09:05:39 +0300
committerEli Bendersky <eliben@gmail.com>2010-05-21 09:05:39 +0300
commit3921e8e23ef7952e2e118e9d534cfc4a221e2450 (patch)
tree60efcf9f007a5657422a75ed0aad28cb97cb3fa2 /utils
downloadpycparser-3921e8e23ef7952e2e118e9d534cfc4a221e2450.tar.gz
initial import from SVN
Diffstat (limited to 'utils')
-rw-r--r--utils/cpp.exebin0 -> 196608 bytes
-rw-r--r--utils/fake_libc_include/_ansi.h2
-rw-r--r--utils/fake_libc_include/_fake_defines.h28
-rw-r--r--utils/fake_libc_include/_fake_typedefs.h80
-rw-r--r--utils/fake_libc_include/_syslist.h2
-rw-r--r--utils/fake_libc_include/alloca.h2
-rw-r--r--utils/fake_libc_include/ar.h2
-rw-r--r--utils/fake_libc_include/argz.h2
-rw-r--r--utils/fake_libc_include/assert.h2
-rw-r--r--utils/fake_libc_include/ctype.h2
-rw-r--r--utils/fake_libc_include/dirent.h2
-rw-r--r--utils/fake_libc_include/envz.h2
-rw-r--r--utils/fake_libc_include/errno.h2
-rw-r--r--utils/fake_libc_include/fastmath.h2
-rw-r--r--utils/fake_libc_include/fcntl.h2
-rw-r--r--utils/fake_libc_include/getopt.h2
-rw-r--r--utils/fake_libc_include/grp.h2
-rw-r--r--utils/fake_libc_include/iconv.h2
-rw-r--r--utils/fake_libc_include/ieeefp.h2
-rw-r--r--utils/fake_libc_include/inttypes.h2
-rw-r--r--utils/fake_libc_include/langinfo.h2
-rw-r--r--utils/fake_libc_include/libgen.h2
-rw-r--r--utils/fake_libc_include/limits.h2
-rw-r--r--utils/fake_libc_include/locale.h2
-rw-r--r--utils/fake_libc_include/malloc.h2
-rw-r--r--utils/fake_libc_include/math.h2
-rw-r--r--utils/fake_libc_include/newlib.h2
-rw-r--r--utils/fake_libc_include/paths.h2
-rw-r--r--utils/fake_libc_include/process.h2
-rw-r--r--utils/fake_libc_include/pthread.h2
-rw-r--r--utils/fake_libc_include/pwd.h2
-rw-r--r--utils/fake_libc_include/reent.h2
-rw-r--r--utils/fake_libc_include/regdef.h2
-rw-r--r--utils/fake_libc_include/sched.h2
-rw-r--r--utils/fake_libc_include/search.h2
-rw-r--r--utils/fake_libc_include/setjmp.h2
-rw-r--r--utils/fake_libc_include/signal.h2
-rw-r--r--utils/fake_libc_include/stdarg.h2
-rw-r--r--utils/fake_libc_include/stddef.h2
-rw-r--r--utils/fake_libc_include/stdint.h2
-rw-r--r--utils/fake_libc_include/stdio.h2
-rw-r--r--utils/fake_libc_include/stdlib.h2
-rw-r--r--utils/fake_libc_include/string.h2
-rw-r--r--utils/fake_libc_include/tar.h2
-rw-r--r--utils/fake_libc_include/termios.h2
-rw-r--r--utils/fake_libc_include/time.h2
-rw-r--r--utils/fake_libc_include/unctrl.h2
-rw-r--r--utils/fake_libc_include/unistd.h2
-rw-r--r--utils/fake_libc_include/utime.h2
-rw-r--r--utils/fake_libc_include/utmp.h2
-rw-r--r--utils/fake_libc_include/wchar.h2
-rw-r--r--utils/fake_libc_include/wctype.h2
-rw-r--r--utils/internal/cppify.bat3
-rw-r--r--utils/internal/example_c_file.c25
-rw-r--r--utils/internal/fake_includes.py13
-rw-r--r--utils/internal/make_fake_typedefs.py21
-rw-r--r--utils/internal/zc.c107
-rw-r--r--utils/internal/zz_parse.py10
58 files changed, 385 insertions, 0 deletions
diff --git a/utils/cpp.exe b/utils/cpp.exe
new file mode 100644
index 0000000..60c7787
--- /dev/null
+++ b/utils/cpp.exe
Binary files differ
diff --git a/utils/fake_libc_include/_ansi.h b/utils/fake_libc_include/_ansi.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/_ansi.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/_fake_defines.h b/utils/fake_libc_include/_fake_defines.h
new file mode 100644
index 0000000..4a30792
--- /dev/null
+++ b/utils/fake_libc_include/_fake_defines.h
@@ -0,0 +1,28 @@
+#ifndef _FAKE_DEFINES_H
+#define _FAKE_DEFINES_H
+
+#define NULL 0
+#define BUFSIZ 1024
+#define FOPEN_MAX 20
+#define FILENAME_MAX 1024
+
+#ifndef SEEK_SET
+#define SEEK_SET 0 /* set file offset to offset */
+#endif
+#ifndef SEEK_CUR
+#define SEEK_CUR 1 /* set file offset to current plus offset */
+#endif
+#ifndef SEEK_END
+#define SEEK_END 2 /* set file offset to EOF plus offset */
+#endif
+
+
+#define EXIT_FAILURE 1
+#define EXIT_SUCCESS 0
+
+#define RAND_MAX 32767
+#define INT_MAX 32767
+
+
+
+#endif
diff --git a/utils/fake_libc_include/_fake_typedefs.h b/utils/fake_libc_include/_fake_typedefs.h
new file mode 100644
index 0000000..344cbc6
--- /dev/null
+++ b/utils/fake_libc_include/_fake_typedefs.h
@@ -0,0 +1,80 @@
+#ifndef _FAKE_TYPEDEFS_H
+#define _FAKE_TYPEDEFS_H
+
+typedef int size_t;
+typedef int __builtin_va_list;
+typedef int __gnuc_va_list;
+typedef int __int8_t;
+typedef int __uint8_t;
+typedef int __int16_t;
+typedef int __uint16_t;
+typedef int __int_least16_t;
+typedef int __uint_least16_t;
+typedef int __int32_t;
+typedef int __uint32_t;
+typedef int __int_least32_t;
+typedef int __uint_least32_t;
+typedef int _LOCK_T;
+typedef int _LOCK_RECURSIVE_T;
+typedef int _off_t;
+typedef int __dev_t;
+typedef int __uid_t;
+typedef int __gid_t;
+typedef int _off64_t;
+typedef int _fpos_t;
+typedef int _ssize_t;
+typedef int wint_t;
+typedef int _mbstate_t;
+typedef int _flock_t;
+typedef int _iconv_t;
+typedef int __ULong;
+typedef int __FILE;
+typedef int ptrdiff_t;
+typedef int wchar_t;
+typedef int __off_t;
+typedef int __pid_t;
+typedef int __loff_t;
+typedef int u_char;
+typedef int u_short;
+typedef int u_int;
+typedef int u_long;
+typedef int ushort;
+typedef int uint;
+typedef int clock_t;
+typedef int time_t;
+typedef int daddr_t;
+typedef int caddr_t;
+typedef int ino_t;
+typedef int off_t;
+typedef int dev_t;
+typedef int uid_t;
+typedef int gid_t;
+typedef int pid_t;
+typedef int key_t;
+typedef int ssize_t;
+typedef int mode_t;
+typedef int nlink_t;
+typedef int fd_mask;
+typedef int _types_fd_set;
+typedef int clockid_t;
+typedef int timer_t;
+typedef int useconds_t;
+typedef int suseconds_t;
+typedef int FILE;
+typedef int fpos_t;
+typedef int cookie_read_function_t;
+typedef int cookie_write_function_t;
+typedef int cookie_seek_function_t;
+typedef int cookie_close_function_t;
+typedef int cookie_io_functions_t;
+typedef int div_t;
+typedef int ldiv_t;
+typedef int lldiv_t;
+typedef int sigset_t;
+typedef int _sig_func_ptr;
+typedef int sig_atomic_t;
+typedef int __tzrule_type;
+typedef int __tzinfo_type;
+typedef int mbstate_t;
+
+#endif
diff --git a/utils/fake_libc_include/_syslist.h b/utils/fake_libc_include/_syslist.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/_syslist.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/alloca.h b/utils/fake_libc_include/alloca.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/alloca.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/ar.h b/utils/fake_libc_include/ar.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/ar.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/argz.h b/utils/fake_libc_include/argz.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/argz.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/assert.h b/utils/fake_libc_include/assert.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/assert.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/ctype.h b/utils/fake_libc_include/ctype.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/ctype.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/dirent.h b/utils/fake_libc_include/dirent.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/dirent.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/envz.h b/utils/fake_libc_include/envz.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/envz.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/errno.h b/utils/fake_libc_include/errno.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/errno.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/fastmath.h b/utils/fake_libc_include/fastmath.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/fastmath.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/fcntl.h b/utils/fake_libc_include/fcntl.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/fcntl.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/getopt.h b/utils/fake_libc_include/getopt.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/getopt.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/grp.h b/utils/fake_libc_include/grp.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/grp.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/iconv.h b/utils/fake_libc_include/iconv.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/iconv.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/ieeefp.h b/utils/fake_libc_include/ieeefp.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/ieeefp.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/inttypes.h b/utils/fake_libc_include/inttypes.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/inttypes.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/langinfo.h b/utils/fake_libc_include/langinfo.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/langinfo.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/libgen.h b/utils/fake_libc_include/libgen.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/libgen.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/limits.h b/utils/fake_libc_include/limits.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/limits.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/locale.h b/utils/fake_libc_include/locale.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/locale.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/malloc.h b/utils/fake_libc_include/malloc.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/malloc.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/math.h b/utils/fake_libc_include/math.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/math.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/newlib.h b/utils/fake_libc_include/newlib.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/newlib.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/paths.h b/utils/fake_libc_include/paths.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/paths.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/process.h b/utils/fake_libc_include/process.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/process.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/pthread.h b/utils/fake_libc_include/pthread.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/pthread.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/pwd.h b/utils/fake_libc_include/pwd.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/pwd.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/reent.h b/utils/fake_libc_include/reent.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/reent.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/regdef.h b/utils/fake_libc_include/regdef.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/regdef.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/sched.h b/utils/fake_libc_include/sched.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/sched.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/search.h b/utils/fake_libc_include/search.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/search.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/setjmp.h b/utils/fake_libc_include/setjmp.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/setjmp.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/signal.h b/utils/fake_libc_include/signal.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/signal.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/stdarg.h b/utils/fake_libc_include/stdarg.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/stdarg.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/stddef.h b/utils/fake_libc_include/stddef.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/stddef.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/stdint.h b/utils/fake_libc_include/stdint.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/stdint.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/stdio.h b/utils/fake_libc_include/stdio.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/stdio.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/stdlib.h b/utils/fake_libc_include/stdlib.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/stdlib.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/string.h b/utils/fake_libc_include/string.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/string.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/tar.h b/utils/fake_libc_include/tar.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/tar.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/termios.h b/utils/fake_libc_include/termios.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/termios.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/time.h b/utils/fake_libc_include/time.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/time.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/unctrl.h b/utils/fake_libc_include/unctrl.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/unctrl.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/unistd.h b/utils/fake_libc_include/unistd.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/unistd.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/utime.h b/utils/fake_libc_include/utime.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/utime.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/utmp.h b/utils/fake_libc_include/utmp.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/utmp.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/wchar.h b/utils/fake_libc_include/wchar.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/wchar.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/fake_libc_include/wctype.h b/utils/fake_libc_include/wctype.h
new file mode 100644
index 0000000..f2992f3
--- /dev/null
+++ b/utils/fake_libc_include/wctype.h
@@ -0,0 +1,2 @@
+#include "_fake_defines.h"
+#include "_fake_typedefs.h"
diff --git a/utils/internal/cppify.bat b/utils/internal/cppify.bat
new file mode 100644
index 0000000..fb16db5
--- /dev/null
+++ b/utils/internal/cppify.bat
@@ -0,0 +1,3 @@
+REM ~ ..\cpp -D__i386__ -I"D:\eli\cpp_stuff\libc_include" -D__extension__ example_c_file.c > example_c_file_pp.c
+REM ~ ..\cpp -D__i386__ -I"D:\eli\c_analyzing\pycparser-trunk\utils\fake_libc_include" example_c_file.c > example_c_file_pp.c
+..\cpp -D__i386__ -I"D:\eli\c_analyzing\pycparser-trunk\utils\fake_libc_include" zc.c > zc_pp.c
diff --git a/utils/internal/example_c_file.c b/utils/internal/example_c_file.c
new file mode 100644
index 0000000..44564ac
--- /dev/null
+++ b/utils/internal/example_c_file.c
@@ -0,0 +1,25 @@
+/* a comment / */
+/* "not a string" */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <ctype.h>
+#include <signal.h>
+#include <time.h>
+#include <wchar.h>
+
+/*
+ multiline comment
+ comment
+*/
+
+int main()
+{
+ auto char* multi = "a multi"; /* and a comment !*/
+}
+
+/* A final comment for good measure /* /* /* */
+
+
+
diff --git a/utils/internal/fake_includes.py b/utils/internal/fake_includes.py
new file mode 100644
index 0000000..b55f767
--- /dev/null
+++ b/utils/internal/fake_includes.py
@@ -0,0 +1,13 @@
+import os.path
+
+for cur_path, dirs, files in os.walk('.'):
+ if cur_path == '.':
+ for f in files:
+ if f.endswith('.h'):
+ print f
+ fo = open(f, 'w')
+ fo.write('#include "_fake_defines.h"\n')
+ fo.write('#include "_fake_typedefs.h"\n')
+ fo.close()
+
+
diff --git a/utils/internal/make_fake_typedefs.py b/utils/internal/make_fake_typedefs.py
new file mode 100644
index 0000000..68f57b3
--- /dev/null
+++ b/utils/internal/make_fake_typedefs.py
@@ -0,0 +1,21 @@
+import sys
+sys.path.insert(0, '../..')
+
+from pycparser import c_parser, c_ast, parse_file
+
+
+class MyVisitor(c_ast.NodeVisitor):
+ def visit_Typedef(self, node):
+ print 'typedef int %s;' % node.name
+
+
+
+def generate_fake_typedefs(filename):
+ ast = parse_file(filename, use_cpp=True, cpp_path="../cpp.exe")
+ v = MyVisitor()
+ v.visit(ast)
+
+
+if __name__ == "__main__":
+ generate_fake_typedefs('example_c_file_pp.c')
+
diff --git a/utils/internal/zc.c b/utils/internal/zc.c
new file mode 100644
index 0000000..eff94bd
--- /dev/null
+++ b/utils/internal/zc.c
@@ -0,0 +1,107 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+
+#define PACKAGE "wgram"
+#define VERSION "0.0.4"
+#define MAXLINE 1024
+#define MAXGRAM 32
+
+/* status epilepticus .. print help */
+void print_help(int exval);
+
+int main (int argc, char *argv[]) {
+ /* word delimeter for strtok() */
+ char delim[] = ".,:;`/\"+-_(){}[]<>*&^%$#@!?~/|\\=1234567890 \t\n";
+ char line[MAXLINE]; /* input buff, fgets() */
+ char *stray = NULL; /* returned value by strtok() */
+ char **strarray = NULL; /* array to hold all entrys */
+ int i = 0; /* general counter */
+ int strcount = 0; /* number of entrys in pointer array */
+ int N = 3, pos = 0; /* ngram size, 3 in this case */
+ int opt = 0; /* holds command line opt nr.. */
+ int word_flag = 0; /* print only the `raw' words */
+ FILE *fp = stdin; /* read input from `FILE', default is stdin */
+
+ while((opt = getopt(argc, argv, "hvn:wf:")) != -1) {
+ switch(opt) {
+ case 'h':
+ print_help(0);
+ break;
+ case 'v':
+ exit(0);
+ break;
+ case 'n':
+ N = atoi(optarg);
+ if(N > MAXGRAM || N < 2) {
+ fprintf(stderr, "%s: Error - Ngram length `%d' out of range `0-%d'\n",
+ PACKAGE, N, MAXGRAM);
+ return 1;
+ }
+ break;
+ case 'w':
+ word_flag = 1;
+ break;
+ case 'f':
+ if(freopen(optarg, "r", fp) == NULL) {
+ fprintf(stderr, "%s: Error - opening `%s'\n", PACKAGE, optarg);
+ return 1;
+ }
+ break;
+ case '?':
+ fprintf(stderr, "%s: Error - No such option: `%c'\n\n", PACKAGE, optopt);
+ print_help(1);
+ } /* switch */
+ } /* while */
+
+ /* start reading lines from file pointer, add all entrys to **strarray */
+ while((fgets(line, MAXLINE, fp)) != NULL) {
+ if(strlen(line) < 2)
+ continue;
+
+ stray = strtok(line, delim);
+ while(stray != NULL) {
+ strarray = (char **)realloc(strarray, (strcount + 1) * sizeof(char *));
+ strarray[strcount++] = strdup(stray);
+ stray = strtok(NULL, delim);
+ }
+ }
+
+ if(word_flag == 0) {
+ /*
+ // print the array of strings, jumping back each time
+ // (N - 1) positions if a whole ngram of words has been printed
+ */
+ for(i = 0, pos = N; i < strcount; i++, pos--) {
+ if(pos == 0) pos = N, i -= (N - 1), printf("\n");
+ printf("%s ", strarray[i]);
+ }
+ printf("\n");
+ } else {
+ /* print raw words */
+ for(i = 0; i < strcount; i++)
+ printf("%s\n", strarray[i]);
+ }
+
+ /* free the string array */
+ for(i = 0; i < strcount; i++)
+ free(strarray[i]);
+
+ free(strarray);
+ return 0;
+}
+
+/* status epilepticus .. print help */
+void print_help(int exval) {
+ printf("%s,%s extract N-grams from text data\n", PACKAGE, VERSION);
+ printf("Usage: %s [-h] [-v] [-n INT] [-w] [-f FILE]\n\n", PACKAGE);
+
+ printf(" -h print this help and exit\n");
+ printf(" -v print version and exit\n\n");
+
+ printf(" -n INT set ngram length (default=3)\n");
+ printf(" -w print only the extracted words\n");
+ printf(" -f FILE read input from `FILE' (default=stdin)\n\n");
+ exit(exval);
+}
diff --git a/utils/internal/zz_parse.py b/utils/internal/zz_parse.py
new file mode 100644
index 0000000..6251a9f
--- /dev/null
+++ b/utils/internal/zz_parse.py
@@ -0,0 +1,10 @@
+import sys
+sys.path.insert(0, '../..')
+
+from pycparser import c_parser, c_ast, parse_file
+
+
+if __name__ == "__main__":
+ ast = parse_file('zc_pp.c', use_cpp=True, cpp_path="../cpp.exe")
+
+