CMake Nightly Date Stamp
[kiteware-cmake.git] / Source / LexerParser / cmGccDepfileLexer.in.l
bloba0a0f22bad1d2351990b70d5219acf89a007ca69
1 %{
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>
10 #include <string>
13 %option prefix="cmGccDepfile_yy"
14 %option noyywrap
15 %option reentrant
16 %pointer
18 WSPACE [ \t]
19 NEWLINE \r?\n
22 \${2}                  {
23                          // Unescape the dollar sign.
24                          yyextra->addToCurrentPath("$");
25                        }
26 \\#                    {
27                          // Unescape the hash.
28                          yyextra->addToCurrentPath("#");
29                        }
30 \\:                    {
31                          // Unescape the colon.
32                          yyextra->addToCurrentPath(":");
33                        }
34 (\\\\)*\\[ ]           {
35                          // 2N+1 backslashes plus space -> N backslashes plus space.
36                          size_t c = (strlen(yytext) - 1) / 2;
37                          std::string s(c, '\\');
38                          s.push_back(' ');
39                          yyextra->addToCurrentPath(s.c_str());
40                        }
41 (\\\\)+[ ]             {
42                          // 2N backslashes plus space -> 2N backslashes, end of filename.
43                          yytext[strlen(yytext) - 1] = 0;
44                          yyextra->addToCurrentPath(yytext);
45                          yyextra->newDependency();
46                        }
47 {WSPACE}*\\{NEWLINE}   {
48                          // A line continuation ends the current file name.
49                          yyextra->newRuleOrDependency();
50                        }
51 {NEWLINE}              {
52                          // A newline ends the current file name and the current rule.
53                          yyextra->newEntry();
54                        }
55 :{NEWLINE}             {
56                          // A colon ends the rules
57                          yyextra->newDependency();
58                          // A newline after colon terminates current rule.
59                          yyextra->newEntry();
60                        }
61 :({WSPACE}+|\\{NEWLINE}) {
62                          // A colon followed by space or line continuation ends the rules
63                          // and starts a new dependency.
64                          yyextra->newDependency();
65                        }
66 {WSPACE}+              {
67                          // Rules and dependencies are separated by blocks of whitespace.
68                          yyextra->newRuleOrDependency();
69                        }
70 [a-zA-Z0-9+,/_.~()}{%=@\x5B\x5D!\x80-\xFF-]+ {
71                          // Got a span of plain text.
72                          yyextra->addToCurrentPath(yytext);
73                        }
74 .                      {
75                          // Got an otherwise unmatched character.
76                          yyextra->addToCurrentPath(yytext);
77                        }
81 /*--------------------------------------------------------------------------*/
83 #endif /* __clang_analyzer__ */