Ninja
Main Page
Namespaces
Classes
Files
File List
File Members
manifest_parser.h
Go to the documentation of this file.
1
// Copyright 2011 Google Inc. All Rights Reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef NINJA_MANIFEST_PARSER_H_
16
#define NINJA_MANIFEST_PARSER_H_
17
18
#include <string>
19
20
using namespace
std;
21
22
#include "
lexer.h
"
23
24
struct
BindingEnv
;
25
struct
EvalString
;
26
struct
State
;
27
28
/// Parses .ninja files.
29
struct
ManifestParser
{
30
struct
FileReader
{
31
virtual
~FileReader
() {}
32
virtual
bool
ReadFile
(
const
string
& path,
string
* content,
string
* err) = 0;
33
};
34
35
ManifestParser
(
State
* state, FileReader* file_reader);
36
37
/// Load and parse a file.
38
bool
Load(
const
string
& filename,
string
* err);
39
40
/// Parse a text string of input. Used by tests.
41
bool
ParseTest
(
const
string
& input,
string
* err) {
42
return
Parse(
"input"
, input, err);
43
}
44
45
private
:
46
/// Parse a file, given its contents as a string.
47
bool
Parse(
const
string
& filename,
const
string
& input,
string
* err);
48
49
/// Parse various statement types.
50
bool
ParsePool(
string
* err);
51
bool
ParseRule(
string
* err);
52
bool
ParseLet(
string
* key,
EvalString
* val,
string
* err);
53
bool
ParseEdge(
string
* err);
54
bool
ParseDefault(
string
* err);
55
56
/// Parse either a 'subninja' or 'include' line.
57
bool
ParseFileInclude(
bool
new_scope,
string
* err);
58
59
/// If the next token is not \a expected, produce an error string
60
/// saying "expectd foo, got bar".
61
bool
ExpectToken(
Lexer::Token
expected,
string
* err);
62
63
State
*
state_
;
64
BindingEnv
*
env_
;
65
FileReader
*
file_reader_
;
66
Lexer
lexer_
;
67
};
68
69
#endif // NINJA_MANIFEST_PARSER_H_
Generated on Thu Jul 18 2013 20:51:42 for Ninja by
1.8.4