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
97
98
|
// file : odb/lookup.hxx
// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC
// license : GNU GPL v3; see accompanying LICENSE file
#ifndef ODB_LOOKUP_HXX
#define ODB_LOOKUP_HXX
#include <odb/gcc.hxx>
#include <string>
#include <odb/cxx-lexer.hxx>
#include <odb/semantics/elements.hxx>
namespace lookup
{
struct invalid_name
{
};
struct unable_to_resolve
{
unable_to_resolve (std::string const& n, bool l): name_ (n), last_ (l) {}
std::string const&
name () const {return name_;}
// Last component in the name.
//
bool
last () const {return last_;}
private:
std::string name_;
bool last_;
};
std::string
parse_scoped_name (cxx_lexer&,
cpp_ttype&,
std::string& tl, // Token literal.
tree& tn); // Token node.
// If trailing_scope is true, then this function also handles
// names in the 'foo::bar::<something-other-than-name>' form.
// In this case token will be <something-other-than-name> and
// ptt will be CPP_SCOPE.
//
// The names are appended to the 'name' variable as they are
// being resolved.
//
tree
resolve_scoped_name (cxx_lexer&,
cpp_ttype&,
std::string& tl, // Token literal.
tree& tn, // Token node.
cpp_ttype& ptt, // Previous token type.
tree start_scope,
std::string& name,
bool is_type,
bool trailing_scope = false,
tree* end_scope = 0);
// The same but using semantic graph instead of GCC tree. Also
// throws semantics::unresolved instead of unable_to_resolve.
//
semantics::node&
resolve_scoped_name (cxx_lexer&,
cpp_ttype&,
std::string& tl, // Token literal.
tree& tn, // Token node.
cpp_ttype& ptt, // Previous token type.
semantics::scope& start_scope,
std::string& name,
semantics::type_id const&,
bool trailing_scope = false,
semantics::scope** end_scope = 0);
template <typename T>
T&
resolve_scoped_name (cxx_lexer& l,
cpp_ttype& tt,
std::string& tl, // Token literal.
tree& tn, // Token node.
cpp_ttype& ptt, // Previous token type.
semantics::scope& start_scope,
std::string& name,
bool trailing_scope = false,
semantics::scope** end_scope = 0)
{
return dynamic_cast<T&> (
resolve_scoped_name (
l, tt, tl, tn, ptt,
start_scope, name, typeid (T), trailing_scope, end_scope));
}
}
#endif // ODB_LOOKUP_HXX
|