2 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
3 file Copyright.txt or https://cmake.org/licensing for details. */
5 /* IWYU pragma: no_forward_declare yyguts_t */
7 #ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
9 #include <cmGccDepfileLexerHelper.h>
13 %option prefix="cmGccDepfile_yy"
23 // Unescape the dollar sign.
24 yyextra->addToCurrentPath("$");
28 yyextra->addToCurrentPath("#");
31 // Unescape the colon.
32 yyextra->addToCurrentPath(":");
35 // 2N+1 backslashes plus space -> N backslashes plus space.
36 size_t c = (strlen(yytext) - 1) / 2;
37 std::string s(c, '\\');
39 yyextra->addToCurrentPath(s.c_str());
42 // 2N backslashes plus space -> 2N backslashes, end of filename.
43 yytext[strlen(yytext) - 1] = 0;
44 yyextra->addToCurrentPath(yytext);
45 yyextra->newDependency();
47 {WSPACE}*\\{NEWLINE} {
48 // A line continuation ends the current file name.
49 yyextra->newRuleOrDependency();
52 // A newline ends the current file name and the current rule.
56 // A colon ends the rules
57 yyextra->newDependency();
58 // A newline after colon terminates current rule.
61 :({WSPACE}+|\\{NEWLINE}) {
62 // A colon followed by space or line continuation ends the rules
63 // and starts a new dependency.
64 yyextra->newDependency();
67 // Rules and dependencies are separated by blocks of whitespace.
68 yyextra->newRuleOrDependency();
70 [a-zA-Z0-9+,/_.~()}{%=@\x5B\x5D!\x80-\xFF-]+ {
71 // Got a span of plain text.
72 yyextra->addToCurrentPath(yytext);
75 // Got an otherwise unmatched character.
76 yyextra->addToCurrentPath(yytext);
81 /*--------------------------------------------------------------------------*/
83 #endif /* __clang_analyzer__ */