From 5eab16cef550bb0b45fefd0e8e956adbfed724ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Thu, 29 Oct 2026 21:31:25 +0100 Subject: [PATCH] cmExprLexer: Treat newline as whitespace explicitly Newlines matched no rule, so they reached flex's default rule. It discards them only because cmStandardLexer.h defines ECHO as empty, and `flex -s` warns "default rule can be matched". Add the newline to the whitespace rule to make the existing behavior of math(EXPR) explicit. --- Source/LexerParser/cmExprLexer.cxx | 3 ++- Source/LexerParser/cmExprLexer.in.l | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/LexerParser/cmExprLexer.cxx b/Source/LexerParser/cmExprLexer.cxx index d05dfd8128..f034128b89 100644 --- a/Source/LexerParser/cmExprLexer.cxx +++ b/Source/LexerParser/cmExprLexer.cxx @@ -559,7 +559,7 @@ struct yy_trans_info }; static const flex_int16_t yy_accept[29] = { 0, - 0, 0, 19, 17, 1, 18, 8, 10, 15, 16, + 0, 0, 19, 17, 1, 1, 8, 10, 15, 16, 6, 4, 5, 7, 2, 2, 17, 17, 11, 9, 12, 2, 0, 13, 14, 3, 3, 0 } ; @@ -987,6 +987,7 @@ do_action: /* This label is used only to access EOF actions. */ goto yy_find_action; case 1: +/* rule 1 can match eol */ YY_RULE_SETUP {} YY_BREAK diff --git a/Source/LexerParser/cmExprLexer.in.l b/Source/LexerParser/cmExprLexer.in.l index 9a5f42fdae..f97e2986f0 100644 --- a/Source/LexerParser/cmExprLexer.in.l +++ b/Source/LexerParser/cmExprLexer.in.l @@ -42,7 +42,7 @@ Modify cmExprLexer.cxx: %pointer %% -[ \t] {} +[ \t\n] {} [0-9][0-9]* { yylvalp->Number = std::stoll(yytext, nullptr, 10); return exp_NUMBER; } 0[xX][0-9a-fA-F][0-9a-fA-F]* { yylvalp->Number = std::stoll(yytext, nullptr, 16); return exp_NUMBER; }