Ninja
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
ManifestParser Struct Reference

Parses .ninja files. More...

#include <manifest_parser.h>

Inheritance diagram for ManifestParser:
Inheritance graph
[legend]

Public Member Functions

bool Load (const std::string &filename, std::string *err, Lexer *parent=NULL)
 Load and parse a file. More...
 
 ManifestParser (State *state, FileReader *file_reader, ManifestParserOptions options=ManifestParserOptions())
 
bool ParseTest (const std::string &input, std::string *err)
 Parse a text string of input. Used by tests. More...
 

Protected Member Functions

bool ExpectToken (Lexer::Token expected, std::string *err)
 If the next token is not expected, produce an error string saying "expected foo, got bar". More...
 

Protected Attributes

FileReaderfile_reader_
 
Lexer lexer_
 
Statestate_
 

Private Member Functions

bool Parse (const std::string &filename, const std::string &input, std::string *err)
 Parse a file, given its contents as a string. More...
 
bool ParseDefault (std::string *err)
 
bool ParseEdge (std::string *err)
 
bool ParseFileInclude (bool new_scope, std::string *err)
 Parse either a 'subninja' or 'include' line. More...
 
bool ParseLet (std::string *key, EvalString *val, std::string *err)
 
bool ParsePool (std::string *err)
 Parse various statement types. More...
 
bool ParseRule (std::string *err)
 

Private Attributes

BindingEnvenv_
 
std::vector< EvalStringins_
 
ManifestParserOptions options_
 
std::vector< EvalStringouts_
 
bool quiet_
 
std::unique_ptr< ManifestParsersubparser_
 
std::vector< EvalStringvalidations_
 

Detailed Description

Parses .ninja files.

Definition at line 41 of file manifest_parser.h.

Constructor & Destructor Documentation

◆ ManifestParser()

ManifestParser::ManifestParser ( State state,
FileReader file_reader,
ManifestParserOptions  options = ManifestParserOptions() 
)

Definition at line 31 of file manifest_parser.cc.

References State::bindings_, and env_.

Referenced by ParseFileInclude().

Member Function Documentation

◆ ExpectToken()

bool Parser::ExpectToken ( Lexer::Token  expected,
std::string *  err 
)
protectedinherited

If the next token is not expected, produce an error string saying "expected foo, got bar".

Definition at line 40 of file parser.cc.

References Lexer::TokenErrorHint(), and Lexer::TokenName().

Referenced by ParseDefault(), DyndepParser::ParseEdge(), ParseEdge(), ParseFileInclude(), DyndepParser::ParseLet(), ParseLet(), ParsePool(), and ParseRule().

◆ Load()

bool Parser::Load ( const std::string &  filename,
std::string *  err,
Lexer parent = NULL 
)
inherited

Load and parse a file.

Definition at line 22 of file parser.cc.

References Lexer::Error(), METRIC_RECORD_IF, and FileReader::Okay.

Referenced by DyndepLoader::LoadDyndepFile(), LoadManifests(), and TEST_F().

◆ Parse()

bool ManifestParser::Parse ( const std::string &  filename,
const std::string &  input,
std::string *  err 
)
privatevirtual

◆ ParseDefault()

bool ManifestParser::ParseDefault ( std::string *  err)
private

◆ ParseEdge()

bool ManifestParser::ParseEdge ( std::string *  err)
private

◆ ParseFileInclude()

bool ManifestParser::ParseFileInclude ( bool  new_scope,
std::string *  err 
)
private

Parse either a 'subninja' or 'include' line.

Definition at line 419 of file manifest_parser.cc.

References env_, EvalString::Evaluate(), Parser::ExpectToken(), Parser::file_reader_, Parser::lexer_, ManifestParser(), Lexer::NEWLINE, options_, Lexer::ReadPath(), Parser::state_, and subparser_.

Referenced by Parse().

◆ ParseLet()

bool ManifestParser::ParseLet ( std::string *  key,
EvalString val,
std::string *  err 
)
private

◆ ParsePool()

bool ManifestParser::ParsePool ( std::string *  err)
private

◆ ParseRule()

bool ManifestParser::ParseRule ( std::string *  err)
private

◆ ParseTest()

bool ManifestParser::ParseTest ( const std::string &  input,
std::string *  err 
)
inline

Parse a text string of input. Used by tests.

Definition at line 46 of file manifest_parser.h.

References Parse(), and quiet_.

Referenced by ParserTest::AssertParse(), AssertParse(), TEST_F(), and WriteTestData().

Member Data Documentation

◆ env_

BindingEnv* ManifestParser::env_
private

◆ file_reader_

FileReader* Parser::file_reader_
protectedinherited

Definition at line 40 of file parser.h.

Referenced by ParseFileInclude().

◆ ins_

std::vector<EvalString> ManifestParser::ins_
private

Definition at line 74 of file manifest_parser.h.

Referenced by ParseEdge().

◆ lexer_

Lexer Parser::lexer_
protectedinherited

◆ options_

ManifestParserOptions ManifestParser::options_
private

Definition at line 67 of file manifest_parser.h.

Referenced by ParseEdge(), and ParseFileInclude().

◆ outs_

std::vector<EvalString> ManifestParser::outs_
private

Definition at line 74 of file manifest_parser.h.

Referenced by ParseEdge().

◆ quiet_

bool ManifestParser::quiet_
private

Definition at line 68 of file manifest_parser.h.

Referenced by ParseEdge(), and ParseTest().

◆ state_

State* Parser::state_
protectedinherited

◆ subparser_

std::unique_ptr<ManifestParser> ManifestParser::subparser_
private

Definition at line 73 of file manifest_parser.h.

Referenced by ParseFileInclude().

◆ validations_

std::vector<EvalString> ManifestParser::validations_
private

Definition at line 74 of file manifest_parser.h.

Referenced by ParseEdge().


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