Bill Currie
881b6626e4
[qfcc] Partially implement __VA_OPT__ and __VA_ARGS__
...
__VA_ARGS__ seems to be working but __VA_OPT__ still needs a lot of work
for dealing with its expansions, but basic error checking and simple
expansions seem to work.
2023-11-07 12:36:56 +09:00
Bill Currie
d21260d9f6
[qfcc] Use rua_loc_t for most location information
...
This gets rid of the simple source_file and source_line in pr_info_t, so
all expressions, and many other things have full location information.
2023-11-06 14:25:20 +09:00
Bill Currie
6bfb1f37f0
[qfcc] Rework macro expansion
...
Macros now store their arguments and have a cursor pointing to the next
token to take from their expansion list. While not checked yet, this
will make avoiding recursive macro invocations much easier. More
importantly, it's a step closer to correct argument expansion (though
token pasting is currently broken).
2023-11-03 13:54:08 +09:00
Bill Currie
6408c131dd
[qfcc] Ensure macros expand for #elif
...
It seems I wasn't quite paying attention to when I should be getting
that invalid directive error for #version and when I shouldn't.
2023-11-03 13:48:38 +09:00
Bill Currie
82ce36c981
[qfcc] Add macro support for __FILE__ and __LINE__
...
There are some expansion problems, but this moves their handling to
where it needs to be.
2023-11-01 16:19:39 +09:00
Bill Currie
071e529b0e
[qfcc] Implement parsing side of ... macros
...
Expansion is not yet implemented (need __VA_OPT__ and __VA_ARGS__), but
this gets scheme compiling.
2023-10-30 13:28:01 +09:00
Bill Currie
e402d0fa21
[qfcc] Implement command-line macro definitions
...
This takes care of __QFCC__ not being defined
2023-10-29 18:19:03 +09:00
Bill Currie
0990401a87
[qfcc] Get vkgen compiling
...
Or at least mostly so. The __QFCC__ define isn't visible, and it seems
undef might not be working properly (ruamoko/lib/types.r doesn't
compile). Of course, there's still the issue of whether it's compiling
correctly.
2023-10-28 23:51:12 +09:00
Bill Currie
3bd391d01f
[qfcc] Handle h-string and q-string only in #include
...
And #embed, though that's not implemented yet. Comparisons eating
multiple lines results in some rather interesting errors.
2023-10-27 17:24:54 +09:00
Bill Currie
ffb2514e75
[qfcc] Implement #include and search paths
...
Other than some trouble with line comments and continuation lines, it
seems to work nicely.
2023-10-25 21:07:50 +09:00
Bill Currie
717be4a12d
[qfcc] Update pragma handling for the preprocessor
...
This removes the now redundant flex rules, though does spread
preprocess-only checks around a little more.
2023-10-25 09:25:00 +09:00
Bill Currie
4e922008eb
[qfcc] Collect all arg tokens for stringification
...
Now all the tokens in the arg go into the one string.
2023-10-25 00:25:41 +09:00
Bill Currie
dc598c58b5
[qfcc] Record and expand macro arguments
...
Stringizing doesn't work correctly (stringizes only the first token, not
the whole argument), but things seems to work otherwise.
2023-10-24 23:32:13 +09:00
Bill Currie
3307ef77ec
[qfcc] Implement object-type macro expansion
...
Really, function-type macros expand too, but incorrectly as the
parameters are not parsed and thus not expanded, but this gets the basic
handling implemented, including # and ## processing.
2023-10-24 15:58:37 +09:00
Bill Currie
45e61544bb
[qfcc] Improve handling of spaces in macro definitions
...
Avoids space tokens on either side of ## and after #
2023-10-24 14:17:05 +09:00
Bill Currie
8341f48f9d
[qfcc] Implement #undef
...
That was pleasantly easy :)
2023-10-23 19:00:37 +09:00
Bill Currie
5cab587207
[qfcc] Implement macro recording and defined()
...
So far, very consistent with gcc's cpp from my limited testing, though
some error handling may be a little different.
2023-10-23 19:00:30 +09:00
Bill Currie
5794c68bda
[qfcc] Implement basic conditional compilation
...
Just #if, #else and #endif for now. However, much of the preprocessor
parsing working minus the semantics (expressions do work, though).
2023-10-23 00:10:25 +09:00
Bill Currie
93247163b3
[qfcc] Create a preprocessor token type
...
This will be used for unifying preprocessing and parsing, the idea being
that the tokens will be recorded for later expansion via macros, without
the need to retokenize.
2023-10-20 20:39:13 +09:00