forked from freeorion/freeorion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVisibilityValueRefParser.cpp
87 lines (67 loc) · 2.9 KB
/
VisibilityValueRefParser.cpp
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
#include "ValueRefParser.h"
#include "EnumParser.h"
#include "EnumValueRefRules.h"
#include "../universe/ValueRefs.h"
#include <boost/phoenix.hpp>
namespace parse { namespace detail {
visibility_complex_parser_grammar::visibility_complex_parser_grammar(
const parse::lexer& tok, Labeller& label
) :
visibility_complex_parser_grammar::base_type(start, "EmpireObjectVisibility"),
simple_int_rules(tok)
{
namespace phoenix = boost::phoenix;
namespace qi = boost::spirit::qi;
using phoenix::construct;
using phoenix::new_;
qi::_1_type _1;
qi::_2_type _2;
qi::_3_type _3;
qi::_val_type _val;
qi::_pass_type _pass;
const boost::phoenix::function<parse::detail::construct_movable> construct_movable_;
const boost::phoenix::function<parse::detail::deconstruct_movable> deconstruct_movable_;
const value_ref_rule<int>& simple_int = simple_int_rules.simple;
empire_object_visibility
= ( tok.EmpireObjectVisibility_
> label(tok.empire_) > simple_int
> label(tok.object_) > simple_int
) [ _val = construct_movable_(new_<ValueRef::ComplexVariable<Visibility>>(_1, deconstruct_movable_(_2, _pass), deconstruct_movable_(_3, _pass), nullptr, nullptr, nullptr)) ]
;
start
= empire_object_visibility
;
empire_object_visibility.name("EmpireObjectVisibility");
#if DEBUG_DOUBLE_COMPLEX_PARSERS
debug(empire_object_visibility);
#endif
}
visibility_parser_rules::visibility_parser_rules(
const parse::lexer& tok,
Labeller& label,
const condition_parser_grammar& condition_parser
) :
enum_value_ref_rules("Visibility", tok, label, condition_parser),
visibility_var_complex_grammar(tok, label)
{
namespace phoenix = boost::phoenix;
namespace qi = boost::spirit::qi;
using phoenix::new_;
qi::_val_type _val;
const boost::phoenix::function<parse::detail::construct_movable> construct_movable_;
//const boost::phoenix::function<parse::detail::deconstruct_movable> deconstruct_movable_;
// variable_name left empty, as no direct object properties are
// available that return a visibility
enum_expr
= tok.Invisible_ [ _val = Visibility::VIS_NO_VISIBILITY ]
| tok.Basic_ [ _val = Visibility::VIS_BASIC_VISIBILITY ]
| tok.Partial_ [ _val = Visibility::VIS_PARTIAL_VISIBILITY ]
| tok.Full_ [ _val = Visibility::VIS_FULL_VISIBILITY ]
;
free_variable_expr
= tok.Value_ [ _val = construct_movable_(new_<ValueRef::Variable<Visibility>>(ValueRef::ReferenceType::EFFECT_TARGET_VALUE_REFERENCE)) ]
;
complex_expr = visibility_var_complex_grammar;
}
}
}