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
5f21422df3
[qfcc] Parse parameterless function-type macros
...
This allows `#define foo()` to work as expected.
2023-10-30 17:20:32 +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
243a3de629
[qfcc] Grab undef id early
...
I'm unsure of the small string handling is a premature optimization, but
when most tokens are small...
2023-10-29 18:23:39 +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
b52b803c2a
[qfcc] Add a #notice directive
...
Haven't got things working properly and I'm already extending the
preprocessor :P. It proved handy for debugging :)
2023-10-28 08:43:17 +09:00
Bill Currie
80c9132199
[qfcc] Treat all identifiers as undefined
...
If ID gets to the preprocessor parser in expressions, the ID is not
defined because if it was defined, it would have been expanded. Thus,
all IDs are 0.
2023-10-27 17:27:52 +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
f1f0a4a260
[qfcc] Update line directive handling
...
In addition to cleaning up the old flex line rules, this improves
handling of the '# num "file" flags' from cpp to at least parse the
additional flags (support for the system header flag might come later,
but I doubt the extern-c flag will have much meaning).
QuakePascal has lost its line directive handling (no errors, but dead
rules) for now. Eventually the lexers will be merged.
2023-10-25 12:22:33 +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
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
e60f538664
[qfcc] Implement function-type macro argument parsing
...
The arguments are not recorded yet, but argument parsing can consume the
whole file if the closing ) is missing (same as gcc).
2023-10-24 22:06:01 +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