From b3b3c8bcd07e644fdba9167f927ad8dee4a255db Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 26 Aug 2025 20:43:21 +0900 Subject: feat: support nop preprocessing directive --- src/preprocess.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/preprocess.c') diff --git a/src/preprocess.c b/src/preprocess.c index c96c194..2a53059 100644 --- a/src/preprocess.c +++ b/src/preprocess.c @@ -176,6 +176,10 @@ static TokenKind pplexer_tokenize_pp_directive(PpLexer* ppl) { break; infile_next_char(ppl->src); } + // '#' new-line + if (c == '\n') { + return TokenKind_pp_directive_nop; + } SourceLocation pp_directive_name_start_loc = ppl->src->loc; @@ -935,6 +939,11 @@ static void process_pragma_directive(Preprocessor* pp, int directive_token_pos) unimplemented(); } +static void process_nop_directive(Preprocessor* pp, int directive_token_pos) { + next_pp_token(pp); + remove_directive_tokens(pp, directive_token_pos, pp->pos); +} + // ws ::= many0() // macro-arguments ::= '(' opt( many0(',' )) ')' static MacroArgArray* pp_parse_macro_arguments(Preprocessor* pp) { @@ -1047,6 +1056,8 @@ static void process_pp_directive(Preprocessor* pp) { process_error_directive(pp, first_token_pos); } else if (tok->kind == TokenKind_pp_directive_pragma) { process_pragma_directive(pp, first_token_pos); + } else if (tok->kind == TokenKind_pp_directive_nop) { + process_nop_directive(pp, first_token_pos); } else if (tok->kind == TokenKind_ident) { BOOL expanded = expand_macro(pp); if (expanded) { -- cgit v1.2.3-70-g09d2