Ninja
Public Member Functions | Public Attributes | List of all members
DepfileParser Struct Reference

Parser for the dependency information emitted by gcc's -M flags. More...

#include <depfile_parser.h>

Public Member Functions

 DepfileParser (DepfileParserOptions options=DepfileParserOptions())
 
bool Parse (string *content, string *err)
 Parse an input file. More...
 

Public Attributes

vector< StringPieceins_
 
DepfileParserOptions options_
 
StringPiece out_
 

Detailed Description

Parser for the dependency information emitted by gcc's -M flags.

Definition at line 38 of file depfile_parser.h.

Constructor & Destructor Documentation

◆ DepfileParser()

DepfileParser::DepfileParser ( DepfileParserOptions  options = DepfileParserOptions())
explicit

Definition at line 19 of file depfile_parser.cc.

Member Function Documentation

◆ Parse()

bool DepfileParser::Parse ( string *  content,
string *  err 
)

Parse an input file.

Input must be NUL-terminated. Warning: may mutate the content in-place and parsed StringPieces are pointers within it.

re2c re2c:define:YYCTYPE = "unsigned char"; re2c:define:YYCURSOR = in; re2c:define:YYLIMIT = end; re2c:define:YYMARKER = yymarker;

re2c:yyfill:enable = 0;

re2c:indent:top = 2; re2c:indent:string = " ";

nul = "\000"; escape = [ \#*[|]]; newline = ''?'
';

'\' escape { De-escape backslashed character. out++ = yych; continue; } '$$' { De-escape dollar character. out++ = '$'; continue; } '\' [^\000
] { Let backslash before other characters through verbatim. out++ = '\'; out++ = yych; continue; } [a-zA-Z0-9+,/_:.~()}{%@=!--]+ { Got a span of plain text. int len = (int)(in - start); Need to shift it over if we're overwriting backslashes. if (out < start) memmove(out, start, len); out += len; continue; } nul { break; } '\' newline { A line continuation ends the current file name. break; } newline { A newline ends the current file name and the current rule. have_newline = true; break; } [^] { For any other character (e.g. whitespace), swallow it here, allowing the outer logic to loop around again. break; }

Definition at line 38 of file depfile_parser.cc.

References DepfileParserOptions::depfile_distinct_target_lines_action_, ins_, kDepfileDistinctTargetLinesActionError, options_, out_, StringPiece::str_, and Warning().

Referenced by Builder::ExtractDeps(), ImplicitDepLoader::LoadDepFile(), main(), DepfileParserTest::Parse(), and TEST_F().

Member Data Documentation

◆ ins_

vector<StringPiece> DepfileParser::ins_

Definition at line 48 of file depfile_parser.h.

Referenced by Builder::ExtractDeps(), ImplicitDepLoader::LoadDepFile(), and Parse().

◆ options_

DepfileParserOptions DepfileParser::options_

Definition at line 49 of file depfile_parser.h.

Referenced by Parse().

◆ out_

StringPiece DepfileParser::out_

Definition at line 47 of file depfile_parser.h.

Referenced by ImplicitDepLoader::LoadDepFile(), and Parse().


The documentation for this struct was generated from the following files: