|
Ninja
|
Parses .ninja files. More...
#include <manifest_parser.h>
Public Member Functions | |
| bool | Load (const string &filename, string *err, Lexer *parent=NULL) |
| Load and parse a file. More... | |
| ManifestParser (State *state, FileReader *file_reader, ManifestParserOptions options=ManifestParserOptions()) | |
| bool | ParseTest (const string &input, string *err) |
| Parse a text string of input. Used by tests. More... | |
Private Member Functions | |
| bool | ExpectToken (Lexer::Token expected, string *err) |
| If the next token is not expected, produce an error string saying "expectd foo, got bar". More... | |
| bool | Parse (const string &filename, const string &input, string *err) |
| Parse a file, given its contents as a string. More... | |
| bool | ParseDefault (string *err) |
| bool | ParseEdge (string *err) |
| bool | ParseFileInclude (bool new_scope, string *err) |
| Parse either a 'subninja' or 'include' line. More... | |
| bool | ParseLet (string *key, EvalString *val, string *err) |
| bool | ParsePool (string *err) |
| Parse various statement types. More... | |
| bool | ParseRule (string *err) |
Private Attributes | |
| BindingEnv * | env_ |
| FileReader * | file_reader_ |
| Lexer | lexer_ |
| ManifestParserOptions | options_ |
| bool | quiet_ |
| State * | state_ |
Parses .ninja files.
Definition at line 48 of file manifest_parser.h.
| ManifestParser::ManifestParser | ( | State * | state, |
| FileReader * | file_reader, | ||
| ManifestParserOptions | options = ManifestParserOptions() |
||
| ) |
Definition at line 28 of file manifest_parser.cc.
References State::bindings_, and env_.
|
private |
If the next token is not expected, produce an error string saying "expectd foo, got bar".
Definition at line 438 of file manifest_parser.cc.
References Lexer::Error(), lexer_, Lexer::ReadToken(), Lexer::TokenErrorHint(), and Lexer::TokenName().
Referenced by ParseDefault(), ParseEdge(), ParseFileInclude(), ParseLet(), ParsePool(), and ParseRule().
| bool ManifestParser::Load | ( | const string & | filename, |
| string * | err, | ||
| Lexer * | parent = NULL |
||
| ) |
Load and parse a file.
Definition at line 35 of file manifest_parser.cc.
References Lexer::Error(), file_reader_, METRIC_RECORD, FileReader::Okay, Parse(), and FileReader::ReadFile().
Referenced by LoadManifests(), ParseFileInclude(), and TEST_F().
|
private |
Parse a file, given its contents as a string.
Definition at line 56 of file manifest_parser.cc.
References BindingEnv::AddBinding(), Lexer::BUILD, CheckNinjaVersion(), Lexer::DEFAULT, Lexer::DescribeLastError(), env_, Lexer::ERROR, Lexer::Error(), EvalString::Evaluate(), Lexer::IDENT, Lexer::INCLUDE, lexer_, Lexer::NEWLINE, ParseDefault(), ParseEdge(), ParseFileInclude(), ParseLet(), ParsePool(), ParseRule(), Lexer::POOL, Lexer::ReadToken(), Lexer::RULE, Lexer::Start(), Lexer::SUBNINJA, Lexer::TEOF, Lexer::TokenName(), and Lexer::UnreadToken().
Referenced by Load().
|
private |
Definition at line 205 of file manifest_parser.cc.
References State::AddDefault(), CanonicalizePath(), EvalString::Clear(), EvalString::empty(), env_, Lexer::Error(), EvalString::Evaluate(), ExpectToken(), lexer_, Lexer::NEWLINE, Lexer::ReadPath(), and state_.
Referenced by Parse().
|
private |
Definition at line 232 of file manifest_parser.cc.
References BindingEnv::AddBinding(), State::AddEdge(), State::AddIn(), State::AddOut(), CanonicalizePath(), EvalString::Clear(), Lexer::COLON, ManifestParserOptions::dupe_edge_action_, State::edges_, EvalString::empty(), env_, Edge::env_, Lexer::Error(), EvalString::Evaluate(), ExpectToken(), Edge::GetBinding(), Edge::implicit_deps_, Edge::implicit_outs_, Lexer::INDENT, Edge::inputs_, kDupeEdgeActionError, kPhonyCycleActionWarn, lexer_, State::LookupPool(), BindingEnv::LookupRule(), Edge::maybe_phonycycle_diagnostic(), Lexer::NEWLINE, options_, Edge::order_only_deps_, Edge::outputs_, ParseLet(), Node::path(), Lexer::PeekToken(), ManifestParserOptions::phony_cycle_action_, Lexer::PIPE, Lexer::PIPE2, Edge::pool_, quiet_, Lexer::ReadIdent(), Lexer::ReadPath(), state_, and Warning().
Referenced by Parse().
|
private |
Parse either a 'subninja' or 'include' line.
Definition at line 416 of file manifest_parser.cc.
References env_, EvalString::Evaluate(), ExpectToken(), file_reader_, lexer_, Load(), Lexer::NEWLINE, options_, Lexer::ReadPath(), and state_.
Referenced by Parse().
|
private |
Definition at line 195 of file manifest_parser.cc.
References Lexer::EQUALS, Lexer::Error(), ExpectToken(), lexer_, Lexer::ReadIdent(), and Lexer::ReadVarValue().
Referenced by Parse(), ParseEdge(), ParsePool(), and ParseRule().
|
private |
Parse various statement types.
Definition at line 117 of file manifest_parser.cc.
References State::AddPool(), env_, Lexer::Error(), EvalString::Evaluate(), ExpectToken(), Lexer::INDENT, lexer_, State::LookupPool(), Lexer::NEWLINE, ParseLet(), Lexer::PeekToken(), Lexer::ReadIdent(), and state_.
Referenced by Parse().
|
private |
Definition at line 154 of file manifest_parser.cc.
References Rule::AddBinding(), BindingEnv::AddRule(), Rule::bindings_, env_, Lexer::Error(), ExpectToken(), Lexer::INDENT, Rule::IsReservedBinding(), lexer_, BindingEnv::LookupRuleCurrentScope(), Lexer::NEWLINE, ParseLet(), Lexer::PeekToken(), and Lexer::ReadIdent().
Referenced by Parse().
|
inline |
Parse a text string of input. Used by tests.
Definition at line 56 of file manifest_parser.h.
Referenced by ParserTest::AssertParse(), AssertParse(), TEST_F(), and WriteTestData().
|
private |
Definition at line 80 of file manifest_parser.h.
Referenced by ManifestParser(), Parse(), ParseDefault(), ParseEdge(), ParseFileInclude(), ParsePool(), and ParseRule().
|
private |
Definition at line 81 of file manifest_parser.h.
Referenced by Load(), and ParseFileInclude().
|
private |
Definition at line 82 of file manifest_parser.h.
Referenced by ExpectToken(), Parse(), ParseDefault(), ParseEdge(), ParseFileInclude(), ParseLet(), ParsePool(), and ParseRule().
|
private |
Definition at line 83 of file manifest_parser.h.
Referenced by ParseEdge(), and ParseFileInclude().
|
private |
Definition at line 84 of file manifest_parser.h.
Referenced by ParseEdge().
|
private |
Definition at line 79 of file manifest_parser.h.
Referenced by ParseDefault(), ParseEdge(), ParseFileInclude(), and ParsePool().
1.8.14