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
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// file : libbuild2/build/script/parser.hxx -*- C++ -*-
// license : MIT; see accompanying LICENSE file
#ifndef LIBBUILD2_BUILD_SCRIPT_PARSER_HXX
#define LIBBUILD2_BUILD_SCRIPT_PARSER_HXX
#include <libbuild2/types.hxx>
#include <libbuild2/forward.hxx>
#include <libbuild2/utility.hxx>
#include <libbuild2/diagnostics.hxx>
#include <libbuild2/script/parser.hxx>
#include <libbuild2/build/script/token.hxx>
#include <libbuild2/build/script/script.hxx>
namespace build2
{
namespace build
{
namespace script
{
class runner;
class parser: public build2::script::parser
{
// Pre-parse. Issue diagnostics and throw failed in case of an error.
//
public:
parser (context& c): build2::script::parser (c) {}
// Note that the returned script object references the passed path
// name.
//
script
pre_parse (istream&, const path_name&, uint64_t line);
// Recursive descent parser.
//
// Usually (but not always) parse functions receive the token/type
// from which it should start consuming and in return the token/type
// should contain the first token that has not been consumed.
//
// Functions that are called parse_*() rather than pre_parse_*() are
// used for both stages.
//
protected:
token
pre_parse_script ();
void
pre_parse_line (token&, token_type&, bool if_line = false);
void
pre_parse_if_else (token&, token_type&);
command_expr
parse_command_line (token&, token_type&);
// Execute. Issue diagnostics and throw failed in case of an error.
//
public:
void
execute (const scope& root, const scope& base,
environment&, const script&, runner&);
protected:
void
exec_script ();
// Helpers.
//
public:
static bool
special_variable (const string&) noexcept;
// Customization hooks.
//
protected:
virtual lookup
lookup_variable (name&&, string&&, const location&) override;
protected:
script* script_;
// Execute state.
//
runner* runner_;
environment* environment_;
};
}
}
}
#endif // LIBBUILD2_BUILD_SCRIPT_PARSER_HXX
|