[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.
This commit is contained in:
Bill Currie 2023-10-27 17:22:47 +09:00
parent 823a9bd8d9
commit 3bd391d01f
3 changed files with 19 additions and 4 deletions

View file

@ -83,6 +83,7 @@ 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_start_include (void *scanner);
void rua_expand_on (void *scanner);
void rua_expand_off (void *scanner);
void rua_end_directive (void *scanner);

View file

@ -179,8 +179,8 @@ directive_list
eod : EOD { rua_end_directive (scanner); } ;
directive
: INCLUDE expand string extra_warn eod { rua_include_file ($3, scanner); }
| EMBED expand string extra_ignore eod { rua_embed_file ($3, scanner); }
: INCLUDE incexp string extra_warn eod { rua_include_file ($3, scanner); }
| EMBED incexp string extra_ignore eod { rua_embed_file ($3, scanner); }
| DEFINE ID <macro> { $$ = rua_start_macro ($2, false, scanner); }
body { rua_macro_finish ($body, scanner); }
eod
@ -244,6 +244,10 @@ body: /* empty */ { $$ = $<macro>0; }
body_token : TOKEN | ',' | '(' | ')' ;
incexp
: { rua_start_include (scanner); }
;
expand
: { rua_start_expr (scanner); }
;

View file

@ -276,8 +276,8 @@ pp_vnumber '({s}*{m}?{pp_number}){2,4}{s}*'{ULFD}?
<TEXT>[\\]* { return PRE_TEXT; }
<MACRO>## { return PRE_CONCAT; }
<MACRO># { return '#'; }
<PREEXPR>{h_string} { return PRE_HSTRING; }
<PREEXPR>{q_string} { return PRE_QSTRING; }
<PREPROC>{h_string} { return PRE_HSTRING; }
<PREPROC>{q_string} { return PRE_QSTRING; }
<PREEXPR>defined { return PRE_DEFINED; }
<PREEXPR>{ID} { return PRE_ID; }
@ -1654,6 +1654,16 @@ rua_start_text (void *scanner)
yy_push_state (TEXT, scanner);
}
void
rua_start_include (void *scanner)
{
auto extra = qc_yyget_extra (scanner);
extra->expand = true;
yy_pop_state (scanner);
yy_push_state (PREPROC, scanner);
}
void
rua_start_expr (void *scanner)
{