File: cmGccDepfileLexer.in.l

package info (click to toggle)
cmake 4.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 152,348 kB
  • sloc: ansic: 403,894; cpp: 303,807; sh: 4,097; python: 3,582; yacc: 3,106; lex: 1,279; f90: 538; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 239; objc: 215; perl: 213; xml: 198; makefile: 108; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (83 lines) | stat: -rw-r--r-- 3,128 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
%{
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file LICENSE.rst or https://cmake.org/licensing for details.  */

/* IWYU pragma: no_forward_declare yyguts_t */

#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */

#include <cmGccDepfileLexerHelper.h>
#include <string>
%}

%option prefix="cmGccDepfile_yy"
%option noyywrap
%option reentrant
%pointer

WSPACE [ \t]
NEWLINE \r?\n

%%
\${2}                  {
                         // Unescape the dollar sign.
                         yyextra->addToCurrentPath("$");
                       }
\\#                    {
                         // Unescape the hash.
                         yyextra->addToCurrentPath("#");
                       }
\\:                    {
                         // Unescape the colon.
                         yyextra->addToCurrentPath(":");
                       }
(\\\\)*\\[ ]           {
                         // 2N+1 backslashes plus space -> N backslashes plus space.
                         size_t c = (strlen(yytext) - 1) / 2;
                         std::string s(c, '\\');
                         s.push_back(' ');
                         yyextra->addToCurrentPath(s.c_str());
                       }
(\\\\)+[ ]             {
                         // 2N backslashes plus space -> 2N backslashes, end of filename.
                         yytext[strlen(yytext) - 1] = 0;
                         yyextra->addToCurrentPath(yytext);
                         yyextra->newDependency();
                       }
{WSPACE}*\\{NEWLINE}   {
                         // A line continuation ends the current file name.
                         yyextra->newRuleOrDependency();
                       }
{NEWLINE}              {
                         // A newline ends the current file name and the current rule.
                         yyextra->newEntry();
                       }
:{NEWLINE}             {
                         // A colon ends the rules
                         yyextra->newDependency();
                         // A newline after colon terminates current rule.
                         yyextra->newEntry();
                       }
:({WSPACE}+|\\{NEWLINE}) {
                         // A colon followed by space or line continuation ends the rules
                         // and starts a new dependency.
                         yyextra->newDependency();
                       }
{WSPACE}+              {
                         // Rules and dependencies are separated by blocks of whitespace.
                         yyextra->newRuleOrDependency();
                       }
[a-zA-Z0-9+,/_.~()}{%=@\x5B\x5D!\x80-\xFF-]+ {
                         // Got a span of plain text.
                         yyextra->addToCurrentPath(yytext);
                       }
.                      {
                         // Got an otherwise unmatched character.
                         yyextra->addToCurrentPath(yytext);
                       }

%%

/*--------------------------------------------------------------------------*/

#endif /* __clang_analyzer__ */