diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-12-15 22:23:46 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2021-02-25 13:39:56 +0300 |
commit | 949a9f572341b6cd07690f0b78b1b1941d320055 (patch) | |
tree | a4b9a32fb5a4cd6a46a17718cc854697df49c920 /libxsd-frontend/traversal | |
parent | 061b59ec50c40e8757c5e9237f45a2c7ade36d62 (diff) |
Switch to build2
Diffstat (limited to 'libxsd-frontend/traversal')
31 files changed, 2061 insertions, 0 deletions
diff --git a/libxsd-frontend/traversal/any-attribute.hxx b/libxsd-frontend/traversal/any-attribute.hxx new file mode 100644 index 0000000..ede2ea0 --- /dev/null +++ b/libxsd-frontend/traversal/any-attribute.hxx @@ -0,0 +1,20 @@ +// file : libxsd-frontend/traversal/any-attribute.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_FRONTEND_TRAVERSAL_ANY_ATTRIBUTE_HXX +#define LIBXSD_FRONTEND_TRAVERSAL_ANY_ATTRIBUTE_HXX + +#include <libxsd-frontend/traversal/elements.hxx> +#include <libxsd-frontend/semantic-graph/any-attribute.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + typedef + Node<SemanticGraph::AnyAttribute> + AnyAttribute; + } +} + +#endif // LIBXSD_FRONTEND_TRAVERSAL_ANY_ATTRIBUTE_HXX diff --git a/libxsd-frontend/traversal/any.hxx b/libxsd-frontend/traversal/any.hxx new file mode 100644 index 0000000..ed085bf --- /dev/null +++ b/libxsd-frontend/traversal/any.hxx @@ -0,0 +1,20 @@ +// file : libxsd-frontend/traversal/any.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_FRONTEND_TRAVERSAL_ANY_HXX +#define LIBXSD_FRONTEND_TRAVERSAL_ANY_HXX + +#include <libxsd-frontend/traversal/elements.hxx> +#include <libxsd-frontend/semantic-graph/any.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + typedef + Node<SemanticGraph::Any> + Any; + } +} + +#endif // LIBXSD_FRONTEND_TRAVERSAL_ANY_HXX diff --git a/libxsd-frontend/traversal/attribute-group.cxx b/libxsd-frontend/traversal/attribute-group.cxx new file mode 100644 index 0000000..af0b3f3 --- /dev/null +++ b/libxsd-frontend/traversal/attribute-group.cxx @@ -0,0 +1,28 @@ +// file : libxsd-frontend/traversal/attribute-group.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <libxsd-frontend/traversal/attribute-group.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + void AttributeGroup:: + traverse (Type& g) + { + pre (g); + names (g); + post (g); + } + + void AttributeGroup:: + pre (Type&) + { + } + + void AttributeGroup:: + post (Type&) + { + } + } +} diff --git a/libxsd-frontend/traversal/attribute-group.hxx b/libxsd-frontend/traversal/attribute-group.hxx new file mode 100644 index 0000000..51c6a00 --- /dev/null +++ b/libxsd-frontend/traversal/attribute-group.hxx @@ -0,0 +1,28 @@ +// file : libxsd-frontend/traversal/attribute-group.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_FRONTEND_TRAVERSAL_ATTRIBUTE_GROUP_HXX +#define LIBXSD_FRONTEND_TRAVERSAL_ATTRIBUTE_GROUP_HXX + +#include <libxsd-frontend/traversal/elements.hxx> +#include <libxsd-frontend/semantic-graph/attribute-group.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + struct AttributeGroup: ScopeTemplate<SemanticGraph::AttributeGroup> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + post (Type&); + }; + } +} + +#endif // LIBXSD_FRONTEND_TRAVERSAL_ATTRIBUTE_GROUP_HXX diff --git a/libxsd-frontend/traversal/attribute.cxx b/libxsd-frontend/traversal/attribute.cxx new file mode 100644 index 0000000..1af6964 --- /dev/null +++ b/libxsd-frontend/traversal/attribute.cxx @@ -0,0 +1,46 @@ +// file : libxsd-frontend/traversal/attribute.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <libxsd-frontend/traversal/attribute.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + void Attribute:: + traverse (Type& a) + { + pre (a); + belongs (a); + name (a); + post (a); + } + + void Attribute:: + pre (Type&) + { + } + + void Attribute:: + belongs (Type& a, EdgeDispatcher& d) + { + d.dispatch (a.belongs ()); + } + + void Attribute:: + belongs (Type& a) + { + belongs (a, *this); + } + + void Attribute:: + name (Type&) + { + } + + void Attribute:: + post (Type&) + { + } + } +} diff --git a/libxsd-frontend/traversal/attribute.hxx b/libxsd-frontend/traversal/attribute.hxx new file mode 100644 index 0000000..c8fb8e6 --- /dev/null +++ b/libxsd-frontend/traversal/attribute.hxx @@ -0,0 +1,39 @@ +// file : libxsd-frontend/traversal/attribute.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_FRONTEND_TRAVERSAL_ATTRIBUTE_HXX +#define LIBXSD_FRONTEND_TRAVERSAL_ATTRIBUTE_HXX + +#include <libxsd-frontend/traversal/elements.hxx> + +#include <libxsd-frontend/semantic-graph/attribute.hxx> + + +namespace XSDFrontend +{ + namespace Traversal + { + struct Attribute : Node<SemanticGraph::Attribute> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + belongs (Type&, EdgeDispatcher&); + + virtual void + belongs (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + } +} + +#endif // LIBXSD_FRONTEND_TRAVERSAL_ATTRIBUTE_HXX diff --git a/libxsd-frontend/traversal/complex.cxx b/libxsd-frontend/traversal/complex.cxx new file mode 100644 index 0000000..4a80b4c --- /dev/null +++ b/libxsd-frontend/traversal/complex.cxx @@ -0,0 +1,62 @@ +// file : libxsd-frontend/traversal/complex.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <libxsd-frontend/traversal/complex.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + void Complex:: + traverse (Type& c) + { + pre (c); + name (c); + inherits (c); + names (c); + contains_compositor (c); + post (c); + } + + void Complex:: + pre (Type&) + { + } + + void Complex:: + name (Type&) + { + } + + void Complex:: + inherits (Type& c) + { + inherits (c, *this); + } + + void Complex:: + inherits (Type& c, EdgeDispatcher& d) + { + if (c.inherits_p ()) + d.dispatch (c.inherits ()); + } + + void Complex:: + contains_compositor (Type& c) + { + contains_compositor (c, *this); + } + + void Complex:: + contains_compositor (Type& c, EdgeDispatcher& d) + { + if (c.contains_compositor_p ()) + d.dispatch (c.contains_compositor ()); + } + + void Complex:: + post (Type&) + { + } + } +} diff --git a/libxsd-frontend/traversal/complex.hxx b/libxsd-frontend/traversal/complex.hxx new file mode 100644 index 0000000..2109172 --- /dev/null +++ b/libxsd-frontend/traversal/complex.hxx @@ -0,0 +1,43 @@ +// file : libxsd-frontend/traversal/complex.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_FRONTEND_TRAVERSAL_COMPLEX_HXX +#define LIBXSD_FRONTEND_TRAVERSAL_COMPLEX_HXX + +#include <libxsd-frontend/traversal/elements.hxx> +#include <libxsd-frontend/semantic-graph/complex.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + struct Complex : ScopeTemplate<SemanticGraph::Complex> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + inherits (Type&); + + void + inherits (Type&, EdgeDispatcher&); + + virtual void + contains_compositor (Type&); + + void + contains_compositor (Type&, EdgeDispatcher&); + + virtual void + post (Type&); + }; + } +} + +#endif // LIBXSD_FRONTEND_TRAVERSAL_COMPLEX_HXX diff --git a/libxsd-frontend/traversal/compositors.cxx b/libxsd-frontend/traversal/compositors.cxx new file mode 100644 index 0000000..b5d3d56 --- /dev/null +++ b/libxsd-frontend/traversal/compositors.cxx @@ -0,0 +1,163 @@ +// file : libxsd-frontend/traversal/compositors.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <libxsd-frontend/traversal/compositors.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + // ContainsParticle + // + void ContainsParticle:: + traverse (Type& c) + { + dispatch (c.particle ()); + } + + + // ContainsCompositor + // + void ContainsCompositor:: + traverse (Type& c) + { + dispatch (c.compositor ()); + } + + + // Compositor + // + void Compositor:: + traverse (Type& c) + { + pre (c); + contains (c); + post (c); + } + + void Compositor:: + pre (Type&) + { + } + + void Compositor:: + contains (Type& c) + { + iterate_and_dispatch ( + c.contains_begin (), c.contains_end (), edge_traverser ()); + } + + void Compositor:: + contains (Type& c, EdgeDispatcher& d) + { + iterate_and_dispatch (c.contains_begin (), c.contains_end (), d); + } + + void Compositor:: + post (Type&) + { + } + + + // All + // + void All:: + traverse (Type& c) + { + pre (c); + contains (c); + post (c); + } + + void All:: + pre (Type&) + { + } + + void All:: + contains (Type& c) + { + iterate_and_dispatch ( + c.contains_begin (), c.contains_end (), edge_traverser ()); + } + + void All:: + contains (Type& c, EdgeDispatcher& d) + { + iterate_and_dispatch (c.contains_begin (), c.contains_end (), d); + } + + void All:: + post (Type&) + { + } + + + // Choice + // + void Choice:: + traverse (Type& c) + { + pre (c); + contains (c); + post (c); + } + + void Choice:: + pre (Type&) + { + } + + void Choice:: + contains (Type& c) + { + iterate_and_dispatch ( + c.contains_begin (), c.contains_end (), edge_traverser ()); + } + + void Choice:: + contains (Type& c, EdgeDispatcher& d) + { + iterate_and_dispatch (c.contains_begin (), c.contains_end (), d); + } + + void Choice:: + post (Type&) + { + } + + + // Sequence + // + void Sequence:: + traverse (Type& c) + { + pre (c); + contains (c); + post (c); + } + + void Sequence:: + pre (Type&) + { + } + + void Sequence:: + contains (Type& c) + { + iterate_and_dispatch ( + c.contains_begin (), c.contains_end (), edge_traverser ()); + } + + void Sequence:: + contains (Type& c, EdgeDispatcher& d) + { + iterate_and_dispatch (c.contains_begin (), c.contains_end (), d); + } + + void Sequence:: + post (Type&) + { + } + } +} diff --git a/libxsd-frontend/traversal/compositors.hxx b/libxsd-frontend/traversal/compositors.hxx new file mode 100644 index 0000000..a36f3b3 --- /dev/null +++ b/libxsd-frontend/traversal/compositors.hxx @@ -0,0 +1,134 @@ +// file : libxsd-frontend/traversal/compositors.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_FRONTEND_TRAVERSAL_COMPOSITORS_HXX +#define LIBXSD_FRONTEND_TRAVERSAL_COMPOSITORS_HXX + +#include <libxsd-frontend/traversal/elements.hxx> +#include <libxsd-frontend/semantic-graph/compositors.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + // + // + struct ContainsParticle: Edge<SemanticGraph::ContainsParticle> + { + ContainsParticle () + { + } + + ContainsParticle (NodeBase& n) + { + node_traverser (n); + } + + virtual void + traverse (Type&); + }; + + + // + // + struct ContainsCompositor: Edge<SemanticGraph::ContainsCompositor> + { + ContainsCompositor () + { + } + + ContainsCompositor (NodeBase& n) + { + node_traverser (n); + } + + virtual void + traverse (Type&); + }; + + // + // + struct Compositor : Node<SemanticGraph::Compositor> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + contains (Type&); + + virtual void + contains (Type&, EdgeDispatcher&); + + virtual void + post (Type&); + }; + + + // + // + struct All : Node<SemanticGraph::All> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + contains (Type&); + + virtual void + contains (Type&, EdgeDispatcher&); + + virtual void + post (Type&); + }; + + + // + // + struct Choice : Node<SemanticGraph::Choice> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + contains (Type&); + + virtual void + contains (Type&, EdgeDispatcher&); + + virtual void + post (Type&); + }; + + + // + // + struct Sequence : Node<SemanticGraph::Sequence> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + contains (Type&); + + virtual void + contains (Type&, EdgeDispatcher&); + + virtual void + post (Type&); + }; + } +} + +#endif // LIBXSD_FRONTEND_TRAVERSAL_COMPOSITORS_HXX diff --git a/libxsd-frontend/traversal/element-group.cxx b/libxsd-frontend/traversal/element-group.cxx new file mode 100644 index 0000000..e6e7bf0 --- /dev/null +++ b/libxsd-frontend/traversal/element-group.cxx @@ -0,0 +1,41 @@ +// file : libxsd-frontend/traversal/element-group.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <libxsd-frontend/traversal/element-group.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + void ElementGroup:: + traverse (Type& g) + { + pre (g); + names (g); + contains_compositor (g); + post (g); + } + + void ElementGroup:: + pre (Type&) + { + } + + void ElementGroup:: + contains_compositor (Type& g, EdgeDispatcher& d) + { + d.dispatch (g.contains_compositor ()); + } + + void ElementGroup:: + contains_compositor (Type& g) + { + contains_compositor (g, *this); + } + + void ElementGroup:: + post (Type&) + { + } + } +} diff --git a/libxsd-frontend/traversal/element-group.hxx b/libxsd-frontend/traversal/element-group.hxx new file mode 100644 index 0000000..2088e3c --- /dev/null +++ b/libxsd-frontend/traversal/element-group.hxx @@ -0,0 +1,34 @@ +// file : libxsd-frontend/traversal/element-group.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_FRONTEND_TRAVERSAL_ELEMENT_GROUP_HXX +#define LIBXSD_FRONTEND_TRAVERSAL_ELEMENT_GROUP_HXX + +#include <libxsd-frontend/traversal/elements.hxx> +#include <libxsd-frontend/semantic-graph/element-group.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + struct ElementGroup: ScopeTemplate<SemanticGraph::ElementGroup> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + contains_compositor (Type&); + + virtual void + contains_compositor (Type&, EdgeDispatcher&); + + virtual void + post (Type&); + }; + } +} + +#endif // LIBXSD_FRONTEND_TRAVERSAL_ELEMENT_GROUP_HXX diff --git a/libxsd-frontend/traversal/element.cxx b/libxsd-frontend/traversal/element.cxx new file mode 100644 index 0000000..82361fd --- /dev/null +++ b/libxsd-frontend/traversal/element.cxx @@ -0,0 +1,46 @@ +// file : libxsd-frontend/traversal/element.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <libxsd-frontend/traversal/element.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + void Element:: + traverse (Type& m) + { + pre (m); + belongs (m); + name (m); + post (m); + } + + void Element:: + pre (Type&) + { + } + + void Element:: + belongs (Type& m, EdgeDispatcher& d) + { + d.dispatch (m.belongs ()); + } + + void Element:: + belongs (Type& m) + { + belongs (m, edge_traverser ()); + } + + void Element:: + name (Type&) + { + } + + void Element:: + post (Type&) + { + } + } +} diff --git a/libxsd-frontend/traversal/element.hxx b/libxsd-frontend/traversal/element.hxx new file mode 100644 index 0000000..e530ac1 --- /dev/null +++ b/libxsd-frontend/traversal/element.hxx @@ -0,0 +1,37 @@ +// file : libxsd-frontend/traversal/element.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_FRONTEND_TRAVERSAL_ELEMENT_HXX +#define LIBXSD_FRONTEND_TRAVERSAL_ELEMENT_HXX + +#include <libxsd-frontend/traversal/elements.hxx> +#include <libxsd-frontend/semantic-graph/element.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + struct Element : Node<SemanticGraph::Element> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + belongs (Type&, EdgeDispatcher&); + + virtual void + belongs (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + } +} + +#endif // LIBXSD_FRONTEND_TRAVERSAL_ELEMENT_HXX diff --git a/libxsd-frontend/traversal/elements.cxx b/libxsd-frontend/traversal/elements.cxx new file mode 100644 index 0000000..4b97657 --- /dev/null +++ b/libxsd-frontend/traversal/elements.cxx @@ -0,0 +1,75 @@ +// file : libxsd-frontend/traversal/elements.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <libxsd-frontend/traversal/elements.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + // Instance + // + void Instance:: + traverse (Type& a) + { + pre (a); + belongs (a); + post (a); + } + + void Instance:: + pre (Type&) + { + } + + void Instance:: + belongs (Type& a, EdgeDispatcher& d) + { + d.dispatch (a.belongs ()); + } + + void Instance:: + belongs (Type& a) + { + belongs (a, edge_traverser ()); + } + + void Instance:: + post (Type&) + { + } + + + // Member + // + void Member:: + traverse (Type& a) + { + pre (a); + belongs (a); + post (a); + } + + void Member:: + pre (Type&) + { + } + + void Member:: + belongs (Type& a, EdgeDispatcher& d) + { + d.dispatch (a.belongs ()); + } + + void Member:: + belongs (Type& a) + { + belongs (a, edge_traverser ()); + } + + void Member:: + post (Type&) + { + } + } +} diff --git a/libxsd-frontend/traversal/elements.hxx b/libxsd-frontend/traversal/elements.hxx new file mode 100644 index 0000000..b3c7d13 --- /dev/null +++ b/libxsd-frontend/traversal/elements.hxx @@ -0,0 +1,410 @@ +// file : libxsd-frontend/traversal/elements.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_FRONTEND_TRAVERSAL_ELEMENTS_HXX +#define LIBXSD_FRONTEND_TRAVERSAL_ELEMENTS_HXX + +#include <libcutl/compiler/traversal.hxx> + +#include <libxsd-frontend/types.hxx> +#include <libxsd-frontend/semantic-graph/elements.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + using namespace cutl; + + typedef compiler::dispatcher<SemanticGraph::Node> NodeDispatcher; + typedef compiler::dispatcher<SemanticGraph::Edge> EdgeDispatcher; + + // + // + struct NodeBase: NodeDispatcher, EdgeDispatcher + { + void + edge_traverser (EdgeDispatcher& d) + { + EdgeDispatcher::traverser (d); + } + + EdgeDispatcher& + edge_traverser () + { + return *this; + } + + using NodeDispatcher::dispatch; + using EdgeDispatcher::dispatch; + + using EdgeDispatcher::iterate_and_dispatch; + }; + + struct EdgeBase: EdgeDispatcher, NodeDispatcher + { + void + node_traverser (NodeDispatcher& d) + { + NodeDispatcher::traverser (d); + } + + NodeDispatcher& + node_traverser () + { + return *this; + } + + using EdgeDispatcher::dispatch; + using NodeDispatcher::dispatch; + + using NodeDispatcher::iterate_and_dispatch; + }; + + inline EdgeBase& + operator>> (NodeBase& n, EdgeBase& e) + { + n.edge_traverser (e); + return e; + } + + inline NodeBase& + operator>> (EdgeBase& e, NodeBase& n) + { + e.node_traverser (n); + return n; + } + + // + // + template <typename T> + struct Node: compiler::traverser_impl<T, SemanticGraph::Node>, + virtual NodeBase + { + typedef T Type; + }; + + template <typename T> + struct Edge: compiler::traverser_impl<T, SemanticGraph::Edge>, + virtual EdgeBase + { + typedef T Type; + }; + + // + // Edges + // + + // + // + struct Names : Edge<SemanticGraph::Names> + { + Names () + { + } + + Names (NodeBase& n) + { + node_traverser (n); + } + + virtual void + traverse (Type& e) + { + dispatch (e.named ()); + } + }; + + + // + // + struct Belongs : Edge<SemanticGraph::Belongs> + { + Belongs () + { + } + + Belongs (NodeBase& n) + { + node_traverser (n); + } + + virtual void + traverse (Type& e) + { + dispatch (e.type ()); + } + }; + + // + // Nodes + // + + // + // + struct Nameable : Node<SemanticGraph::Nameable> + { + }; + + + // + // + template <typename T> + struct ScopeTemplate : Node<T> + { + public: + virtual void + traverse (T& s) + { + names (s); + } + + template<typename X> + void + names (T& s, + EdgeDispatcher& d, + void (X::*pre_) (T&) = (void (ScopeTemplate<T>::*)(T&)) (0), + void (X::*post_) (T&) = (void (ScopeTemplate<T>::*)(T&)) (0), + void (X::*none_) (T&) = (void (ScopeTemplate<T>::*)(T&)) (0), + void (X::*next_) (T&) = (void (ScopeTemplate<T>::*)(T&)) (0)) + { + X* this_ (dynamic_cast<X*> (this)); + + typename T::NamesIterator b (s.names_begin ()), e (s.names_end ()); + + if (b != e) + { + if (pre_) + (this_->*pre_) (s); + + //iterate_and_dispatch (b, e, d, *this_, next_, s); + + for (; b != s.names_end ();) + { + d.dispatch (*b); + + if (++b != s.names_end () && next_ != 0) + (this_->*next_) (s); + } + + if (post_) + (this_->*post_) (s); + } + else + { + if (none_) + (this_->*none_) (s); + } + } + + virtual void + names (T& s, EdgeDispatcher& d) + { + names<ScopeTemplate<T> > (s, d); + } + + virtual void + names (T& s) + { + names (s, + *this, + &ScopeTemplate<T>::names_pre, + &ScopeTemplate<T>::names_post, + &ScopeTemplate<T>::names_none, + &ScopeTemplate<T>::names_next); + } + + virtual void + names_pre (T&) + { + } + + virtual void + names_next (T&) + { + } + + virtual void + names_post (T&) + { + } + + virtual void + names_none (T&) + { + } + }; + + + // + // + typedef + ScopeTemplate<SemanticGraph::Scope> + Scope; + + + // + // + struct Type : Node<SemanticGraph::Type> + { + virtual void + traverse (SemanticGraph::Type&) = 0; + }; + + + // + // + struct Instance : Node<SemanticGraph::Instance> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + belongs (Type&, EdgeDispatcher&); + + virtual void + belongs (Type&); + + virtual void + post (Type&); + }; + + + // + // + struct Member : Node<SemanticGraph::Member> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + belongs (Type&, EdgeDispatcher&); + + virtual void + belongs (Type&); + + virtual void + post (Type&); + }; + + + // + // + struct Inherits : Edge<SemanticGraph::Inherits> + { + Inherits () + { + } + + Inherits (NodeBase& n) + { + node_traverser (n); + } + + virtual void + traverse (Type& e) + { + dispatch (e.base ()); + } + }; + + + // + // + struct Extends : Edge<SemanticGraph::Extends> + { + Extends () + { + } + + Extends (NodeBase& n) + { + node_traverser (n); + } + + virtual void + traverse (Type& e) + { + dispatch (e.base ()); + } + }; + + + // + // + struct Restricts : Edge<SemanticGraph::Restricts> + { + Restricts () + { + } + + Restricts (NodeBase& n) + { + node_traverser (n); + } + + virtual void + traverse (Type& e) + { + dispatch (e.base ()); + } + }; + + + // + // + struct Argumented : Edge<SemanticGraph::Arguments> + { + Argumented () + { + } + + Argumented (NodeBase& n) + { + node_traverser (n); + } + + virtual void + traverse (Type& a) + { + dispatch (a.type ()); + } + }; + + + /* + // + // + struct Contains : Edge<SemanticGraph::Contains> + { + virtual void + traverse (Type& e) + { + dispatch (e.element ()); + } + }; + */ + + // + // + typedef + Node<SemanticGraph::AnyType> + AnyType; + + + // + // + typedef + Node<SemanticGraph::AnySimpleType> + AnySimpleType; + } +} + +#include <libxsd-frontend/traversal/elements.txx> + +#endif // LIBXSD_FRONTEND_TRAVERSAL_ELEMENTS_HXX diff --git a/libxsd-frontend/traversal/elements.txx b/libxsd-frontend/traversal/elements.txx new file mode 100644 index 0000000..a479346 --- /dev/null +++ b/libxsd-frontend/traversal/elements.txx @@ -0,0 +1,9 @@ +// file : libxsd-frontend/traversal/elements.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace XSDFrontend +{ + namespace Traversal + { + } +} diff --git a/libxsd-frontend/traversal/enumeration.cxx b/libxsd-frontend/traversal/enumeration.cxx new file mode 100644 index 0000000..c11d8a7 --- /dev/null +++ b/libxsd-frontend/traversal/enumeration.cxx @@ -0,0 +1,89 @@ +// file : libxsd-frontend/traversal/enumeration.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <libxsd-frontend/traversal/enumeration.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + // Enumeration + // + void Enumeration:: + traverse (Type& e) + { + pre (e); + name (e); + inherits (e); + names (e); + post (e); + } + + void Enumeration:: + pre (Type&) + { + } + + void Enumeration:: + name (Type&) + { + } + + void Enumeration:: + inherits (Type& e) + { + inherits (e, *this); + } + + void Enumeration:: + inherits (Type& e, EdgeDispatcher& d) + { + if (e.inherits_p ()) + d.dispatch (e.inherits ()); + } + + void Enumeration:: + post (Type&) + { + } + + + // Enumerator + // + void Enumerator:: + traverse (Type& e) + { + pre (e); + belongs (e); + name (e); + post (e); + } + + void Enumerator:: + pre (Type&) + { + } + + void Enumerator:: + belongs (Type& e, EdgeDispatcher& d) + { + d.dispatch (e.belongs ()); + } + + void Enumerator:: + belongs (Type& e) + { + belongs (e, edge_traverser ()); + } + + void Enumerator:: + name (Type&) + { + } + + void Enumerator:: + post (Type&) + { + } + } +} diff --git a/libxsd-frontend/traversal/enumeration.hxx b/libxsd-frontend/traversal/enumeration.hxx new file mode 100644 index 0000000..eded1d9 --- /dev/null +++ b/libxsd-frontend/traversal/enumeration.hxx @@ -0,0 +1,58 @@ +// file : libxsd-frontend/traversal/enumeration.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_FRONTEND_TRAVERSAL_ENUMERATION_HXX +#define LIBXSD_FRONTEND_TRAVERSAL_ENUMERATION_HXX + +#include <libxsd-frontend/traversal/elements.hxx> +#include <libxsd-frontend/semantic-graph/enumeration.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + struct Enumeration : ScopeTemplate<SemanticGraph::Enumeration> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + inherits (Type&); + + void + inherits (Type&, EdgeDispatcher&); + + virtual void + post (Type&); + }; + + struct Enumerator : Node<SemanticGraph::Enumerator> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + belongs (Type&, EdgeDispatcher&); + + virtual void + belongs (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + } +} + +#endif // LIBXSD_FRONTEND_TRAVERSAL_ENUMERATION_HXX diff --git a/libxsd-frontend/traversal/fundamental.cxx b/libxsd-frontend/traversal/fundamental.cxx new file mode 100644 index 0000000..efc85a9 --- /dev/null +++ b/libxsd-frontend/traversal/fundamental.cxx @@ -0,0 +1,11 @@ +// file : libxsd-frontend/traversal/fundamental.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <libxsd-frontend/traversal/fundamental.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + } +} diff --git a/libxsd-frontend/traversal/fundamental.hxx b/libxsd-frontend/traversal/fundamental.hxx new file mode 100644 index 0000000..0dc1e63 --- /dev/null +++ b/libxsd-frontend/traversal/fundamental.hxx @@ -0,0 +1,232 @@ +// file : libxsd-frontend/traversal/fundamental.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_FRONTEND_TRAVERSAL_FUNDAMENTAL_HXX +#define LIBXSD_FRONTEND_TRAVERSAL_FUNDAMENTAL_HXX + +#include <libxsd-frontend/traversal/elements.hxx> +#include <libxsd-frontend/semantic-graph/fundamental.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + namespace Fundamental + { + typedef + Node<SemanticGraph::Fundamental::Type> + Type; + + // Integers. + // + typedef + Node<SemanticGraph::Fundamental::Byte> + Byte; + + typedef + Node<SemanticGraph::Fundamental::UnsignedByte> + UnsignedByte; + + typedef + Node<SemanticGraph::Fundamental::Short> + Short; + + typedef + Node<SemanticGraph::Fundamental::UnsignedShort> + UnsignedShort; + + typedef + Node<SemanticGraph::Fundamental::Int> + Int; + + typedef + Node<SemanticGraph::Fundamental::UnsignedInt> + UnsignedInt; + + typedef + Node<SemanticGraph::Fundamental::Long> + Long; + + typedef + Node<SemanticGraph::Fundamental::UnsignedLong> + UnsignedLong; + + typedef + Node<SemanticGraph::Fundamental::Integer> + Integer; + + typedef + Node<SemanticGraph::Fundamental::NonPositiveInteger> + NonPositiveInteger; + + typedef + Node<SemanticGraph::Fundamental::NonNegativeInteger> + NonNegativeInteger; + + typedef + Node<SemanticGraph::Fundamental::PositiveInteger> + PositiveInteger; + + typedef + Node<SemanticGraph::Fundamental::NegativeInteger> + NegativeInteger; + + + // Boolean. + // + typedef + Node<SemanticGraph::Fundamental::Boolean> + Boolean; + + + // Floats. + // + typedef + Node<SemanticGraph::Fundamental::Float> + Float; + + typedef + Node<SemanticGraph::Fundamental::Double> + Double; + + typedef + Node<SemanticGraph::Fundamental::Decimal> + Decimal; + + + // Strings. + // + typedef + Node<SemanticGraph::Fundamental::String> + String; + + typedef + Node<SemanticGraph::Fundamental::NormalizedString> + NormalizedString; + + typedef + Node<SemanticGraph::Fundamental::Token> + Token; + + typedef + Node<SemanticGraph::Fundamental::Name> + Name; + + typedef + Node<SemanticGraph::Fundamental::NameToken> + NameToken; + + typedef + Node<SemanticGraph::Fundamental::NameTokens> + NameTokens; + + typedef + Node<SemanticGraph::Fundamental::NCName> + NCName; + + typedef + Node<SemanticGraph::Fundamental::Language> + Language; + + + // Qualified name. + // + typedef + Node<SemanticGraph::Fundamental::QName> + QName; + + + // ID/IDREF. + // + typedef + Node<SemanticGraph::Fundamental::Id> + Id; + + typedef + Node<SemanticGraph::Fundamental::IdRef> + IdRef; + + typedef + Node<SemanticGraph::Fundamental::IdRefs> + IdRefs; + + + // URI. + // + typedef + Node<SemanticGraph::Fundamental::AnyURI> + AnyURI; + + + // Binary. + // + typedef + Node<SemanticGraph::Fundamental::Base64Binary> + Base64Binary; + + typedef + Node<SemanticGraph::Fundamental::HexBinary> + HexBinary; + + + // Date/time. + // + typedef + Node<SemanticGraph::Fundamental::Date> + Date; + + typedef + Node<SemanticGraph::Fundamental::DateTime> + DateTime; + + typedef + Node<SemanticGraph::Fundamental::Duration> + Duration; + + typedef + Node<SemanticGraph::Fundamental::Day> + Day; + + typedef + Node<SemanticGraph::Fundamental::Month> + Month; + + typedef + Node<SemanticGraph::Fundamental::MonthDay> + MonthDay; + + typedef + Node<SemanticGraph::Fundamental::Year> + Year; + + typedef + Node<SemanticGraph::Fundamental::YearMonth> + YearMonth; + + typedef + Node<SemanticGraph::Fundamental::Time> + Time; + + + // Entity. + // + typedef + Node<SemanticGraph::Fundamental::Entity> + Entity; + + typedef + Node<SemanticGraph::Fundamental::Entities> + Entities; + + + // Notation. + // + typedef + Node<SemanticGraph::Fundamental::Notation> + Notation; + } + } +} + + +#endif // LIBXSD_FRONTEND_TRAVERSAL_FUNDAMENTAL_HXX diff --git a/libxsd-frontend/traversal/list.cxx b/libxsd-frontend/traversal/list.cxx new file mode 100644 index 0000000..64a43d9 --- /dev/null +++ b/libxsd-frontend/traversal/list.cxx @@ -0,0 +1,46 @@ +// file : libxsd-frontend/traversal/list.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <libxsd-frontend/traversal/list.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + void List:: + traverse (Type& l) + { + pre (l); + argumented (l); + name (l); + post (l); + } + + void List:: + pre (Type&) + { + } + + void List:: + argumented (Type& l) + { + argumented (l, *this); + } + + void List:: + argumented (Type& l, EdgeDispatcher& d) + { + d.dispatch (l.argumented ()); + } + + void List:: + name (Type&) + { + } + + void List:: + post (Type&) + { + } + } +} diff --git a/libxsd-frontend/traversal/list.hxx b/libxsd-frontend/traversal/list.hxx new file mode 100644 index 0000000..473af7f --- /dev/null +++ b/libxsd-frontend/traversal/list.hxx @@ -0,0 +1,37 @@ +// file : libxsd-frontend/traversal/list.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_FRONTEND_TRAVERSAL_LIST_HXX +#define LIBXSD_FRONTEND_TRAVERSAL_LIST_HXX + +#include <libxsd-frontend/traversal/elements.hxx> +#include <libxsd-frontend/semantic-graph/list.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + struct List: Node<SemanticGraph::List> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + argumented (Type&); + + virtual void + argumented (Type&, EdgeDispatcher& d); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + } +} + +#endif // LIBXSD_FRONTEND_TRAVERSAL_LIST_HXX diff --git a/libxsd-frontend/traversal/namespace.cxx b/libxsd-frontend/traversal/namespace.cxx new file mode 100644 index 0000000..3bafda8 --- /dev/null +++ b/libxsd-frontend/traversal/namespace.cxx @@ -0,0 +1,11 @@ +// file : libxsd-frontend/traversal/namespace.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <libxsd-frontend/traversal/namespace.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + } +} diff --git a/libxsd-frontend/traversal/namespace.hxx b/libxsd-frontend/traversal/namespace.hxx new file mode 100644 index 0000000..ac115d8 --- /dev/null +++ b/libxsd-frontend/traversal/namespace.hxx @@ -0,0 +1,43 @@ +// file : libxsd-frontend/traversal/namespace.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_FRONTEND_TRAVERSAL_NAMESPACE_HXX +#define LIBXSD_FRONTEND_TRAVERSAL_NAMESPACE_HXX + +#include <libxsd-frontend/traversal/elements.hxx> +#include <libxsd-frontend/semantic-graph/namespace.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + struct Namespace: ScopeTemplate<SemanticGraph::Namespace> + { + virtual void + traverse (Type& m) + { + pre (m); + name (m); + names (m); + post (m); + } + + virtual void + pre (Type&) + { + } + + virtual void + name (Type&) + { + } + + virtual void + post (Type&) + { + } + }; + } +} + +#endif // LIBXSD_FRONTEND_TRAVERSAL_NAMESPACE_HXX diff --git a/libxsd-frontend/traversal/particle.cxx b/libxsd-frontend/traversal/particle.cxx new file mode 100644 index 0000000..1b80536 --- /dev/null +++ b/libxsd-frontend/traversal/particle.cxx @@ -0,0 +1,29 @@ +// file : libxsd-frontend/traversal/particle.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <libxsd-frontend/traversal/particle.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + // Particle + // + void Particle:: + traverse (Type& c) + { + pre (c); + post (c); + } + + void Particle:: + pre (Type&) + { + } + + void Particle:: + post (Type&) + { + } + } +} diff --git a/libxsd-frontend/traversal/particle.hxx b/libxsd-frontend/traversal/particle.hxx new file mode 100644 index 0000000..c931e65 --- /dev/null +++ b/libxsd-frontend/traversal/particle.hxx @@ -0,0 +1,28 @@ +// file : libxsd-frontend/traversal/particle.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_FRONTEND_TRAVERSAL_PARTICLE_HXX +#define LIBXSD_FRONTEND_TRAVERSAL_PARTICLE_HXX + +#include <libxsd-frontend/traversal/elements.hxx> +#include <libxsd-frontend/semantic-graph/particle.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + struct Particle : Node<SemanticGraph::Particle> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + post (Type&); + }; + } +} + +#endif // LIBXSD_FRONTEND_TRAVERSAL_PARTICLE_HXX diff --git a/libxsd-frontend/traversal/schema.cxx b/libxsd-frontend/traversal/schema.cxx new file mode 100644 index 0000000..d38416c --- /dev/null +++ b/libxsd-frontend/traversal/schema.cxx @@ -0,0 +1,11 @@ +// file : libxsd-frontend/traversal/schema.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <libxsd-frontend/traversal/schema.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + } +} diff --git a/libxsd-frontend/traversal/schema.hxx b/libxsd-frontend/traversal/schema.hxx new file mode 100644 index 0000000..52e9302 --- /dev/null +++ b/libxsd-frontend/traversal/schema.hxx @@ -0,0 +1,148 @@ +// file : libxsd-frontend/traversal/schema.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_FRONTEND_TRAVERSAL_SCHEMA_HXX +#define LIBXSD_FRONTEND_TRAVERSAL_SCHEMA_HXX + +#include <libxsd-frontend/traversal/elements.hxx> +#include <libxsd-frontend/semantic-graph/schema.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + // + // + struct Uses: Edge<SemanticGraph::Uses> + { + Uses () + { + } + + Uses (NodeBase& n) + { + node_traverser (n); + } + + virtual void + traverse (Type& e) + { + dispatch (e.schema ()); + } + }; + + // + // + struct Implies: Edge<SemanticGraph::Implies> + { + Implies () + { + } + + Implies (NodeBase& n) + { + node_traverser (n); + } + + virtual void + traverse (Type& e) + { + dispatch (e.schema ()); + } + }; + + + // + // + struct Sources: Edge<SemanticGraph::Sources> + { + Sources () + { + } + + Sources (NodeBase& n) + { + node_traverser (n); + } + + virtual void + traverse (Type& e) + { + dispatch (e.schema ()); + } + }; + + + // + // + struct Includes: Edge<SemanticGraph::Includes> + { + Includes () + { + } + + Includes (NodeBase& n) + { + node_traverser (n); + } + + virtual void + traverse (Type& e) + { + dispatch (e.schema ()); + } + }; + + + // + // + struct Imports: Edge<SemanticGraph::Imports> + { + Imports () + { + } + + Imports (NodeBase& n) + { + node_traverser (n); + } + + virtual void + traverse (Type& e) + { + dispatch (e.schema ()); + } + }; + + + // + // + struct Schema: ScopeTemplate<SemanticGraph::Schema> + { + virtual void + traverse (Type& s) + { + pre (s); + + iterate_and_dispatch ( + s.uses_begin (), s.uses_end (), edge_traverser ()); + + names (s); + + post (s); + } + + virtual void + pre (Type&) + { + } + + virtual void + post (Type&) + { + } + }; + } +} + +#endif // LIBXSD_FRONTEND_TRAVERSAL_SCHEMA_HXX diff --git a/libxsd-frontend/traversal/union.cxx b/libxsd-frontend/traversal/union.cxx new file mode 100644 index 0000000..782eecc --- /dev/null +++ b/libxsd-frontend/traversal/union.cxx @@ -0,0 +1,46 @@ +// file : libxsd-frontend/traversal/union.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <libxsd-frontend/traversal/union.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + void Union:: + traverse (Type& u) + { + pre (u); + argumented (u); + name (u); + post (u); + } + + void Union:: + pre (Type&) + { + } + + void Union:: + argumented (Type& u) + { + argumented (u, *this); + } + + void Union:: + argumented (Type& u, EdgeDispatcher& d) + { + iterate_and_dispatch (u.argumented_begin (), u.argumented_end (), d); + } + + void Union:: + name (Type&) + { + } + + void Union:: + post (Type&) + { + } + } +} diff --git a/libxsd-frontend/traversal/union.hxx b/libxsd-frontend/traversal/union.hxx new file mode 100644 index 0000000..a1df894 --- /dev/null +++ b/libxsd-frontend/traversal/union.hxx @@ -0,0 +1,37 @@ +// file : libxsd-frontend/traversal/union.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_FRONTEND_TRAVERSAL_UNION_HXX +#define LIBXSD_FRONTEND_TRAVERSAL_UNION_HXX + +#include <libxsd-frontend/traversal/elements.hxx> +#include <libxsd-frontend/semantic-graph/union.hxx> + +namespace XSDFrontend +{ + namespace Traversal + { + struct Union: Node<SemanticGraph::Union> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + argumented (Type&); + + virtual void + argumented (Type&, EdgeDispatcher& d); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + } +} + +#endif // LIBXSD_FRONTEND_TRAVERSAL_UNION_HXX |