mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-04-19 07:51:08 +00:00
[qfcc] Update pragma handling for the preprocessor
This removes the now redundant flex rules, though does spread preprocess-only checks around a little more.
This commit is contained in:
parent
31ee99ee0a
commit
717be4a12d
4 changed files with 25 additions and 10 deletions
|
@ -80,6 +80,7 @@ rua_macro_t *rua_macro_append (rua_macro_t *macro, rua_tok_t *token,
|
|||
void *scanner);
|
||||
void rua_macro_finish (rua_macro_t *macro, void *scanner);
|
||||
rua_macro_t *rua_macro_arg (rua_macro_t *arg, void *scanner);
|
||||
void rua_start_pragma (void *scanner);
|
||||
void rua_start_text (void *scanner);
|
||||
void rua_start_expr (void *scanner);
|
||||
void rua_expand_on (void *scanner);
|
||||
|
|
|
@ -205,6 +205,9 @@ set_math (pragma_arg_t *args)
|
|||
void
|
||||
pragma_process ()
|
||||
{
|
||||
if (options.preprocess_only) {
|
||||
return;
|
||||
}
|
||||
if (!pragma_args) {
|
||||
warning (0, "empty pragma");
|
||||
return;
|
||||
|
@ -239,6 +242,10 @@ pragma_process ()
|
|||
void
|
||||
pragma_add_arg (const char *id)
|
||||
{
|
||||
if (options.preprocess_only) {
|
||||
printf (" %s", id);
|
||||
return;
|
||||
}
|
||||
pragma_arg_t *arg;
|
||||
ALLOC (16, pragma_arg_t, pragma_args, arg);
|
||||
arg->arg = save_string (id);
|
||||
|
|
|
@ -167,7 +167,8 @@ directive
|
|||
| UNDEF ID extra_warn { rua_undefine ($2, scanner); }
|
||||
| ERROR text { error (0, "%s", $text->str); dstring_delete ($text); }
|
||||
| WARNING text { warning (0, "%s", $text->str); dstring_delete ($text); }
|
||||
| PRAGMA expand pragma_params { pragma_process (); }
|
||||
| PRAGMA expand { rua_start_pragma (scanner); }
|
||||
pragma_params { pragma_process (); }
|
||||
| LINE expand expr QSTRING extra_warn
|
||||
| IF expand expr { rua_if (expr_long ($3), scanner); }
|
||||
| IFDEF ID extra_warn { rua_if (rua_defined ($2, scanner), scanner); }
|
||||
|
@ -212,8 +213,8 @@ expand
|
|||
;
|
||||
|
||||
pragma_params
|
||||
: ID { pragma_add_arg (pre_yytext); }
|
||||
| pragma_params ID { pragma_add_arg (pre_yytext); }
|
||||
: ID { pragma_add_arg ($1); }
|
||||
| pragma_params ID { pragma_add_arg ($2); }
|
||||
;
|
||||
|
||||
string
|
||||
|
|
|
@ -246,8 +246,6 @@ pp_vnumber '({s}*{m}?{pp_number}){2,4}{s}*'{ULFD}?
|
|||
^#{s}+{D}+{s}+\"(\.|[^"\n])*\".*$ { line_info (yytext + 1); }
|
||||
^#line{s}+{D}+{s}+\"(\.|[^"\n])*\".*$ { line_info (yytext + 5); }
|
||||
|
||||
^{s}*#{s}*pragma{s}+ { yy_push_state (PRAGMA, yyscanner); }
|
||||
|
||||
<INITIAL,ARGS>{
|
||||
{ID} |
|
||||
@{ID} { return -rua_id; }
|
||||
|
@ -317,15 +315,13 @@ pp_vnumber '({s}*{m}?{pp_number}){2,4}{s}*'{ULFD}?
|
|||
write_frame_macros (s);
|
||||
BEGIN (GRAB_OTHER); // ignore rest of line
|
||||
}
|
||||
<PRAGMA>{PRAGMAID} { pragma_add_arg (yytext); }
|
||||
<PRAGMA>@{PRAGMAID} { pragma_add_arg (yytext); }
|
||||
<PRAGMA>{PRAGMAID} |
|
||||
<PRAGMA>@{PRAGMAID} { return PRE_ID; }
|
||||
<PRAGMA>\r*\n { next_line (yylloc, yyscanner); return PRE_EOD; }
|
||||
|
||||
<*>\\\r*\n { next_line (yylloc, yyscanner); }/*line continuation*/
|
||||
<ARGS>\r*\n { next_line (yylloc, yyscanner); return -rua_space; }
|
||||
<*>\r*\n {
|
||||
if (YY_START == PRAGMA) {
|
||||
pragma_process ();
|
||||
}
|
||||
next_line (yylloc, yyscanner);
|
||||
if (yyg->yy_start_stack_ptr) {
|
||||
yy_pop_state (yyscanner);
|
||||
|
@ -1586,6 +1582,16 @@ rua_macro_arg (rua_macro_t *arg, void *scanner)
|
|||
return arg;
|
||||
}
|
||||
|
||||
void
|
||||
rua_start_pragma (void *scanner)
|
||||
{
|
||||
if (options.preprocess_only) {
|
||||
printf ("#pragma");
|
||||
}
|
||||
yy_pop_state (scanner);
|
||||
yy_push_state (PRAGMA, scanner);
|
||||
}
|
||||
|
||||
void
|
||||
rua_start_text (void *scanner)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue