Commit graph

122 commits

Author SHA1 Message Date
Dale Weiler
fa155f8a42 Added my awesome MT1997 PRNG, and use it instead of stdio's rand()/srand() .. which are implementation specific .. and simply unsafe (for example one of the compilers at work simply has it's standard library implementation of rand() return 0 always (which is perfectly conformant)). 2012-12-24 01:43:27 +00:00
Dale Weiler
0a57c408c0 Added ftepp predefs flag (ability to turn on/off predefs) disabled by default (even with -ftepp), enabled with -E, to enable use -fftepp-predefs. 2012-12-24 00:21:55 +00:00
Dale Weiler
bd12429cd0 Implemented __FILE__, __LINE__, __RANDOM__, __RANDOM_LAST__, __COUNTER__ and __COUNTER_LAST__ as predefined macros. __FUNCTION__ is not implemented yet due to the overall complexity in making it constant. 2012-12-24 00:12:24 +00:00
Dale Weiler
c3964cf29d Make compiler and virtual-machine compile as C++ code, also removed gmqcc_voidptr hack. 2012-12-23 07:51:19 +00:00
Dale Weiler
13003bf6af Wrapper around FILE to take advantage of MSVC "secure" CRT. We don't actually defend bounds checks (we just hack in the few ones to silent MSVC .. and to pass WinRT "native code" rules) 2012-12-23 06:05:22 +00:00
Dale Weiler
3c003bc168 Get gmqcc/qcvm compiling on windows again. Plus work in progress support for the testsuite on windows (does not compile yet). 2012-12-21 01:00:51 -05:00
Dale Weiler
f78ab9061b added -Wcpp (for turning off cpp warnings defined with #warning like GCC/clang/pathscale .. no more [-Wunused-variable]) 2012-12-21 03:12:58 +00:00
Dale Weiler
36a90bb866 Implemented #warning and #error preprocessor directives, they're functionally equivalent to CPPs (supporting both string constant and non-string constant versions). Warnings however are printed with a [-Wunused-variable] which isn't correct (TODO: allow systematic changes of -W paramaters in relation to warning fields for preprocessor directives. 2012-12-21 03:08:21 +00:00
Wolfgang (Blub) Bumiller
0f99ae3459 ftepp_warn to use vcompile_warning 2012-12-17 18:24:16 +01:00
Dale Weiler
e72d656eb8 Fixes, but still crashes because ... I have no clue, there is no reason for this to crash. 2012-12-17 15:39:22 +00:00
Dale Weiler
c1c7a93884 Implemented -D for preprocessor 2012-12-17 14:58:55 +00:00
Wolfgang (Blub) Bumiller
f9b1d057b5 Moving all the global opts_ variables into a struct, now there's one global 'opts' struct 2012-12-06 13:23:53 +01:00
Wolfgang (Blub) Bumiller
ea08d16c06 ftepp_preprocess_string uses strlen - push nul-byte to verminor and vermajor 2012-12-03 20:23:40 +01:00
Dale Weiler
37ccf19769 added __STD_VERSION_[MINOR/MAJOR]__, and vec_upload 2012-12-02 04:30:46 +00:00
Wolfgang (Blub) Bumiller
44cbf40553 We can now reintroduce the 'preprocessor-directives only after newlines' rule correctly 2012-11-30 15:53:53 +01:00
Wolfgang (Blub) Bumiller
41cb923c0c Wrong condition *sigh* 2012-11-30 15:43:18 +01:00
Wolfgang (Blub) Bumiller
0627e9e06e Still have to parse ahead though 2012-11-30 15:41:01 +01:00
Wolfgang (Blub) Bumiller
b78dab9d71 Don't expand macros inside #if 0 at _all_ 2012-11-30 15:40:19 +01:00
Wolfgang (Blub) Bumiller
7f915c0f2a Don't try to add a slash to actual filenames, only paths... 2012-11-30 15:26:14 +01:00
Dale Weiler
ca52ecc20a Remove trailing whitespace for Blub. 2012-11-26 11:12:06 +00:00
Wolfgang (Blub) Bumiller
b457bfec2a linecounting... 2012-11-25 18:02:54 +01:00
Wolfgang (Blub) Bumiller
07fa97b8e7 linecounting issues in the ftepp 2012-11-25 16:08:41 +01:00
Wolfgang (Blub) Bumiller
e7bf73455d always define GMQCC, never define FTEQCC or QCC, but have __STD_FTEQCC__ and the likes for -std=qcc/gmqcc/fteqcc 2012-11-25 14:29:06 +01:00
Dale Weiler
8bce855f0b Set correct macro for PP based on the selected standard 2012-11-24 00:37:36 +00:00
Wolfgang (Blub) Bumiller
74fce32233 relation operation in #if just as wrong as in fteqcc 2012-11-23 21:05:07 +01:00
Wolfgang (Blub) Bumiller
58c87ac328 Enforce a trailing nul-byte after preprocessing 2012-11-23 19:34:24 +01:00
Wolfgang (Blub) Bumiller
85e98e9f53 Don't ftepp_warn after destroying the lexer... 2012-11-23 19:30:02 +01:00
Wolfgang (Blub) Bumiller
37eaaa76f9 Look for include files in the currently #included file's directory first 2012-11-23 19:29:45 +01:00
Wolfgang (Blub) Bumiller
4a3921fcb9 Let's #define GMQCC by default 2012-11-23 19:13:09 +01:00
Wolfgang (Blub) Bumiller
f6b7ddf72b Don't delete the ftepp prematurely 2012-11-23 15:03:10 +01:00
Dale Weiler
20d65da321 change choice of diagnostics for ftepp to use lex_ctx instance. Cleaned up C++ style comments, and some other things ... 2012-11-23 02:29:01 +00:00
Dale Weiler
b5507b3127 Make it compile with -Wall and -pedantic 2012-11-23 02:23:22 +00:00
Wolfgang (Blub) Bumiller
facd89b188 unsed params in ftepp.c 2012-11-22 21:42:14 +01:00
Dale Weiler
baf69f3725 Fix more warnings 2012-11-22 20:32:08 +00:00
Wolfgang (Blub) Bumiller
e4998e0798 Added #include 2012-11-18 16:22:07 +01:00
Wolfgang (Blub) Bumiller
d3861cea9f Make pragmas pass through the preprocessor so the user can write them manually 2012-11-18 15:30:24 +01:00
Wolfgang (Blub) Bumiller
4c2e5d7ebf update old_string after a recursive preprocess call so we don't reset to a free'd vector; add recursion header/footer pragmas 2012-11-18 14:39:24 +01:00
Wolfgang (Blub) Bumiller
441a224435 Comment about why stringify is so short 2012-11-18 14:29:15 +01:00
Wolfgang (Blub) Bumiller
a014480987 Add quotes to the known control sequences... darn. Add stringification via # 2012-11-18 14:26:40 +01:00
Wolfgang (Blub) Bumiller
0330b082a2 The ftepp now always outputs into a string buffer, with -E the buffer will be dumped to stdout or the via -o specified file, without -E it'll be passed to the parser to be compiled 2012-11-18 13:33:53 +01:00
Wolfgang (Blub) Bumiller
d1373af7fc Make -E print to stdout by default and honor -o, changed handling of source list a bit 2012-11-18 12:51:38 +01:00
Wolfgang (Blub) Bumiller
366557bbab Since like with parsing, the preprocessor state has to be preserved across files for macros, we do that now, and with that introduce a new warning: -Wmultifile-if in case an #if spans over several command-line-provided source files (or progs.src file provided for that matter) 2012-11-18 11:54:11 +01:00
Wolfgang (Blub) Bumiller
515cafe8bd Lexer should keep newlines in merged lines, so will the preprocessor, but therefore the lexer will replace comments with actual spaces so we don't get borken output... also don't error about redifining a macro when inside a non-outputting #if branch 2012-11-16 23:13:53 +01:00
Wolfgang (Blub) Bumiller
990450bfe0 ## concatenation, -Wpreprocessor warning about redefining macros, #undef 2012-11-16 22:54:59 +01:00
Wolfgang (Blub) Bumiller
d237ff1736 don't error on non-EOL EOF at the end of a macro line 2012-11-16 22:41:29 +01:00
Wolfgang (Blub) Bumiller
0ad2b8b2c7 also use recursive-expansion on macros without parameters 2012-11-16 22:38:58 +01:00
Wolfgang (Blub) Bumiller
57ac55ad01 recursively call the preprocessor on expanded macros 2012-11-16 22:31:51 +01:00
Wolfgang (Blub) Bumiller
05a26333fc Expand macros into a string buffer 2012-11-16 22:22:31 +01:00
Wolfgang (Blub) Bumiller
99dd208880 moving ftepp_delete out of ftepp_preprocess so that it can actually be called recursively 2012-11-16 22:07:53 +01:00
Wolfgang (Blub) Bumiller
03f0e39f7f ftepp_out can now output to a string buffer 2012-11-16 22:06:07 +01:00
Wolfgang (Blub) Bumiller
b8a5c87360 Correctly handle nested #ifs 2012-11-16 22:02:38 +01:00
Wolfgang (Blub) Bumiller
5b91c2af5e Relax the preprocessor condition: # in the middle of a line also counts, but take care of builtin numbers since they use # as well 2012-11-16 21:37:34 +01:00
Wolfgang (Blub) Bumiller
7e660951c2 Fix a bug in macro call parameter parsing 2012-11-16 21:27:15 +01:00
Wolfgang (Blub) Bumiller
d688820518 Parsing parameters for a macro call 2012-11-16 21:20:31 +01:00
Wolfgang (Blub) Bumiller
a56c224f9c macro_body parse function shouldn't skip whitespace inside 2012-11-16 20:50:28 +01:00
Wolfgang (Blub) Bumiller
6c0b4a46fe moving ftepp_out further up, using it in ftepp_macro_call, generating output of parameter-less macros 2012-11-16 20:49:37 +01:00
Wolfgang (Blub) Bumiller
5f287fc476 ftepp_macro_call/ftepp_skipallwhite 2012-11-16 20:46:52 +01:00
Wolfgang (Blub) Bumiller
0bd0a430d6 Also allow empty-parameter-list macros 2012-11-16 20:41:20 +01:00
Wolfgang (Blub) Bumiller
c48b9dbf61 Parsing basic macro body, no special tokens yet 2012-11-16 20:38:44 +01:00
Wolfgang (Blub) Bumiller
52d7a5d7be Set the mergelines flag only for preprocessor commands 2012-11-16 20:32:03 +01:00
Wolfgang (Blub) Bumiller
053d8fb0e2 mergelines flag for the lexer to handle a backslash-newline 2012-11-16 20:29:20 +01:00
Wolfgang (Blub) Bumiller
d4fe6ed82d fixing up dtors, parsing parameters of macros 2012-11-16 20:15:04 +01:00
Wolfgang (Blub) Bumiller
34646cfca7 Update #if description comment 2012-11-16 20:04:30 +01:00
Wolfgang (Blub) Bumiller
45a354d664 Unary NOT in #if 2012-11-16 20:02:27 +01:00
Wolfgang (Blub) Bumiller
bdd8b8275e handling the noops flag better now 2012-11-16 19:32:02 +01:00
Wolfgang (Blub) Bumiller
6ab09ef3bf Parsing some basic #ifs with defined() 2012-11-16 19:28:20 +01:00
Wolfgang (Blub) Bumiller
bd5b2a8b58 Fixing indentation 2012-11-16 19:07:23 +01:00
Wolfgang (Blub) Bumiller
0c75182aab Some #if parsing 2012-11-16 19:01:44 +01:00
Wolfgang (Blub) Bumiller
0473fd84d1 using ftepp_out which will honor conditions 2012-11-16 18:29:46 +01:00
Wolfgang (Blub) Bumiller
cc1c197fc6 macro structure, parsing ifdefs and non-macro defines 2012-11-16 18:27:32 +01:00
Wolfgang (Blub) Bumiller
4bee1bdb6e Basic structure of ftepp 2012-11-16 17:46:16 +01:00
Wolfgang (Blub) Bumiller
07ca2e6407 importing initial ftepp.c; -E option now executes the preprocessor 2012-11-16 16:57:59 +01:00