blob: 0698f7b3bb9cf201dc8fc71ac89d8cafb06e9bd5 (
plain)
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
99
100
101
102
103
104
105
106
107
|
// file : CCF/IDL3/SemanticAction/Impl/Publishes.hpp
// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
// cvs-id : $Id$
#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_PUBLISHES_HPP
#define CCF_IDL3_SEMANTIC_ACTION_IMPL_PUBLISHES_HPP
#include "CCF/IDL3/SemanticAction/Publishes.hpp"
namespace CCF
{
namespace IDL3
{
namespace SemanticAction
{
namespace Impl
{
//
//
//
class Publishes : public virtual SemanticAction::Publishes
{
public:
virtual
~Publishes () throw () {}
Publishes (bool trace, SyntaxTree::ScopePtr& current)
: trace_ (trace),
scope_ (current),
type_ ("")
{
}
virtual void
type (IdentifierPtr const& id)
{
if (trace_) cerr << "publishes " << id;
using namespace SyntaxTree;
Name name (id->lexeme ());
struct Predicate : public DeclarationTable::ResolvePredicate
{
virtual bool
test (DeclarationPtr const& d) throw ()
{
return d->is_a<EventTypeDef> ();
}
} p;
try
{
ScopedName sn = scope_->table ().resolve (
name,
scope_->name (),
scope_->peek_order (),
p);
type_ = sn;
}
catch (DeclarationTable::NameNotFound const&)
{
cerr << "error: invalid publishes declaration" << endl;
cerr << "no event type with name \'"
<< name << "\' visible from scope \'"
<< scope_->name () << "\'" << endl;
}
catch (DeclarationTable::PredicateNotMet const&)
{
cerr << "error: invalid publishes declaration" << endl;
cerr << "declaration with name \'" << name
<< "\' visible from scope \'" << scope_->name ()
<< "\' is not a defined event type" << endl;
cerr << "using non-<defined event type> in publishes "
<< "declaration is illegal" << endl;
}
}
virtual void
name (SimpleIdentifierPtr const& id)
{
if (trace_) cerr << " " << id << endl;
using namespace SyntaxTree;
SimpleName name (id->lexeme ());
DeclarationPtr d (
new SyntaxTree::PublishesDecl (name, type_, scope_));
scope_->insert (d);
type_ = ScopedName ("");
}
private:
bool trace_;
SyntaxTree::ScopePtr& scope_;
SyntaxTree::ScopedName type_;
};
}
}
}
}
#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_PUBLISHES_HPP
|