aboutsummaryrefslogtreecommitdiff
path: root/libxsd-frontend/semantic-graph
diff options
context:
space:
mode:
Diffstat (limited to 'libxsd-frontend/semantic-graph')
-rw-r--r--libxsd-frontend/semantic-graph/annotation.cxx44
-rw-r--r--libxsd-frontend/semantic-graph/annotation.hxx74
-rw-r--r--libxsd-frontend/semantic-graph/any-attribute.cxx110
-rw-r--r--libxsd-frontend/semantic-graph/any-attribute.hxx79
-rw-r--r--libxsd-frontend/semantic-graph/any.cxx121
-rw-r--r--libxsd-frontend/semantic-graph/any.hxx84
-rw-r--r--libxsd-frontend/semantic-graph/attribute-group.cxx33
-rw-r--r--libxsd-frontend/semantic-graph/attribute-group.hxx23
-rw-r--r--libxsd-frontend/semantic-graph/attribute.cxx40
-rw-r--r--libxsd-frontend/semantic-graph/attribute.hxx35
-rw-r--r--libxsd-frontend/semantic-graph/complex.cxx44
-rw-r--r--libxsd-frontend/semantic-graph/complex.hxx93
-rw-r--r--libxsd-frontend/semantic-graph/compositors.cxx99
-rw-r--r--libxsd-frontend/semantic-graph/compositors.hxx233
-rw-r--r--libxsd-frontend/semantic-graph/element-group.cxx33
-rw-r--r--libxsd-frontend/semantic-graph/element-group.hxx41
-rw-r--r--libxsd-frontend/semantic-graph/element.cxx52
-rw-r--r--libxsd-frontend/semantic-graph/element.hxx93
-rw-r--r--libxsd-frontend/semantic-graph/elements.cxx299
-rw-r--r--libxsd-frontend/semantic-graph/elements.hxx1003
-rw-r--r--libxsd-frontend/semantic-graph/enumeration.cxx58
-rw-r--r--libxsd-frontend/semantic-graph/enumeration.hxx29
-rw-r--r--libxsd-frontend/semantic-graph/fundamental.cxx1096
-rw-r--r--libxsd-frontend/semantic-graph/fundamental.hxx468
-rw-r--r--libxsd-frontend/semantic-graph/list.cxx33
-rw-r--r--libxsd-frontend/semantic-graph/list.hxx21
-rw-r--r--libxsd-frontend/semantic-graph/namespace.cxx33
-rw-r--r--libxsd-frontend/semantic-graph/namespace.hxx26
-rw-r--r--libxsd-frontend/semantic-graph/particle.cxx53
-rw-r--r--libxsd-frontend/semantic-graph/particle.hxx139
-rw-r--r--libxsd-frontend/semantic-graph/schema.cxx129
-rw-r--r--libxsd-frontend/semantic-graph/schema.hxx236
-rw-r--r--libxsd-frontend/semantic-graph/union.cxx33
-rw-r--r--libxsd-frontend/semantic-graph/union.hxx21
34 files changed, 5008 insertions, 0 deletions
diff --git a/libxsd-frontend/semantic-graph/annotation.cxx b/libxsd-frontend/semantic-graph/annotation.cxx
new file mode 100644
index 0000000..c57e393
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/annotation.cxx
@@ -0,0 +1,44 @@
+// file : libxsd-frontend/semantic-graph/annotation.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/annotation.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ using compiler::type_info;
+
+ // Annotates
+ //
+ namespace
+ {
+ struct AnnotatesInit
+ {
+ AnnotatesInit ()
+ {
+ type_info ti (typeid (Annotates));
+ ti.add_base (typeid (Edge));
+ insert (ti);
+ }
+ } annotates_init_;
+ }
+
+ // Annotation
+ //
+ namespace
+ {
+ struct AnnotationInit
+ {
+ AnnotationInit ()
+ {
+ type_info ti (typeid (Annotation));
+ ti.add_base (typeid (Node));
+ insert (ti);
+ }
+ } annotation_init_;
+ }
+ }
+}
diff --git a/libxsd-frontend/semantic-graph/annotation.hxx b/libxsd-frontend/semantic-graph/annotation.hxx
new file mode 100644
index 0000000..797a259
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/annotation.hxx
@@ -0,0 +1,74 @@
+// file : libxsd-frontend/semantic-graph/annotation.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_ANNOTATION_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_ANNOTATION_HXX
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ //
+ //
+ class Annotation;
+
+ class Annotates: public virtual Edge
+ {
+ public:
+ Annotation&
+ annotation ()
+ {
+ return *annotation_;
+ }
+
+ public:
+ Annotates (): annotation_ (0) {}
+
+ void
+ set_left_node (Annotation& a)
+ {
+ annotation_ = &a;
+ }
+
+ void
+ set_right_node (Node&) {}
+
+ void
+ set_right_node (Edge&) {}
+
+ private:
+ Annotation* annotation_;
+ };
+
+ //
+ //
+ class Annotation: public virtual Node
+ {
+ public:
+ String const&
+ documentation () const
+ {
+ return documentation_;
+ }
+
+ public:
+ Annotation (Path const& file,
+ unsigned long line,
+ unsigned long column,
+ String const& documentation)
+ : Node (file, line, column), documentation_ (documentation)
+ {
+ }
+
+ void
+ add_edge_left (Annotates&) {}
+
+ private:
+ String documentation_;
+ };
+ }
+}
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_ANNOTATION_HXX
diff --git a/libxsd-frontend/semantic-graph/any-attribute.cxx b/libxsd-frontend/semantic-graph/any-attribute.cxx
new file mode 100644
index 0000000..8428c27
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/any-attribute.cxx
@@ -0,0 +1,110 @@
+// file : libxsd-frontend/semantic-graph/any-attribute.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/any-attribute.hxx>
+#include <libxsd-frontend/semantic-graph/compositors.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ AnyAttribute::
+ AnyAttribute (Path const& file,
+ unsigned long line,
+ unsigned long column,
+ String const& namespaces)
+ : Node (file, line, column),
+ prototype_ (0)
+ {
+ // Not sure if the separator is just space or any white-space
+ // chararcter.
+ //
+
+ for (size_t i (0), j (namespaces.find (L' '));;)
+ {
+ if (j != String::npos)
+ {
+ namespaces_.push_back (String (namespaces, i, j - i));
+
+ i = j + 1;
+ j = namespaces.find (L' ', i);
+ }
+ else
+ {
+ // Last element.
+ //
+ namespaces_.push_back (String (namespaces, i));
+ break;
+ }
+ }
+ }
+
+ AnyAttribute::
+ AnyAttribute (Path const& file,
+ unsigned long line,
+ unsigned long column,
+ NamespaceIterator begin,
+ NamespaceIterator end)
+ : Node (file, line, column),
+ prototype_ (0)
+ {
+ for (; begin != end; ++begin)
+ namespaces_.push_back (*begin);
+ }
+
+ namespace
+ {
+ Namespace&
+ namespace_ (Nameable& n)
+ {
+ // The basic idea goes like this: go up Names edges until you
+ // reach Namespace. There are, however, anonymous types which
+ // need special handling. In the case of an anonymous type we
+ // will go up the first Belongs edge (because the first edge
+ // is where the type was defined.
+ //
+
+ if (n.named_p ())
+ {
+ Scope& s (n.scope ());
+ Namespace* ns (dynamic_cast<Namespace*> (&n));
+
+ return ns ? *ns : namespace_ (s);
+ }
+ else
+ {
+ Type& t (dynamic_cast<Type&> (n));
+ Belongs& b (*t.classifies_begin ());
+
+ return namespace_ (b.instance ());
+ }
+ }
+ }
+
+ Namespace& AnyAttribute::
+ definition_namespace ()
+ {
+ if (prototype_p ())
+ return prototype ().definition_namespace ();
+
+ return namespace_ (scope ());
+ }
+
+ namespace
+ {
+ using compiler::type_info;
+
+ struct AnyAttributeInit
+ {
+ AnyAttributeInit ()
+ {
+ type_info ti (typeid (AnyAttribute));
+ ti.add_base (typeid (Nameable));
+ insert (ti);
+ }
+ } any_attribute_init_;
+ }
+ }
+}
diff --git a/libxsd-frontend/semantic-graph/any-attribute.hxx b/libxsd-frontend/semantic-graph/any-attribute.hxx
new file mode 100644
index 0000000..3a25200
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/any-attribute.hxx
@@ -0,0 +1,79 @@
+// file : libxsd-frontend/semantic-graph/any-attribute.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_ANY_ATTRIBUTE_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_ANY_ATTRIBUTE_HXX
+
+#include <vector>
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+#include <libxsd-frontend/semantic-graph/namespace.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ class AnyAttribute: public virtual Nameable
+ {
+ typedef std::vector<String> Namespaces;
+
+ public:
+ typedef Namespaces::const_iterator NamespaceIterator;
+
+ NamespaceIterator
+ namespace_begin () const
+ {
+ return namespaces_.begin ();
+ }
+
+ NamespaceIterator
+ namespace_end () const
+ {
+ return namespaces_.end ();
+ }
+
+ public:
+ bool
+ prototype_p ()
+ {
+ return prototype_ != 0;
+ }
+
+ AnyAttribute&
+ prototype ()
+ {
+ assert (prototype_ != 0);
+ return *prototype_;
+ }
+
+ void
+ prototype (AnyAttribute& a)
+ {
+ assert (prototype_ == 0);
+ prototype_ = &a;
+ }
+
+ public:
+ Namespace&
+ definition_namespace ();
+
+ public:
+ AnyAttribute (Path const& file,
+ unsigned long line,
+ unsigned long column,
+ String const& namespaces);
+
+ AnyAttribute (Path const& file,
+ unsigned long line,
+ unsigned long column,
+ NamespaceIterator begin,
+ NamespaceIterator end);
+
+ private:
+ AnyAttribute* prototype_;
+ Namespaces namespaces_;
+ };
+ }
+}
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_ANY_ATTRIBUTE_HXX
diff --git a/libxsd-frontend/semantic-graph/any.cxx b/libxsd-frontend/semantic-graph/any.cxx
new file mode 100644
index 0000000..eb5f7d0
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/any.cxx
@@ -0,0 +1,121 @@
+// file : libxsd-frontend/semantic-graph/any.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/any.hxx>
+#include <libxsd-frontend/semantic-graph/compositors.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ Any::
+ Any (Path const& file,
+ unsigned long line,
+ unsigned long column,
+ String const& namespaces)
+ : Node (file, line, column),
+ prototype_ (0)
+ {
+ // Not sure if the separator is just space or any white-space
+ // chararcter.
+ //
+
+ for (size_t i (0), j (namespaces.find (L' '));;)
+ {
+ if (j != String::npos)
+ {
+ namespaces_.push_back (String (namespaces, i, j - i));
+
+ i = j + 1;
+ j = namespaces.find (L' ', i);
+ }
+ else
+ {
+ // Last element.
+ //
+ namespaces_.push_back (String (namespaces, i));
+ break;
+ }
+ }
+ }
+
+ Any::
+ Any (Path const& file,
+ unsigned long line,
+ unsigned long column,
+ NamespaceIterator begin,
+ NamespaceIterator end)
+ : Node (file, line, column),
+ prototype_ (0)
+ {
+ for (; begin != end; ++begin)
+ namespaces_.push_back (*begin);
+ }
+
+ namespace
+ {
+ Namespace&
+ namespace_ (Nameable& n)
+ {
+ // The basic idea goes like this: go up Names edges until you
+ // reach Namespace. There are, however, anonymous types which
+ // need special handling. In the case of an anonymous type we
+ // will go up the first Belongs edge (because the first edge
+ // is where the type was defined.
+ //
+
+ if (n.named_p ())
+ {
+ Scope& s (n.scope ());
+ Namespace* ns (dynamic_cast<Namespace*> (&n));
+
+ return ns ? *ns : namespace_ (s);
+ }
+ else
+ {
+ Type& t (dynamic_cast<Type&> (n));
+ Belongs& b (*t.classifies_begin ());
+
+ return namespace_ (b.instance ());
+ }
+ }
+ }
+
+ Namespace& Any::
+ definition_namespace ()
+ {
+ if (prototype_p ())
+ return prototype ().definition_namespace ();
+
+ // Get to our scope.
+ //
+ Compositor* c (&contained_particle ().compositor ());
+
+ while(!c->contained_compositor_p ())
+ c = &c->contained_particle ().compositor ();
+
+ Scope& scope (
+ dynamic_cast<Scope&> (c->contained_compositor ().container ()));
+
+ return namespace_ (scope);
+ }
+
+ namespace
+ {
+ using compiler::type_info;
+
+ struct AnyInit
+ {
+ AnyInit ()
+ {
+ type_info ti (typeid (Any));
+ ti.add_base (typeid (Nameable));
+ ti.add_base (typeid (Particle));
+ insert (ti);
+ }
+ } any_init_;
+ }
+ }
+}
diff --git a/libxsd-frontend/semantic-graph/any.hxx b/libxsd-frontend/semantic-graph/any.hxx
new file mode 100644
index 0000000..be9dcbf
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/any.hxx
@@ -0,0 +1,84 @@
+// file : libxsd-frontend/semantic-graph/any.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_ANY_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_ANY_HXX
+
+#include <vector>
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+#include <libxsd-frontend/semantic-graph/particle.hxx>
+#include <libxsd-frontend/semantic-graph/namespace.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ class Any: public virtual Nameable,
+ public virtual Particle
+ {
+ typedef std::vector<String> Namespaces;
+
+ public:
+ typedef Namespaces::const_iterator NamespaceIterator;
+
+ NamespaceIterator
+ namespace_begin () const
+ {
+ return namespaces_.begin ();
+ }
+
+ NamespaceIterator
+ namespace_end () const
+ {
+ return namespaces_.end ();
+ }
+
+ public:
+ bool
+ prototype_p ()
+ {
+ return prototype_ != 0;
+ }
+
+ Any&
+ prototype ()
+ {
+ assert (prototype_ != 0);
+ return *prototype_;
+ }
+
+ void
+ prototype (Any& a)
+ {
+ assert (prototype_ == 0);
+ prototype_ = &a;
+ }
+
+ public:
+ Namespace&
+ definition_namespace ();
+
+ public:
+ Any (Path const& file,
+ unsigned long line,
+ unsigned long column,
+ String const& namespaces);
+
+ Any (Path const& file,
+ unsigned long line,
+ unsigned long column,
+ NamespaceIterator begin,
+ NamespaceIterator end);
+
+ using Nameable::add_edge_right;
+ using Particle::add_edge_right;
+
+ private:
+ Any* prototype_;
+ Namespaces namespaces_;
+ };
+ }
+}
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_ANY_HXX
diff --git a/libxsd-frontend/semantic-graph/attribute-group.cxx b/libxsd-frontend/semantic-graph/attribute-group.cxx
new file mode 100644
index 0000000..834dde8
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/attribute-group.cxx
@@ -0,0 +1,33 @@
+// file : libxsd-frontend/semantic-graph/attribute-group.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/attribute-group.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ AttributeGroup::
+ AttributeGroup (Path const& file, unsigned long line, unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ namespace
+ {
+ using compiler::type_info;
+
+ struct AttributeGroupInit
+ {
+ AttributeGroupInit ()
+ {
+ type_info ti (typeid (AttributeGroup));
+ ti.add_base (typeid (Scope));
+ insert (ti);
+ }
+ } attribute_group_init_;
+ }
+ }
+}
diff --git a/libxsd-frontend/semantic-graph/attribute-group.hxx b/libxsd-frontend/semantic-graph/attribute-group.hxx
new file mode 100644
index 0000000..b49d86e
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/attribute-group.hxx
@@ -0,0 +1,23 @@
+// file : libxsd-frontend/semantic-graph/attribute-group.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_ATTRIBUTE_GROUP_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_ATTRIBUTE_GROUP_HXX
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ class AttributeGroup: public virtual Scope
+ {
+ public:
+ AttributeGroup (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+ }
+}
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_ATTRIBUTE_GROUP_HXX
diff --git a/libxsd-frontend/semantic-graph/attribute.cxx b/libxsd-frontend/semantic-graph/attribute.cxx
new file mode 100644
index 0000000..b743bbd
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/attribute.cxx
@@ -0,0 +1,40 @@
+// file : libxsd-frontend/semantic-graph/attribute.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/attribute.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ Attribute::
+ Attribute (Path const& file,
+ unsigned long line,
+ unsigned long column,
+ bool optional,
+ bool global,
+ bool qualified)
+ : Node (file, line, column),
+ Member (global, qualified),
+ optional_ (optional)
+ {
+ }
+
+ namespace
+ {
+ using compiler::type_info;
+
+ struct AttributeInit
+ {
+ AttributeInit ()
+ {
+ type_info ti (typeid (Attribute));
+ ti.add_base (typeid (Member));
+ insert (ti);
+ }
+ } attribute_init_;
+ }
+ }
+}
diff --git a/libxsd-frontend/semantic-graph/attribute.hxx b/libxsd-frontend/semantic-graph/attribute.hxx
new file mode 100644
index 0000000..5b0b160
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/attribute.hxx
@@ -0,0 +1,35 @@
+// file : libxsd-frontend/semantic-graph/attribute.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_ATTRIBUTE_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_ATTRIBUTE_HXX
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ class Attribute: public virtual Member
+ {
+ public:
+ bool
+ optional_p () const
+ {
+ return optional_;
+ }
+
+ public:
+ Attribute (Path const& file,
+ unsigned long line,
+ unsigned long column,
+ bool optional,
+ bool global,
+ bool qualified);
+ private:
+ bool optional_;
+ };
+ }
+}
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_ATTRIBUTE_HXX
diff --git a/libxsd-frontend/semantic-graph/complex.cxx b/libxsd-frontend/semantic-graph/complex.cxx
new file mode 100644
index 0000000..59173ba
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/complex.cxx
@@ -0,0 +1,44 @@
+// file : libxsd-frontend/semantic-graph/complex.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/complex.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ Complex::
+ Complex ()
+ : abstract_ (false), mixed_ (false), contains_compositor_ (0)
+ {
+ }
+
+ Complex::
+ Complex (Path const& file,
+ unsigned long line,
+ unsigned long column,
+ bool abstract)
+ : Node (file, line, column),
+ abstract_ (abstract), mixed_ (false), contains_compositor_ (0)
+ {
+ }
+
+ namespace
+ {
+ using compiler::type_info;
+
+ struct ComplexInit
+ {
+ ComplexInit ()
+ {
+ type_info ti (typeid (Complex));
+ ti.add_base (typeid (Type));
+ ti.add_base (typeid (Scope));
+ insert (ti);
+ }
+ } complex_init_;
+ }
+ }
+}
diff --git a/libxsd-frontend/semantic-graph/complex.hxx b/libxsd-frontend/semantic-graph/complex.hxx
new file mode 100644
index 0000000..f1cf526
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/complex.hxx
@@ -0,0 +1,93 @@
+// file : libxsd-frontend/semantic-graph/complex.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_COMPLEX_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_COMPLEX_HXX
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+#include <libxsd-frontend/semantic-graph/compositors.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ class Complex: public virtual Type, public virtual Scope
+ {
+ public:
+ bool
+ abstract_p () const {return abstract_;}
+
+ bool
+ mixed_p () const
+ {
+ if (mixed_)
+ return true;
+
+ // If we have empty content, then we have the same content
+ // type as our base.
+ //
+ if (!contains_compositor_p () && inherits_p ())
+ {
+ if (Complex* b = dynamic_cast<Complex*> (&inherits ().base ()))
+ return b->mixed_p ();
+ }
+
+ return false;
+ }
+
+ public:
+ bool
+ contains_compositor_p () const
+ {
+ return contains_compositor_ != 0;
+ }
+
+ ContainsCompositor&
+ contains_compositor ()
+ {
+ assert (contains_compositor_ != 0);
+ return *contains_compositor_;
+ }
+
+ public:
+ void
+ mixed_p (bool m)
+ {
+ mixed_ = m;
+ }
+
+ public:
+ Complex (Path const& file,
+ unsigned long line,
+ unsigned long column,
+ bool abstract);
+
+ void
+ add_edge_left (ContainsCompositor& e)
+ {
+ contains_compositor_ = &e;
+ }
+
+ void
+ remove_edge_left (ContainsCompositor& e)
+ {
+ assert (contains_compositor_ == &e);
+ contains_compositor_ = 0;
+ }
+
+ using Type::add_edge_right;
+ using Type::add_edge_left;
+ using Scope::add_edge_left;
+
+ protected:
+ Complex (); // For virtual inheritance (Enumeration).
+
+ private:
+ bool abstract_;
+ bool mixed_;
+ ContainsCompositor* contains_compositor_;
+ };
+ }
+}
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_COMPLEX_HXX
diff --git a/libxsd-frontend/semantic-graph/compositors.cxx b/libxsd-frontend/semantic-graph/compositors.cxx
new file mode 100644
index 0000000..28ab125
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/compositors.cxx
@@ -0,0 +1,99 @@
+// file : libxsd-frontend/semantic-graph/compositor.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/compositors.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ // ContainsCompositor
+ //
+ ContainsCompositor::
+ ContainsCompositor (unsigned long min, unsigned long max)
+ : compositor_ (0), container_ (0), min_ (min), max_ (max)
+ {
+ }
+
+ // All
+ //
+ All::
+ All (Path const& file, unsigned long line, unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Choice
+ //
+ Choice::
+ Choice (Path const& file, unsigned long line, unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Sequence
+ //
+ Sequence::
+ Sequence (Path const& file, unsigned long line, unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ namespace
+ {
+ using compiler::type_info;
+
+ struct ContainsCompositorInit
+ {
+ ContainsCompositorInit ()
+ {
+ type_info ti (typeid (ContainsCompositor));
+ ti.add_base (typeid (Edge));
+ insert (ti);
+ }
+ } contains_compositor_init_;
+
+ struct CompositorInit
+ {
+ CompositorInit ()
+ {
+ type_info ti (typeid (Compositor));
+ ti.add_base (typeid (Particle));
+ insert (ti);
+ }
+ } compositor_init_;
+
+ struct AllInit
+ {
+ AllInit ()
+ {
+ type_info ti (typeid (All));
+ ti.add_base (typeid (Compositor));
+ insert (ti);
+ }
+ } all_init_;
+
+ struct ChoiceInit
+ {
+ ChoiceInit ()
+ {
+ type_info ti (typeid (Choice));
+ ti.add_base (typeid (Compositor));
+ insert (ti);
+ }
+ } choice_init_;
+
+ struct SequenceInit
+ {
+ SequenceInit ()
+ {
+ type_info ti (typeid (Sequence));
+ ti.add_base (typeid (Compositor));
+ insert (ti);
+ }
+ } sequence_init_;
+ }
+ }
+}
diff --git a/libxsd-frontend/semantic-graph/compositors.hxx b/libxsd-frontend/semantic-graph/compositors.hxx
new file mode 100644
index 0000000..4864b70
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/compositors.hxx
@@ -0,0 +1,233 @@
+// file : libxsd-frontend/semantic-graph/compositors.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_COMPOSITORS_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_COMPOSITORS_HXX
+
+#include <list>
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+#include <libxsd-frontend/semantic-graph/particle.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ //
+ //
+ class ContainsCompositor: public virtual Edge
+ {
+ public:
+ Compositor&
+ compositor () const
+ {
+ return *compositor_;
+ }
+
+ Node&
+ container () const
+ {
+ return *container_;
+ }
+
+ public:
+ unsigned long
+ min () const
+ {
+ return min_;
+ }
+
+ unsigned long
+ max () const
+ {
+ return max_;
+ }
+
+ public:
+ ContainsCompositor (unsigned long min, unsigned long max);
+
+ void
+ set_left_node (Node& n)
+ {
+ container_ = &n;
+ }
+
+ void
+ set_right_node (Compositor& n)
+ {
+ compositor_ = &n;
+ }
+
+ void
+ clear_left_node (Node& n)
+ {
+ assert (container_ == &n);
+ container_ = 0;
+ }
+
+ void
+ clear_right_node (Compositor& n)
+ {
+ assert (compositor_ == &n);
+ compositor_ = 0;
+ }
+
+ private:
+ Compositor* compositor_;
+ Node* container_;
+ unsigned long min_, max_;
+ };
+
+ //
+ //
+ class Compositor: public virtual Particle
+ {
+ typedef std::list<ContainsParticle*> ContainsList;
+
+ public:
+ typedef pointer_iterator<ContainsList::iterator> ContainsIterator;
+ typedef
+ pointer_iterator<ContainsList::const_iterator>
+ ContainsConstIterator;
+
+ ContainsIterator
+ contains_begin ()
+ {
+ return contains_.begin ();
+ }
+
+ ContainsIterator
+ contains_end ()
+ {
+ return contains_.end ();
+ }
+
+ ContainsConstIterator
+ contains_begin () const
+ {
+ return contains_.begin ();
+ }
+
+ ContainsConstIterator
+ contains_end () const
+ {
+ return contains_.end ();
+ }
+
+ public:
+ bool
+ contained_compositor_p ()
+ {
+ return contained_compositor_ != 0;
+ }
+
+ ContainsCompositor&
+ contained_compositor ()
+ {
+ assert (contained_compositor_ != 0);
+ return *contained_compositor_;
+ }
+
+ public:
+ unsigned long
+ min () const
+ {
+ if (contained_compositor_ != 0)
+ return contained_compositor_->min ();
+ else
+ return Particle::min ();
+ }
+
+ unsigned long
+ max () const
+ {
+ if (contained_compositor_ != 0)
+ return contained_compositor_->max ();
+ else
+ return Particle::max ();
+ }
+
+ public:
+ Compositor (): contained_compositor_ (0) {}
+
+ void
+ add_edge_left (ContainsParticle& e)
+ {
+ contains_.push_back (&e);
+ }
+
+ void
+ add_edge_left (ContainsParticle& e, ContainsIterator const& after)
+ {
+ if (after.base () == contains_.end ())
+ contains_.push_front (&e);
+ else
+ {
+ ContainsList::iterator i (after.base ());
+ contains_.insert (++i, &e);
+ }
+ }
+
+ void
+ remove_edge_left (ContainsParticle& e)
+ {
+ for (ContainsList::iterator i (contains_.begin ());
+ i != contains_.end (); ++i)
+ {
+ if (*i == &e)
+ {
+ contains_.erase (i);
+ break;
+ }
+ }
+ }
+
+ void
+ add_edge_right (ContainsCompositor& e)
+ {
+ contained_compositor_ = &e;
+ }
+
+ void
+ remove_edge_right (ContainsCompositor& e)
+ {
+ assert (contained_compositor_ == &e);
+ contained_compositor_ = 0;
+ }
+
+ using Node::add_edge_right;
+ using Particle::add_edge_right;
+ using Particle::remove_edge_right;
+
+ private:
+ ContainsList contains_;
+ ContainsCompositor* contained_compositor_;
+ };
+
+ //
+ //
+ class All: public virtual Compositor
+ {
+ public:
+ All (Path const& file, unsigned long line, unsigned long column);
+ };
+
+ //
+ //
+ class Choice: public virtual Compositor
+ {
+ public:
+ Choice (Path const& file, unsigned long line, unsigned long column);
+ };
+
+ //
+ //
+ class Sequence: public virtual Compositor
+ {
+ public:
+ Sequence (Path const& file, unsigned long line, unsigned long column);
+ };
+ }
+}
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_COMPOSITORS_HXX
diff --git a/libxsd-frontend/semantic-graph/element-group.cxx b/libxsd-frontend/semantic-graph/element-group.cxx
new file mode 100644
index 0000000..7f71246
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/element-group.cxx
@@ -0,0 +1,33 @@
+// file : libxsd-frontend/semantic-graph/element-group.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/element-group.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ ElementGroup::
+ ElementGroup (Path const& file, unsigned long line, unsigned long column)
+ : Node (file, line, column), contains_compositor_ (0)
+ {
+ }
+
+ namespace
+ {
+ using compiler::type_info;
+
+ struct ElementGroupInit
+ {
+ ElementGroupInit ()
+ {
+ type_info ti (typeid (ElementGroup));
+ ti.add_base (typeid (Scope));
+ insert (ti);
+ }
+ } element_group_init_;
+ }
+ }
+}
diff --git a/libxsd-frontend/semantic-graph/element-group.hxx b/libxsd-frontend/semantic-graph/element-group.hxx
new file mode 100644
index 0000000..e8c9c65
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/element-group.hxx
@@ -0,0 +1,41 @@
+// file : libxsd-frontend/semantic-graph/element-group.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_ELEMENT_GROUP_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_ELEMENT_GROUP_HXX
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+#include <libxsd-frontend/semantic-graph/compositors.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ class ElementGroup: public virtual Scope
+ {
+ public:
+ ContainsCompositor&
+ contains_compositor ()
+ {
+ assert (contains_compositor_ != 0);
+ return *contains_compositor_;
+ }
+
+ public:
+ ElementGroup (Path const& file, unsigned long line, unsigned long column);
+
+ void
+ add_edge_left (ContainsCompositor& e)
+ {
+ contains_compositor_ = &e;
+ }
+
+ using Scope::add_edge_left;
+
+ private:
+ ContainsCompositor* contains_compositor_;
+ };
+ }
+}
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_ELEMENT_GROUP_HXX
diff --git a/libxsd-frontend/semantic-graph/element.cxx b/libxsd-frontend/semantic-graph/element.cxx
new file mode 100644
index 0000000..c51fac2
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/element.cxx
@@ -0,0 +1,52 @@
+// file : libxsd-frontend/semantic-graph/element.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/element.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ // Element
+ //
+ Element::
+ Element (Path const& file,
+ unsigned long line,
+ unsigned long column,
+ bool global,
+ bool qualified)
+ : Node (file, line, column),
+ Member (global, qualified),
+ substitutes_ (0)
+ {
+ }
+
+ namespace
+ {
+ using compiler::type_info;
+
+ struct SubstitutesInit
+ {
+ SubstitutesInit ()
+ {
+ type_info ti (typeid (Substitutes));
+ ti.add_base (typeid (Edge));
+ insert (ti);
+ }
+ } substitutes_init_;
+
+ struct ElementInit
+ {
+ ElementInit ()
+ {
+ type_info ti (typeid (Element));
+ ti.add_base (typeid (Member));
+ ti.add_base (typeid (Particle));
+ insert (ti);
+ }
+ } element_init_;
+ }
+ }
+}
diff --git a/libxsd-frontend/semantic-graph/element.hxx b/libxsd-frontend/semantic-graph/element.hxx
new file mode 100644
index 0000000..ff5a863
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/element.hxx
@@ -0,0 +1,93 @@
+// file : libxsd-frontend/semantic-graph/element.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_ELEMENT_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_ELEMENT_HXX
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+#include <libxsd-frontend/semantic-graph/particle.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ class Element;
+
+ class Substitutes: public virtual Edge
+ {
+ public:
+ Element&
+ substitution () const
+ {
+ return *substitution_;
+ }
+
+ Element&
+ root () const
+ {
+ return *root_;
+ }
+
+ public:
+ void
+ set_left_node (Element& n)
+ {
+ substitution_ = &n;
+ }
+
+ void
+ set_right_node (Element& n)
+ {
+ root_ = &n;
+ }
+
+ private:
+ Element* root_;
+ Element* substitution_;
+ };
+
+
+ class Element: public virtual Member,
+ public virtual Particle
+ {
+ public:
+ bool
+ substitutes_p () const
+ {
+ return substitutes_ != 0;
+ }
+
+ Substitutes&
+ substitutes () const
+ {
+ assert (substitutes_ != 0);
+ return *substitutes_;
+ }
+
+ public:
+ Element (Path const& file,
+ unsigned long line,
+ unsigned long column,
+ bool global,
+ bool qualified);
+
+ void
+ add_edge_left (Substitutes& e)
+ {
+ substitutes_ = &e;
+ }
+
+ void
+ add_edge_right (Substitutes&) {}
+
+ using Member::add_edge_left;
+ using Member::add_edge_right;
+ using Particle::add_edge_right;
+
+ private:
+ Substitutes* substitutes_;
+ };
+ }
+}
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_ELEMENT_HXX
diff --git a/libxsd-frontend/semantic-graph/elements.cxx b/libxsd-frontend/semantic-graph/elements.cxx
new file mode 100644
index 0000000..c77a41d
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/elements.cxx
@@ -0,0 +1,299 @@
+// file : libxsd-frontend/semantic-graph/elements.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <algorithm>
+#include <iostream>
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+#include <libxsd-frontend/semantic-graph/annotation.hxx>
+
+using namespace std;
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ // Node
+ //
+ Annotation& Node::
+ annotation ()
+ {
+ return annotates_->annotation ();
+ }
+
+ // Type
+ //
+ void Type::
+ remove_edge_left (Arguments& a)
+ {
+ ArgumentsSet::iterator i (arguments_.find (&a));
+ assert (i != arguments_.end ());
+ arguments_.erase (i);
+ }
+
+ // Specialization
+ //
+ void Specialization::
+ remove_edge_right (Arguments& a)
+ {
+ // The number of entries should be small so linear search will do.
+ //
+ Argumented::iterator i (
+ std::find (argumented_.begin (), argumented_.end (), &a));
+
+ assert (i != argumented_.end ());
+ argumented_.erase (i);
+ }
+
+ using compiler::type_info;
+
+ namespace
+ {
+ // Edge
+ //
+ struct EdgeInit
+ {
+ EdgeInit ()
+ {
+ type_info ti (typeid (Edge));
+ insert (ti);
+ }
+ } edge_init_;
+
+ // Node
+ //
+ struct NodeInit
+ {
+ NodeInit ()
+ {
+ type_info ti (typeid (Node));
+ insert (ti);
+ }
+ } node_init_;
+
+ // Names
+ //
+ struct NamesInit
+ {
+ NamesInit ()
+ {
+ type_info ti (typeid (Names));
+ ti.add_base (typeid (Edge));
+ insert (ti);
+ }
+ } names_init_;
+
+ // Nameable
+ //
+ struct NameableInit
+ {
+ NameableInit ()
+ {
+ type_info ti (typeid (Nameable));
+ ti.add_base (typeid (Node));
+ insert (ti);
+ }
+ } nameable_init_;
+
+ // Scope
+ //
+ struct ScopeInit
+ {
+ ScopeInit ()
+ {
+ type_info ti (typeid (Scope));
+ ti.add_base (typeid (Nameable));
+ insert (ti);
+ }
+ } scope_init_;
+
+ // Type
+ //
+ struct TypeInit
+ {
+ TypeInit ()
+ {
+ type_info ti (typeid (Type));
+ ti.add_base (typeid (Nameable));
+ insert (ti);
+ }
+ } type_init_;
+
+ // Instance
+ //
+ struct InstanceInit
+ {
+ InstanceInit ()
+ {
+ type_info ti (typeid (Instance));
+ ti.add_base (typeid (Nameable));
+ insert (ti);
+ }
+ } instance_init_;
+
+ // Belongs
+ //
+ struct BelongsInit
+ {
+ BelongsInit ()
+ {
+ type_info ti (typeid (Belongs));
+ ti.add_base (typeid (Edge));
+ insert (ti);
+ }
+ } belongs_init_;
+
+ // Inherits
+ //
+ struct InheritsInit
+ {
+ InheritsInit ()
+ {
+ type_info ti (typeid (Inherits));
+ ti.add_base (typeid (Edge));
+ insert (ti);
+ }
+ } inherits_init_;
+
+ // Extends
+ //
+ struct ExtendsInit
+ {
+ ExtendsInit ()
+ {
+ type_info ti (typeid (Extends));
+ ti.add_base (typeid (Inherits));
+ insert (ti);
+ }
+ } extends_init_;
+
+ // Restricts
+ //
+ struct RestrictsInit
+ {
+ RestrictsInit ()
+ {
+ type_info ti (typeid (Restricts));
+ ti.add_base (typeid (Inherits));
+ insert (ti);
+ }
+ } restricts_init_;
+
+ // BelongsToNamespace
+ //
+ struct BelongsToNamespaceInit
+ {
+ BelongsToNamespaceInit ()
+ {
+ type_info ti (typeid (BelongsToNamespace));
+ ti.add_base (typeid (Edge));
+ insert (ti);
+ }
+ } belongs_to_namespace_init_;
+
+ // Member
+ //
+ struct MemberInit
+ {
+ MemberInit ()
+ {
+ type_info ti (typeid (Member));
+ ti.add_base (typeid (Instance));
+ insert (ti);
+ }
+ } member_init_;
+
+ // Specialization
+ //
+ struct SpecializationInit
+ {
+ SpecializationInit ()
+ {
+ type_info ti (typeid (Specialization));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+ } specialization_init_;
+
+ // Arguments
+ //
+ struct ArgumentsInit
+ {
+ ArgumentsInit ()
+ {
+ type_info ti (typeid (Arguments));
+ ti.add_base (typeid (Edge));
+ insert (ti);
+ }
+ } arguments_init_;
+
+ /*
+ // Contains
+ //
+ struct ContainsInit
+ {
+ ContainsInit ()
+ {
+ type_info ti (typeid (Contains));
+ ti.add_base (typeid (Edge));
+ insert (ti);
+ }
+ } contains_init_;
+
+ // Container
+ //
+ struct ContainerInit
+ {
+ ContainerInit ()
+ {
+ type_info ti (typeid (Container));
+ ti.add_base (typeid (Node));
+ insert (ti);
+ }
+ } container_init_;
+ */
+
+ // AnyType
+ //
+ struct AnyTypeInit
+ {
+ AnyTypeInit ()
+ {
+ type_info ti (typeid (AnyType));
+ ti.add_base (typeid (SemanticGraph::Type));
+ insert (ti);
+ }
+ } any_type_init_;
+
+ // AnySimpleType
+ //
+ struct AnySimpleTypeInit
+ {
+ AnySimpleTypeInit ()
+ {
+ type_info ti (typeid (AnySimpleType));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+ } any_simple_type_init_;
+ }
+
+ // Instance
+ //
+ Type& Instance::
+ type () const
+ {
+ return belongs ().type ();
+ }
+ }
+}
+
+// Path
+//
+std::wostream&
+operator<< (std::wostream& os, XSDFrontend::SemanticGraph::Path const& path)
+{
+ return os << path.string ().c_str ();
+}
diff --git a/libxsd-frontend/semantic-graph/elements.hxx b/libxsd-frontend/semantic-graph/elements.hxx
new file mode 100644
index 0000000..a7ff2fa
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/elements.hxx
@@ -0,0 +1,1003 @@
+// file : libxsd-frontend/semantic-graph/elements.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_ELEMENTS_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_ELEMENTS_HXX
+
+#include <set>
+#include <map>
+#include <list>
+#include <vector>
+#include <iosfwd>
+#include <cstddef> // std::size_t
+#include <utility> // std::pair
+#include <cstdlib> // abort
+#include <cassert>
+
+#include <libcutl/container/graph.hxx>
+#include <libcutl/container/pointer-iterator.hxx>
+#include <libcutl/compiler/context.hxx>
+#include <libcutl/fs/path.hxx>
+
+#include <libxsd-frontend/types.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ using namespace cutl;
+
+ using container::pointer_iterator;
+
+ //
+ //
+ typedef fs::path Path;
+ typedef fs::invalid_path InvalidPath;
+ typedef std::vector<Path> Paths;
+
+ typedef compiler::context Context;
+
+ //
+ //
+ class Node;
+ class Edge;
+
+ //
+ //
+ class Annotates;
+ class Annotation;
+
+ //
+ //
+ class Edge
+ {
+ public:
+ Context&
+ context () const
+ {
+ return context_;
+ }
+
+ virtual
+ ~Edge ()
+ {
+ }
+
+ public:
+ template <typename X>
+ bool
+ is_a () const
+ {
+ return dynamic_cast<X const*> (this) != 0;
+ }
+
+ private:
+ mutable Context context_;
+ };
+
+ inline bool
+ operator== (Edge const& x, Edge const& y)
+ {
+ return &x == &y;
+ }
+
+
+ //
+ //
+ class Node
+ {
+ public:
+ Context&
+ context () const
+ {
+ return context_;
+ }
+
+ public:
+ Path const&
+ file () const
+ {
+ return file_;
+ }
+
+ unsigned long
+ line () const
+ {
+ return line_;
+ }
+
+ unsigned long
+ column () const
+ {
+ return column_;
+ }
+
+ public:
+ bool
+ annotated_p () const
+ {
+ return annotates_ != 0;
+ }
+
+ Annotates&
+ annotated () const
+ {
+ return *annotates_;
+ }
+
+ Annotation&
+ annotation ();
+
+ public:
+ template <typename X>
+ bool
+ is_a () const
+ {
+ return dynamic_cast<X const*> (this) != 0;
+ }
+
+ public:
+ virtual
+ ~Node () {}
+
+ Node (Path const& file, unsigned long line, unsigned long column)
+ : annotates_ (0), file_ (file), line_ (line), column_ (column)
+ {
+ }
+
+ void
+ add_edge_right (Annotates& a)
+ {
+ annotates_ = &a;
+ }
+
+ protected:
+ Node () // For virtual inheritance.
+ {
+ abort (); // Told you so!
+ }
+
+ private:
+ mutable Context context_;
+ Annotates* annotates_;
+ Path file_;
+ unsigned long line_;
+ unsigned long column_;
+ };
+
+ inline bool
+ operator== (Node const& x, Node const& y)
+ {
+ return &x == &y;
+ }
+
+ //
+ //
+ typedef container::graph<Node, Edge> graph;
+
+ //
+ //
+ typedef String Name;
+
+
+ //
+ //
+ class Scope;
+ class Nameable;
+
+
+ //
+ //
+ class Names: public virtual Edge
+ {
+ public:
+ Name
+ name () const
+ {
+ return name_;
+ }
+
+ Scope&
+ scope () const
+ {
+ return *scope_;
+ }
+
+ Nameable&
+ named () const
+ {
+ return *named_;
+ }
+
+ public:
+ Names (Name const& name): name_ (name) {}
+
+ void
+ set_left_node (Scope& n)
+ {
+ scope_ = &n;
+ }
+
+ void
+ set_right_node (Nameable& n)
+ {
+ named_ = &n;
+ }
+
+ void
+ clear_left_node (Scope& n)
+ {
+ assert (scope_ == &n);
+ scope_ = 0;
+ }
+
+ void
+ clear_right_node (Nameable& n)
+ {
+ assert (named_ == &n);
+ named_ = 0;
+ }
+
+ private:
+ Scope* scope_;
+ Nameable* named_;
+ Name name_;
+ };
+
+
+ class Nameable: public virtual Node
+ {
+ public:
+ bool
+ named_p () const
+ {
+ return named_ != 0;
+ }
+
+ Name
+ name () const
+ {
+ assert (named_p ());
+ return named_->name ();
+ }
+
+ Scope&
+ scope ()
+ {
+ assert (named_p ());
+ return named_->scope ();
+ }
+
+ Names&
+ named ()
+ {
+ assert (named_p ());
+ return *named_;
+ }
+
+ public:
+ Nameable (): named_ (0) {}
+
+ void
+ add_edge_right (Names& e)
+ {
+ named_ = &e;
+ }
+
+ void
+ remove_edge_right (Names& e)
+ {
+ assert (named_ == &e);
+ named_ = 0;
+ }
+
+ using Node::add_edge_right;
+
+ private:
+ Names* named_;
+ };
+
+ //
+ //
+ typedef std::set<Nameable*> Nameables;
+
+ //
+ //
+ class Scope: public virtual Nameable
+ {
+ protected:
+ typedef std::list<Names*> NamesList;
+ typedef std::map<Names*, NamesList::iterator> ListIteratorMap;
+ typedef std::map<Name, NamesList> NamesMap;
+
+ public:
+ typedef pointer_iterator<NamesList::iterator> NamesIterator;
+ typedef pointer_iterator<NamesList::const_iterator> NamesConstIterator;
+
+ typedef
+ std::pair<NamesConstIterator, NamesConstIterator>
+ NamesIteratorPair;
+
+ NamesIterator
+ names_begin ()
+ {
+ return names_.begin ();
+ }
+
+ NamesIterator
+ names_end ()
+ {
+ return names_.end ();
+ }
+
+ NamesConstIterator
+ names_begin () const
+ {
+ return names_.begin ();
+ }
+
+ NamesConstIterator
+ names_end () const
+ {
+ return names_.end ();
+ }
+
+ std::size_t
+ names_size () const
+ {
+ return names_.size ();
+ }
+
+ virtual NamesIteratorPair
+ find (Name const& name) const
+ {
+ NamesMap::const_iterator i (names_map_.find (name));
+
+ if (i == names_map_.end ())
+ return NamesIteratorPair (names_.end (), names_.end ());
+ else
+ return NamesIteratorPair (i->second.begin (), i->second.end ());
+ }
+
+ NamesIterator
+ find (Names& e)
+ {
+ ListIteratorMap::iterator i (iterator_map_.find (&e));
+ return i != iterator_map_.end () ? i->second : names_.end ();
+ }
+
+ public:
+ Scope (Path const& file, unsigned long line, unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ void
+ add_edge_left (Names& e)
+ {
+ NamesList::iterator i (names_.insert (names_.end (), &e));
+ iterator_map_[&e] = i;
+ names_map_[e.name ()].push_back (&e);
+ }
+
+ void
+ remove_edge_left (Names& e)
+ {
+ ListIteratorMap::iterator i (iterator_map_.find (&e));
+ assert (i != iterator_map_.end ());
+
+ names_.erase (i->second);
+ iterator_map_.erase (i);
+
+ NamesMap::iterator j (names_map_.find (e.name ()));
+
+ for (NamesList::iterator i (j->second.begin ());
+ i != j->second.end (); ++i)
+ {
+ if (*i == &e)
+ i = j->second.erase (i);
+ }
+ }
+
+ void
+ add_edge_left (Names& e, NamesIterator const& after)
+ {
+ NamesList::iterator i;
+
+ if (after.base () == names_.end ())
+ i = names_.insert (names_.begin (), &e);
+ else
+ {
+ NamesList::iterator j (after.base ());
+ i = names_.insert (++j, &e);
+ }
+
+ iterator_map_[&e] = i;
+ names_map_[e.name ()].push_back (&e);
+ }
+
+ using Nameable::add_edge_right;
+
+ protected:
+ Scope () {}
+
+ private:
+ NamesList names_;
+ ListIteratorMap iterator_map_;
+ NamesMap names_map_;
+ };
+
+
+ //
+ //
+ class Belongs;
+ class Inherits;
+ class Arguments;
+
+ class Type: public virtual Nameable
+ {
+ protected:
+ typedef std::vector<Belongs*> Classifies;
+ typedef std::vector<Inherits*> Begets;
+ typedef std::set<Arguments*> ArgumentsSet;
+
+ public:
+ typedef pointer_iterator<Classifies::const_iterator> ClassifiesIterator;
+
+ ClassifiesIterator
+ classifies_begin () const
+ {
+ return classifies_.begin ();
+ }
+
+ ClassifiesIterator
+ classifies_end () const
+ {
+ return classifies_.end ();
+ }
+
+ //
+ //
+ bool
+ inherits_p () const
+ {
+ return inherits_ != 0;
+ }
+
+ Inherits&
+ inherits () const
+ {
+ assert (inherits_ != 0);
+ return *inherits_;
+ }
+
+ //
+ //
+ typedef pointer_iterator<Begets::const_iterator> BegetsIterator;
+
+ BegetsIterator
+ begets_begin () const
+ {
+ return begets_.begin ();
+ }
+
+ BegetsIterator
+ begets_end () const
+ {
+ return begets_.end ();
+ }
+
+ //
+ //
+ typedef pointer_iterator<ArgumentsSet::const_iterator> ArgumentsIterator;
+
+ ArgumentsIterator
+ arguments_begin () const
+ {
+ return arguments_.begin ();
+ }
+
+ ArgumentsIterator
+ arguments_end () const
+ {
+ return arguments_.end ();
+ }
+
+ public:
+ Type (): inherits_ (0) {}
+
+ void
+ add_edge_right (Belongs& e)
+ {
+ classifies_.push_back (&e);
+ }
+
+ void
+ add_edge_right (Inherits& e)
+ {
+ begets_.push_back (&e);
+ }
+
+ using Nameable::add_edge_right;
+
+ void
+ add_edge_left (Arguments& a)
+ {
+ arguments_.insert (&a);
+ }
+
+ void
+ remove_edge_left (Arguments&);
+
+ void
+ add_edge_left (Inherits& e)
+ {
+ inherits_ = &e;
+ }
+
+ private:
+ Inherits* inherits_;
+ Begets begets_;
+ Classifies classifies_;
+ ArgumentsSet arguments_;
+ };
+
+ class Instance: public virtual Nameable
+ {
+ public:
+ Belongs&
+ belongs () const
+ {
+ return *belongs_;
+ }
+
+ Type&
+ type () const;
+
+ bool
+ typed_p () const
+ {
+ return belongs_ != 0;
+ }
+
+ public:
+ Instance (): belongs_ (0) {}
+
+ void
+ add_edge_left (Belongs& e)
+ {
+ belongs_ = &e;
+ }
+
+ private:
+ Belongs* belongs_;
+ };
+
+
+ class Belongs: public virtual Edge
+ {
+ public:
+ Instance&
+ instance () const
+ {
+ return *instance_;
+ }
+
+ Type&
+ type () const
+ {
+ return *type_;
+ }
+
+ public:
+ void
+ set_left_node (Instance& n)
+ {
+ instance_ = &n;
+ }
+
+ void
+ set_right_node (Type& n)
+ {
+ type_ = &n;
+ }
+
+ private:
+ Instance* instance_;
+ Type* type_;
+ };
+
+
+ //
+ //
+ class Inherits: public virtual Edge
+ {
+ public:
+ Type&
+ base () const
+ {
+ return *base_;
+ }
+
+ Type&
+ derived () const
+ {
+ return *derived_;
+ }
+
+ public:
+ void
+ set_left_node (Type& n)
+ {
+ derived_ = &n;
+ }
+
+ void
+ set_right_node (Type& n)
+ {
+ base_ = &n;
+ }
+
+ private:
+ Type* base_;
+ Type* derived_;
+ };
+
+ class Extends: public virtual Inherits
+ {
+ };
+
+ class Restricts: public virtual Inherits
+ {
+ public:
+ typedef std::map<String, String> Facets;
+ typedef Facets::iterator FacetIterator;
+
+ bool
+ facet_empty ()
+ {
+ return facets_.empty ();
+ }
+
+ FacetIterator
+ facet_begin ()
+ {
+ return facets_.begin ();
+ }
+
+ FacetIterator
+ facet_end ()
+ {
+ return facets_.end ();
+ }
+
+ FacetIterator
+ facet_find (String const& name)
+ {
+ return facets_.find (name);
+ }
+
+ void
+ facet_insert (String const& name, String const& value)
+ {
+ facets_[name] = value;
+ }
+
+ Facets const&
+ facets () const
+ {
+ return facets_;
+ }
+
+ protected:
+ Facets facets_;
+ };
+
+
+ //
+ //
+ class Member;
+ class Namespace;
+
+ class BelongsToNamespace: public virtual Edge
+ {
+ public:
+ Member&
+ member () const
+ {
+ assert (member_ != 0);
+ return *member_;
+ }
+
+ Namespace&
+ namespace_ () const
+ {
+ assert (namespace__ != 0);
+ return *namespace__;
+ }
+
+ public:
+ BelongsToNamespace (): member_ (0), namespace__ (0) {}
+
+ void
+ set_left_node (Member& n)
+ {
+ member_ = &n;
+ }
+
+ void
+ set_right_node (Namespace& n)
+ {
+ namespace__ = &n;
+ }
+
+ private:
+ Member* member_;
+ Namespace* namespace__;
+ };
+
+ //
+ //
+ class Member: public virtual Instance
+ {
+ public:
+ // Member is global either if it is defined outside any type
+ // or it is a ref="" of a global member.
+ //
+ bool
+ global_p () const
+ {
+ return global_;
+ }
+
+ bool
+ qualified_p () const
+ {
+ return qualified_;
+ }
+
+ // Note that only qualified members belong to a namespace.
+ //
+ Namespace&
+ namespace_ () const
+ {
+ assert (belongs_to_namespace_ != 0);
+ return belongs_to_namespace_->namespace_ ();
+ }
+
+
+ // Default and fixed value API. Note that the fixed value semantics
+ // is a superset of the default value semantics. As such setting the
+ // fixed value appears as if the default value was also set.
+ //
+ bool
+ default_p () const
+ {
+ return value_type_ != ValueType::none;
+ }
+
+ bool
+ fixed_p () const
+ {
+ return value_type_ == ValueType::fixed;
+ }
+
+ struct NoValue {};
+
+ String
+ value () const
+ {
+ if (value_type_ != ValueType::none)
+ return value_;
+ else
+ throw NoValue ();
+ }
+
+ //
+ //
+ void
+ default_ (String const& v)
+ {
+ value_ = v;
+ value_type_ = ValueType::default_;
+ }
+
+ void
+ fixed (String const& v)
+ {
+ value_ = v;
+ value_type_ = ValueType::fixed;
+ }
+
+ public:
+ Member (bool global, bool qualified)
+ : global_ (global),
+ qualified_ (qualified),
+ belongs_to_namespace_ (0),
+ value_type_ (ValueType::none)
+ {
+ }
+
+ void
+ add_edge_left (BelongsToNamespace& e)
+ {
+ // In the parser we sometimes re-add the same adge.
+ //
+ belongs_to_namespace_ = &e;
+ }
+
+ using Instance::add_edge_left;
+
+ private:
+ bool global_;
+ bool qualified_;
+ BelongsToNamespace* belongs_to_namespace_;
+
+ struct ValueType
+ {
+ enum Value
+ {
+ none,
+ default_,
+ fixed
+ };
+ };
+
+ String value_;
+ ValueType::Value value_type_;
+ };
+
+
+ // Parametric types.
+ //
+
+ class Specialization: public virtual Type
+ {
+ typedef std::vector<Arguments*> Argumented;
+
+ public:
+ typedef pointer_iterator<Argumented::iterator> ArgumentedIterator;
+ typedef
+ pointer_iterator<Argumented::const_iterator>
+ ArgumentedConstIterator;
+
+ ArgumentedIterator
+ argumented_begin ()
+ {
+ return argumented_.begin ();
+ }
+
+ ArgumentedConstIterator
+ argumented_begin () const
+ {
+ return argumented_.begin ();
+ }
+
+ ArgumentedIterator
+ argumented_end ()
+ {
+ return argumented_.end ();
+ }
+
+ ArgumentedConstIterator
+ argumented_end () const
+ {
+ return argumented_.end ();
+ }
+
+ // Shortcut for one-argument specializations.
+ //
+ Arguments&
+ argumented () const
+ {
+ return *argumented_[0];
+ }
+
+ public:
+ using Type::add_edge_right;
+
+ void
+ add_edge_right (Arguments& a)
+ {
+ argumented_.push_back (&a);
+ }
+
+ void
+ add_edge_right (Arguments& a, ArgumentedIterator const& pos)
+ {
+ argumented_.insert (pos.base (), &a);
+ }
+
+ void
+ remove_edge_right (Arguments&);
+
+ private:
+ Argumented argumented_;
+ };
+
+ class Arguments: public virtual Edge
+ {
+ public:
+ Type&
+ type () const
+ {
+ return *type_;
+ }
+
+ Specialization&
+ specialization () const
+ {
+ return *specialization_;
+ }
+
+ public:
+ void
+ set_left_node (Type& n)
+ {
+ type_ = &n;
+ }
+
+ void
+ clear_left_node (Type& n)
+ {
+ assert (type_ == &n);
+ type_ = 0;
+ }
+
+ void
+ set_right_node (Specialization& s)
+ {
+ specialization_ = &s;
+ }
+
+ void
+ clear_right_node (Specialization& s)
+ {
+ assert (specialization_ == &s);
+ specialization_ = 0;
+ }
+
+ private:
+ Type* type_;
+ Specialization* specialization_;
+ };
+
+
+ //
+ //
+ class AnyType: public virtual Type
+ {
+ public:
+ AnyType (Path const& file, unsigned long line, unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ protected:
+ AnyType () {} // For virtual inheritance.
+ };
+
+
+ //
+ //
+ class AnySimpleType: public virtual Type
+ {
+ public:
+ AnySimpleType (Path const& file, unsigned long line, unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ protected:
+ AnySimpleType () {} // For virtual inheritance.
+ };
+ }
+}
+
+// ADL won't find it because Path is a typedef. Note that this
+// function prints in native format.
+//
+std::wostream&
+operator<< (std::wostream& os, XSDFrontend::SemanticGraph::Path const& path);
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_ELEMENTS_HXX
diff --git a/libxsd-frontend/semantic-graph/enumeration.cxx b/libxsd-frontend/semantic-graph/enumeration.cxx
new file mode 100644
index 0000000..6fdb03b
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/enumeration.cxx
@@ -0,0 +1,58 @@
+// file : libxsd-frontend/semantic-graph/enumeration.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/enumeration.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ // Enumeration
+ //
+ Enumeration::
+ Enumeration (Path const& file, unsigned long line, unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Enumerator
+ //
+ Enumerator::
+ Enumerator (Path const& file, unsigned long line, unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ namespace
+ {
+ using compiler::type_info;
+
+ // Enumeration
+ //
+ struct EnumerationInit
+ {
+ EnumerationInit ()
+ {
+ type_info ti (typeid (Enumeration));
+ ti.add_base (typeid (Complex));
+ insert (ti);
+ }
+ } enumeration_init_;
+
+
+ // Enumerator
+ //
+ struct EnumeratorInit
+ {
+ EnumeratorInit ()
+ {
+ type_info ti (typeid (Enumerator));
+ ti.add_base (typeid (Instance));
+ insert (ti);
+ }
+ } enumerator_init_;
+ }
+ }
+}
diff --git a/libxsd-frontend/semantic-graph/enumeration.hxx b/libxsd-frontend/semantic-graph/enumeration.hxx
new file mode 100644
index 0000000..88fb5d8
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/enumeration.hxx
@@ -0,0 +1,29 @@
+// file : libxsd-frontend/semantic-graph/enumeration.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_ENUMERATION_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_ENUMERATION_HXX
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+#include <libxsd-frontend/semantic-graph/complex.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ class Enumeration: public virtual Complex
+ {
+ public:
+ Enumeration (Path const& file, unsigned long line, unsigned long column);
+ };
+
+
+ class Enumerator: public virtual Instance
+ {
+ public:
+ Enumerator (Path const& file, unsigned long line, unsigned long column);
+ };
+ }
+}
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_ENUMERATION_HXX
diff --git a/libxsd-frontend/semantic-graph/fundamental.cxx b/libxsd-frontend/semantic-graph/fundamental.cxx
new file mode 100644
index 0000000..0664272
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/fundamental.cxx
@@ -0,0 +1,1096 @@
+// file : libxsd-frontend/semantic-graph/fundamental.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/fundamental.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ namespace Fundamental
+ {
+ using compiler::type_info;
+
+ // Type
+ //
+ namespace
+ {
+ struct TypeInit
+ {
+ TypeInit ()
+ {
+ type_info ti (typeid (Type));
+ ti.add_base (typeid (SemanticGraph::Type));
+ insert (ti);
+ }
+ } any_type_init_;
+ }
+
+ Type::
+ Type ()
+ {
+ }
+
+ // Byte
+ //
+ namespace
+ {
+ struct ByteInit
+ {
+ ByteInit ()
+ {
+ type_info ti (typeid (Byte));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } byte_init_;
+ }
+
+ Byte::
+ Byte (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // UnsignedByte
+ //
+ namespace
+ {
+ struct UnsignedByteInit
+ {
+ UnsignedByteInit ()
+ {
+ type_info ti (typeid (UnsignedByte));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } unsigned_byte_init_;
+ }
+
+ UnsignedByte::
+ UnsignedByte (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Short
+ //
+ namespace
+ {
+ struct ShortInit
+ {
+ ShortInit ()
+ {
+ type_info ti (typeid (Short));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } short_init_;
+ }
+
+ Short::
+ Short (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // UnsignedShort
+ //
+ namespace
+ {
+ struct UnsignedShortInit
+ {
+ UnsignedShortInit ()
+ {
+ type_info ti (typeid (UnsignedShort));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } unsigned_short_init_;
+ }
+
+ UnsignedShort::
+ UnsignedShort (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Int
+ //
+ namespace
+ {
+ struct IntInit
+ {
+ IntInit ()
+ {
+ type_info ti (typeid (Int));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } int_init_;
+ }
+
+ Int::
+ Int (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // UnsignedInt
+ //
+ namespace
+ {
+ struct UnsignedIntInit
+ {
+ UnsignedIntInit ()
+ {
+ type_info ti (typeid (UnsignedInt));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } unsigned_int_init_;
+ }
+
+ UnsignedInt::
+ UnsignedInt (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Long
+ //
+ namespace
+ {
+ struct LongInit
+ {
+ LongInit ()
+ {
+ type_info ti (typeid (Long));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } long_init_;
+ }
+
+ Long::
+ Long (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // UnsignedLong
+ //
+ namespace
+ {
+ struct UnsignedLongInit
+ {
+ UnsignedLongInit ()
+ {
+ type_info ti (typeid (UnsignedLong));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } unsigned_long_init_;
+ }
+
+ UnsignedLong::
+ UnsignedLong (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Integer
+ //
+ namespace
+ {
+ struct IntegerInit
+ {
+ IntegerInit ()
+ {
+ type_info ti (typeid (Integer));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } integer_init_;
+ }
+
+ Integer::
+ Integer (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // NonPositiveInteger
+ //
+ namespace
+ {
+ struct NonPositiveIntegerInit
+ {
+ NonPositiveIntegerInit ()
+ {
+ type_info ti (typeid (NonPositiveInteger));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } non_positive_integer_init_;
+ }
+
+ NonPositiveInteger::
+ NonPositiveInteger (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // NonNegativeInteger
+ //
+ namespace
+ {
+ struct NonNegativeIntegerInit
+ {
+ NonNegativeIntegerInit ()
+ {
+ type_info ti (typeid (NonNegativeInteger));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } non_negative_integer_init_;
+ }
+
+ NonNegativeInteger::
+ NonNegativeInteger (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // PositiveInteger
+ //
+ namespace
+ {
+ struct PositiveIntegerInit
+ {
+ PositiveIntegerInit ()
+ {
+ type_info ti (typeid (PositiveInteger));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } positive_integer_init_;
+ }
+
+ PositiveInteger::
+ PositiveInteger (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // NegativeInteger
+ //
+ namespace
+ {
+ struct NegativeIntegerInit
+ {
+ NegativeIntegerInit ()
+ {
+ type_info ti (typeid (NegativeInteger));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } negative_integer_init_;
+ }
+
+ NegativeInteger::
+ NegativeInteger (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Boolean
+ //
+ namespace
+ {
+ struct BooleanInit
+ {
+ BooleanInit ()
+ {
+ type_info ti (typeid (Boolean));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } boolean_init_;
+ }
+
+ Boolean::
+ Boolean (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Float
+ //
+ namespace
+ {
+ struct FloatInit
+ {
+ FloatInit ()
+ {
+ type_info ti (typeid (Float));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } float_init_;
+ }
+
+ Float::
+ Float (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Double
+ //
+ namespace
+ {
+ struct DoubleInit
+ {
+ DoubleInit ()
+ {
+ type_info ti (typeid (Double));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } double_init_;
+ }
+
+ Double::
+ Double (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Decimal
+ //
+ namespace
+ {
+ struct DecimalInit
+ {
+ DecimalInit ()
+ {
+ type_info ti (typeid (Decimal));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } decimal_init_;
+ }
+
+ Decimal::
+ Decimal (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // String
+ //
+ namespace
+ {
+ struct StringInit
+ {
+ StringInit ()
+ {
+ type_info ti (typeid (String));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } string_init_;
+ }
+
+ String::
+ String (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // NormalizedString
+ //
+ namespace
+ {
+ struct NormalizedStringInit
+ {
+ NormalizedStringInit ()
+ {
+ type_info ti (typeid (NormalizedString));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } normalized_string_init_;
+ }
+
+ NormalizedString::
+ NormalizedString (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Token
+ //
+ namespace
+ {
+ struct TokenInit
+ {
+ TokenInit ()
+ {
+ type_info ti (typeid (Token));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } token_init_;
+ }
+
+ Token::
+ Token (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Name
+ //
+ namespace
+ {
+ struct NameInit
+ {
+ NameInit ()
+ {
+ type_info ti (typeid (Name));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } name_init_;
+ }
+
+ Name::
+ Name (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+
+ // NameToken
+ //
+ namespace
+ {
+ struct NameTokenInit
+ {
+ NameTokenInit ()
+ {
+ type_info ti (typeid (NameToken));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } name_token_init_;
+ }
+
+ NameToken::
+ NameToken (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // NameTokens
+ //
+ namespace
+ {
+ struct NameTokensInit
+ {
+ NameTokensInit ()
+ {
+ type_info ti (typeid (NameTokens));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } name_tokens_init_;
+ }
+
+ NameTokens::
+ NameTokens (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // NCName
+ //
+ namespace
+ {
+ struct NCNameInit
+ {
+ NCNameInit ()
+ {
+ type_info ti (typeid (NCName));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } NC_name_init_;
+ }
+
+ NCName::
+ NCName (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Language
+ //
+ namespace
+ {
+ struct LanguageInit
+ {
+ LanguageInit ()
+ {
+ type_info ti (typeid (Language));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } language_init_;
+ }
+
+ Language::
+ Language (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // QName
+ //
+ namespace
+ {
+ struct QNameInit
+ {
+ QNameInit ()
+ {
+ type_info ti (typeid (QName));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } q_name_init_;
+ }
+
+ QName::
+ QName (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Id
+ //
+ namespace
+ {
+ struct IdInit
+ {
+ IdInit ()
+ {
+ type_info ti (typeid (Id));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } id_init_;
+ }
+
+ Id::
+ Id (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // IdRef
+ //
+ namespace
+ {
+ struct IdRefInit
+ {
+ IdRefInit ()
+ {
+ type_info ti (typeid (IdRef));
+ ti.add_base (typeid (Type));
+ ti.add_base (typeid (Specialization));
+ insert (ti);
+ }
+
+ } id_ref_init_;
+ }
+
+ IdRef::
+ IdRef (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // IdRefs
+ //
+ namespace
+ {
+ struct IdRefsInit
+ {
+ IdRefsInit ()
+ {
+ type_info ti (typeid (IdRefs));
+ ti.add_base (typeid (Type));
+ ti.add_base (typeid (Specialization));
+ insert (ti);
+ }
+
+ } id_refs_init_;
+ }
+
+ IdRefs::
+ IdRefs (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // AnyURI
+ //
+ namespace
+ {
+ struct AnyURIInit
+ {
+ AnyURIInit ()
+ {
+ type_info ti (typeid (AnyURI));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } any_URI_init_;
+ }
+
+ AnyURI::
+ AnyURI (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Base64Binary
+ //
+ namespace
+ {
+ struct Base64BinaryInit
+ {
+ Base64BinaryInit ()
+ {
+ type_info ti (typeid (Base64Binary));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } base_64_binary_init_;
+ }
+
+ Base64Binary::
+ Base64Binary (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // HexBinary
+ //
+ namespace
+ {
+ struct HexBinaryInit
+ {
+ HexBinaryInit ()
+ {
+ type_info ti (typeid (HexBinary));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } hex_binary_init_;
+ }
+
+ HexBinary::
+ HexBinary (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Date
+ //
+ namespace
+ {
+ struct DateInit
+ {
+ DateInit ()
+ {
+ type_info ti (typeid (Date));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } date_init_;
+ }
+
+ Date::
+ Date (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // DateTime
+ //
+ namespace
+ {
+ struct DateTimeInit
+ {
+ DateTimeInit ()
+ {
+ type_info ti (typeid (DateTime));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } date_time_init_;
+ }
+
+ DateTime::
+ DateTime (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Duration
+ //
+ namespace
+ {
+ struct DurationInit
+ {
+ DurationInit ()
+ {
+ type_info ti (typeid (Duration));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } duration_init_;
+ }
+
+ Duration::
+ Duration (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Day
+ //
+ namespace
+ {
+ struct DayInit
+ {
+ DayInit ()
+ {
+ type_info ti (typeid (Day));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } day_init_;
+ }
+
+ Day::
+ Day (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Month
+ //
+ namespace
+ {
+ struct MonthInit
+ {
+ MonthInit ()
+ {
+ type_info ti (typeid (Month));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } month_init_;
+ }
+
+ Month::
+ Month (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // MonthDay
+ //
+ namespace
+ {
+ struct MonthDayInit
+ {
+ MonthDayInit ()
+ {
+ type_info ti (typeid (MonthDay));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } month_day_init_;
+ }
+
+ MonthDay::
+ MonthDay (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Year
+ //
+ namespace
+ {
+ struct YearInit
+ {
+ YearInit ()
+ {
+ type_info ti (typeid (Year));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } year_init_;
+ }
+
+ Year::
+ Year (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // YearMonth
+ //
+ namespace
+ {
+ struct YearMonthInit
+ {
+ YearMonthInit ()
+ {
+ type_info ti (typeid (YearMonth));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } year_month_init_;
+ }
+
+ YearMonth::
+ YearMonth (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Time
+ //
+ namespace
+ {
+ struct TimeInit
+ {
+ TimeInit ()
+ {
+ type_info ti (typeid (Time));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } time_init_;
+ }
+
+ Time::
+ Time (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Entity
+ //
+ namespace
+ {
+ struct EntityInit
+ {
+ EntityInit ()
+ {
+ type_info ti (typeid (Entity));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } entity_init_;
+ }
+
+ Entity::
+ Entity (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Entities
+ //
+ namespace
+ {
+ struct EntitiesInit
+ {
+ EntitiesInit ()
+ {
+ type_info ti (typeid (Entities));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } entities_init_;
+ }
+
+ Entities::
+ Entities (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ // Notation
+ //
+ namespace
+ {
+ struct NotationInit
+ {
+ NotationInit ()
+ {
+ type_info ti (typeid (Notation));
+ ti.add_base (typeid (Type));
+ insert (ti);
+ }
+
+ } notation_init_;
+ }
+
+ Notation::
+ Notation (Path const& file,
+ unsigned long line,
+ unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+ }
+ }
+}
diff --git a/libxsd-frontend/semantic-graph/fundamental.hxx b/libxsd-frontend/semantic-graph/fundamental.hxx
new file mode 100644
index 0000000..e45557d
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/fundamental.hxx
@@ -0,0 +1,468 @@
+// file : libxsd-frontend/semantic-graph/fundamental.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_FUNDAMENTAL_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_FUNDAMENTAL_HXX
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ namespace Fundamental
+ {
+ // Type
+ //
+ class Type: public virtual SemanticGraph::Type
+ {
+ protected:
+ Type ();
+ };
+
+ // Byte
+ //
+ class Byte: public virtual Type
+ {
+ public:
+ Byte (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // UnsignedByte
+ //
+ class UnsignedByte: public virtual Type
+ {
+ public:
+ UnsignedByte (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Short
+ //
+ class Short: public virtual Type
+ {
+ public:
+ Short (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // UnsignedShort
+ //
+ class UnsignedShort: public virtual Type
+ {
+ public:
+ UnsignedShort (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Int
+ //
+ class Int: public virtual Type
+ {
+ public:
+ Int (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // UnsignedInt
+ //
+ class UnsignedInt: public virtual Type
+ {
+ public:
+ UnsignedInt (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Long
+ //
+ class Long: public virtual Type
+ {
+ public:
+ Long (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // UnsignedLong
+ //
+ class UnsignedLong: public virtual Type
+ {
+ public:
+ UnsignedLong (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Integer
+ //
+ class Integer: public virtual Type
+ {
+ public:
+ Integer (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // NonPositiveInteger
+ //
+ class NonPositiveInteger: public virtual Type
+ {
+ public:
+ NonPositiveInteger (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // NonNegativeInteger
+ //
+ class NonNegativeInteger: public virtual Type
+ {
+ public:
+ NonNegativeInteger (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // PositiveInteger
+ //
+ class PositiveInteger: public virtual Type
+ {
+ public:
+ PositiveInteger (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // NegativeInteger
+ //
+ class NegativeInteger: public virtual Type
+ {
+ public:
+ NegativeInteger (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Boolean
+ //
+ class Boolean: public virtual Type
+ {
+ public:
+ Boolean (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Float
+ //
+ class Float: public virtual Type
+ {
+ public:
+ Float (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Double
+ //
+ class Double: public virtual Type
+ {
+ public:
+ Double (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Decimal
+ //
+ class Decimal: public virtual Type
+ {
+ public:
+ Decimal (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // String
+ //
+ class String: public virtual Type
+ {
+ public:
+ String (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // NormalizedString
+ //
+ class NormalizedString: public virtual Type
+ {
+ public:
+ NormalizedString (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Token
+ //
+ class Token: public virtual Type
+ {
+ public:
+ Token (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Name
+ //
+ class Name: public virtual Type
+ {
+ public:
+ Name (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // NameToken
+ //
+ class NameToken: public virtual Type
+ {
+ public:
+ NameToken (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // NameTokens
+ //
+ class NameTokens: public virtual Type
+ {
+ public:
+ NameTokens (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // NCName
+ //
+ class NCName: public virtual Type
+ {
+ public:
+ NCName (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Language
+ //
+ class Language: public virtual Type
+ {
+ public:
+ Language (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // QName
+ //
+ class QName: public virtual Type
+ {
+ public:
+ QName (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Id
+ //
+ class Id: public virtual Type
+ {
+ public:
+ Id (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // IdRef
+ //
+ class IdRef: public virtual Type,
+ public virtual Specialization
+ {
+ public:
+ IdRef (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // IdRefs
+ //
+ class IdRefs: public virtual Type,
+ public virtual Specialization
+ {
+ public:
+ IdRefs (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // AnyURI
+ //
+ class AnyURI: public virtual Type
+ {
+ public:
+ AnyURI (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Base64Binary
+ //
+ class Base64Binary: public virtual Type
+ {
+ public:
+ Base64Binary (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // HexBinary
+ //
+ class HexBinary: public virtual Type
+ {
+ public:
+ HexBinary (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Date
+ //
+ class Date: public virtual Type
+ {
+ public:
+ Date (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // DateTime
+ //
+ class DateTime: public virtual Type
+ {
+ public:
+ DateTime (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Duration
+ //
+ class Duration: public virtual Type
+ {
+ public:
+ Duration (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Day
+ //
+ class Day: public virtual Type
+ {
+ public:
+ Day (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Month
+ //
+ class Month: public virtual Type
+ {
+ public:
+ Month (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // MonthDay
+ //
+ class MonthDay: public virtual Type
+ {
+ public:
+ MonthDay (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Year
+ //
+ class Year: public virtual Type
+ {
+ public:
+ Year (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // YearMonth
+ //
+ class YearMonth: public virtual Type
+ {
+ public:
+ YearMonth (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Time
+ //
+ class Time: public virtual Type
+ {
+ public:
+ Time (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Entity
+ //
+ class Entity: public virtual Type
+ {
+ public:
+ Entity (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Entities
+ //
+ class Entities: public virtual Type
+ {
+ public:
+ Entities (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+
+ // Notation
+ //
+ class Notation: public virtual Type
+ {
+ public:
+ Notation (Path const& file,
+ unsigned long line,
+ unsigned long column);
+ };
+ }
+ }
+}
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_FUNDAMENTAL_HXX
diff --git a/libxsd-frontend/semantic-graph/list.cxx b/libxsd-frontend/semantic-graph/list.cxx
new file mode 100644
index 0000000..7c3fd21
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/list.cxx
@@ -0,0 +1,33 @@
+// file : libxsd-frontend/semantic-graph/list.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/list.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ List::
+ List (Path const& file, unsigned long line, unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ namespace
+ {
+ using compiler::type_info;
+
+ struct ListInit
+ {
+ ListInit ()
+ {
+ type_info ti (typeid (List));
+ ti.add_base (typeid (Specialization));
+ insert (ti);
+ }
+ } list_init_;
+ }
+ }
+}
diff --git a/libxsd-frontend/semantic-graph/list.hxx b/libxsd-frontend/semantic-graph/list.hxx
new file mode 100644
index 0000000..efd6c67
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/list.hxx
@@ -0,0 +1,21 @@
+// file : libxsd-frontend/semantic-graph/list.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_LIST_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_LIST_HXX
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ class List: public virtual Specialization
+ {
+ public:
+ List (Path const& file, unsigned long line, unsigned long column);
+ };
+ }
+}
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_LIST_HXX
diff --git a/libxsd-frontend/semantic-graph/namespace.cxx b/libxsd-frontend/semantic-graph/namespace.cxx
new file mode 100644
index 0000000..d0892f2
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/namespace.cxx
@@ -0,0 +1,33 @@
+// file : libxsd-frontend/semantic-graph/namespace.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/namespace.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ Namespace::
+ Namespace (Path const& file, unsigned long line, unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ namespace
+ {
+ using compiler::type_info;
+
+ struct NamespaceInit
+ {
+ NamespaceInit ()
+ {
+ type_info ti (typeid (Namespace));
+ ti.add_base (typeid (Scope));
+ insert (ti);
+ }
+ } namespace_init_;
+ }
+ }
+}
diff --git a/libxsd-frontend/semantic-graph/namespace.hxx b/libxsd-frontend/semantic-graph/namespace.hxx
new file mode 100644
index 0000000..1ae0a6f
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/namespace.hxx
@@ -0,0 +1,26 @@
+// file : libxsd-frontend/semantic-graph/namespace.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_NAMESPACE_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_NAMESPACE_HXX
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ class Namespace : public virtual Scope
+ {
+ public:
+ Namespace (Path const& file, unsigned long line, unsigned long column);
+
+ void
+ add_edge_right (BelongsToNamespace&) {}
+
+ using Scope::add_edge_right;
+ };
+ }
+}
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_NAMESPACE_HXX
diff --git a/libxsd-frontend/semantic-graph/particle.cxx b/libxsd-frontend/semantic-graph/particle.cxx
new file mode 100644
index 0000000..484d28b
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/particle.cxx
@@ -0,0 +1,53 @@
+// file : libxsd-frontend/semantic-graph/particle.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/particle.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ // ContainsParticle
+ //
+ ContainsParticle::
+ ContainsParticle (unsigned long min, unsigned long max)
+ : particle_ (0), compositor_ (0), min_ (min), max_ (max)
+ {
+ }
+
+ // Particle
+ //
+ Particle::
+ Particle ()
+ : contained_particle_ (0)
+ {
+ }
+
+ namespace
+ {
+ using compiler::type_info;
+
+ struct ContainsParticleInit
+ {
+ ContainsParticleInit ()
+ {
+ type_info ti (typeid (ContainsParticle));
+ ti.add_base (typeid (Edge));
+ insert (ti);
+ }
+ } contains_particle_init_;
+
+ struct ParticleInit
+ {
+ ParticleInit ()
+ {
+ type_info ti (typeid (Particle));
+ ti.add_base (typeid (Node));
+ insert (ti);
+ }
+ } particle_init_;
+ }
+ }
+}
diff --git a/libxsd-frontend/semantic-graph/particle.hxx b/libxsd-frontend/semantic-graph/particle.hxx
new file mode 100644
index 0000000..e438863
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/particle.hxx
@@ -0,0 +1,139 @@
+// file : libxsd-frontend/semantic-graph/particle.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_PARTICLE_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_PARTICLE_HXX
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ //
+ //
+ class Particle;
+ class Compositor;
+
+
+ //
+ //
+ class ContainsParticle: public virtual Edge
+ {
+ public:
+ Particle&
+ particle () const
+ {
+ return *particle_;
+ }
+
+ Compositor&
+ compositor () const
+ {
+ return *compositor_;
+ }
+
+ public:
+ unsigned long
+ min () const
+ {
+ return min_;
+ }
+
+ unsigned long
+ max () const
+ {
+ return max_;
+ }
+
+ public:
+ ContainsParticle (unsigned long min, unsigned long max);
+
+ void
+ set_left_node (Compositor& n)
+ {
+ compositor_ = &n;
+ }
+
+ void
+ set_right_node (Particle& n)
+ {
+ particle_ = &n;
+ }
+
+ void
+ clear_left_node (Compositor& n)
+ {
+ assert (compositor_ == &n);
+ compositor_ = 0;
+ }
+
+ void
+ clear_right_node (Particle& n)
+ {
+ assert (particle_ == &n);
+ particle_ = 0;
+ }
+
+ private:
+ Particle* particle_;
+ Compositor* compositor_;
+ unsigned long min_, max_;
+ };
+
+ //
+ //
+ class Particle: public virtual Node
+ {
+ public:
+ bool
+ contained_particle_p ()
+ {
+ return contained_particle_ != 0;
+ }
+
+ ContainsParticle&
+ contained_particle ()
+ {
+ assert (contained_particle_ != 0);
+ return *contained_particle_;
+ }
+
+ public:
+ unsigned long
+ min () const
+ {
+ assert (contained_particle_ != 0);
+ return contained_particle_->min ();
+ }
+
+ unsigned long
+ max () const
+ {
+ assert (contained_particle_ != 0);
+ return contained_particle_->max ();
+ }
+
+ public:
+ Particle ();
+
+ void
+ add_edge_right (ContainsParticle& e)
+ {
+ contained_particle_ = &e;
+ }
+
+ void
+ remove_edge_right (ContainsParticle& e)
+ {
+ assert (contained_particle_ == &e);
+ contained_particle_ = 0;
+ }
+
+ private:
+ ContainsParticle* contained_particle_;
+ };
+ }
+}
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_PARTICLE_HXX
diff --git a/libxsd-frontend/semantic-graph/schema.cxx b/libxsd-frontend/semantic-graph/schema.cxx
new file mode 100644
index 0000000..3df900b
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/schema.cxx
@@ -0,0 +1,129 @@
+// file : libxsd-frontend/semantic-graph/schema.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/schema.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ // Schema
+ //
+ Schema::NamesIteratorPair Schema::
+ find (Name const& name) const
+ {
+ // Here we are going to create an illusion that the namespace
+ // hierarchy is flat.
+ names_.clear ();
+ schemas_.clear ();
+
+ find_ (name, names_, schemas_);
+
+ return NamesIteratorPair (NamesConstIterator (names_.begin ()),
+ NamesConstIterator (names_.end ()));
+ }
+
+ void Schema::
+ find_ (Name const& name, NamesList& names, SchemaSet& set) const
+ {
+ set.insert (this);
+
+ // Check our own namespace first so it will end up first in the list.
+ //
+ NamesIteratorPair pair (Scope::find (name));
+ names.insert (names.end (), pair.first.base (), pair.second.base ());
+
+ for (UsesIterator i (uses_begin ()), end (uses_end ()); i != end; ++i)
+ {
+ Schema& s (i->schema ());
+
+ if (set.find (&s) == set.end ())
+ s.find_ (name, names, set);
+ }
+ }
+
+ namespace
+ {
+ using compiler::type_info;
+
+ // Uses
+ //
+ struct UsesInit
+ {
+ UsesInit ()
+ {
+ type_info ti (typeid (Uses));
+ ti.add_base (typeid (Edge));
+ insert (ti);
+ }
+ } uses_init_;
+
+
+ // Implies
+ //
+ struct ImpliesInit
+ {
+ ImpliesInit ()
+ {
+ type_info ti (typeid (Implies));
+ ti.add_base (typeid (Uses));
+ insert (ti);
+ }
+ } implies_init_;
+
+
+ // Sources
+ //
+ struct SourcesInit
+ {
+ SourcesInit ()
+ {
+ type_info ti (typeid (Sources));
+ ti.add_base (typeid (Uses));
+ insert (ti);
+ }
+ } sources_init_;
+
+
+ // Includes
+ //
+ struct IncludesInit
+ {
+ IncludesInit ()
+ {
+ type_info ti (typeid (Includes));
+ ti.add_base (typeid (Uses));
+ insert (ti);
+ }
+ } includes_init_;
+
+
+ // Imports
+ //
+ struct ImportsInit
+ {
+ ImportsInit ()
+ {
+ type_info ti (typeid (Imports));
+ ti.add_base (typeid (Uses));
+ insert (ti);
+ }
+ } imports_init_;
+
+
+ // Schema
+ //
+ struct SchemaInit
+ {
+ SchemaInit ()
+ {
+ type_info ti (typeid (Schema));
+ ti.add_base (typeid (Scope));
+ insert (ti);
+ }
+ } schema_init_;
+ }
+ }
+}
diff --git a/libxsd-frontend/semantic-graph/schema.hxx b/libxsd-frontend/semantic-graph/schema.hxx
new file mode 100644
index 0000000..abcd5ca
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/schema.hxx
@@ -0,0 +1,236 @@
+// file : libxsd-frontend/semantic-graph/schema.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_SCHEMA_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_SCHEMA_HXX
+
+#include <set>
+#include <vector>
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+#include <libxsd-frontend/semantic-graph/namespace.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ class Schema;
+
+ class Uses: public virtual Edge
+ {
+ public:
+ Schema&
+ user () const
+ {
+ return *user_;
+ }
+
+ Schema&
+ schema () const
+ {
+ return *schema_;
+ }
+
+ Path
+ path () const
+ {
+ return path_;
+ }
+
+ public:
+ Uses (Path const& path): path_ (path) {}
+
+ void
+ set_left_node (Schema& s)
+ {
+ user_ = &s;
+ }
+
+ void
+ set_right_node (Schema& s)
+ {
+ schema_ = &s;
+ }
+
+ private:
+ Path path_;
+ Schema* user_;
+ Schema* schema_;
+ };
+
+
+ //
+ //
+ class Implies: public virtual Uses
+ {
+ public:
+ Implies (Path const& path): Uses (path) {}
+ };
+
+
+ //
+ //
+ class Sources: public virtual Uses
+ {
+ public:
+ Sources (Path const& path): Uses (path) {}
+ };
+
+
+ //
+ //
+ class Includes: public virtual Uses
+ {
+ public:
+ Includes (Path const& path): Uses (path) {}
+ };
+
+
+ //
+ //
+ class Imports: public virtual Uses
+ {
+ public:
+ Imports (Path const& path): Uses (path) {}
+ };
+
+ //
+ //
+ class Schema: public graph, public virtual Scope
+ {
+ typedef std::vector<Uses*> UsesList;
+ typedef std::vector<Uses*> UsedList;
+
+ public:
+ Schema (Path const& file, unsigned long line, unsigned long column)
+ : Node (file, line, column), graph_ (*this)
+ {
+ }
+
+ private:
+ Schema (Schema const&);
+ Schema& operator= (Schema const&);
+
+ public:
+ typedef pointer_iterator<UsesList::const_iterator> UsesIterator;
+
+ UsesIterator
+ uses_begin () const
+ {
+ return uses_.begin ();
+ }
+
+ UsesIterator
+ uses_end () const
+ {
+ return uses_.end ();
+ }
+
+ public:
+ typedef pointer_iterator<UsedList::const_iterator> UsedIterator;
+
+ UsedIterator
+ used_begin () const
+ {
+ return used_.begin ();
+ }
+
+ UsedIterator
+ used_end () const
+ {
+ return used_.end ();
+ }
+
+ bool
+ used_p () const
+ {
+ return used_begin () != used_end ();
+ }
+
+ virtual NamesIteratorPair
+ find (Name const& name) const;
+
+ public:
+ using graph::new_edge;
+ using graph::reset_left_node;
+ using graph::reset_right_node;
+ using graph::add_edge_left;
+ using graph::add_edge_right;
+ using graph::delete_node;
+ using graph::delete_edge;
+
+ template <typename T>
+ T&
+ new_node (Path const& file, unsigned long line, unsigned long column)
+ {
+ return graph_.new_node<T> (file, line, column);
+ }
+
+ template <typename T, typename A0>
+ T&
+ new_node (Path const& file, unsigned long line, unsigned long column,
+ A0 const& a0)
+ {
+ return graph_.new_node<T> (file, line, column, a0);
+ }
+
+ template <typename T, typename A0, typename A1>
+ T&
+ new_node (Path const& file, unsigned long line, unsigned long column,
+ A0 const& a0, A1 const& a1)
+ {
+ return graph_.new_node<T> (file, line, column, a0, a1);
+ }
+
+ template <typename T, typename A0, typename A1, typename A2>
+ T&
+ new_node (Path const& file, unsigned long line, unsigned long column,
+ A0 const& a0, A1 const& a1, A2 const& a2)
+ {
+ return graph_.new_node<T> (file, line, column, a0, a1, a2);
+ }
+
+ template <typename T, typename A0, typename A1, typename A2,
+ typename A3>
+ T&
+ new_node (Path const& file, unsigned long line, unsigned long column,
+ A0 const& a0, A1 const& a1, A2 const& a2, A3 const& a3)
+ {
+ return graph_.new_node<T> (file, line, column, a0, a1, a2, a3);
+ }
+
+ public:
+ using Scope::add_edge_left;
+ using Node::add_edge_right;
+
+ void
+ add_edge_left (Uses& e)
+ {
+ uses_.push_back (&e);
+ }
+
+ void
+ add_edge_right (Uses& e)
+ {
+ used_.push_back (&e);
+ }
+
+ private:
+ typedef std::set<Schema const*> SchemaSet;
+
+ void
+ find_ (Name const& name, NamesList&, SchemaSet&) const;
+
+ private:
+ graph& graph_;
+
+ UsesList uses_;
+ UsedList used_;
+
+ mutable NamesList names_;
+ mutable SchemaSet schemas_;
+ };
+ }
+}
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_SCHEMA_HXX
diff --git a/libxsd-frontend/semantic-graph/union.cxx b/libxsd-frontend/semantic-graph/union.cxx
new file mode 100644
index 0000000..eeb59d2
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/union.cxx
@@ -0,0 +1,33 @@
+// file : libxsd-frontend/semantic-graph/union.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <libcutl/compiler/type-info.hxx>
+
+#include <libxsd-frontend/semantic-graph/union.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ Union::
+ Union (Path const& file, unsigned long line, unsigned long column)
+ : Node (file, line, column)
+ {
+ }
+
+ namespace
+ {
+ using compiler::type_info;
+
+ struct UnionInit
+ {
+ UnionInit ()
+ {
+ type_info ti (typeid (Union));
+ ti.add_base (typeid (Specialization));
+ insert (ti);
+ }
+ } union_init_;
+ }
+ }
+}
diff --git a/libxsd-frontend/semantic-graph/union.hxx b/libxsd-frontend/semantic-graph/union.hxx
new file mode 100644
index 0000000..bef0144
--- /dev/null
+++ b/libxsd-frontend/semantic-graph/union.hxx
@@ -0,0 +1,21 @@
+// file : libxsd-frontend/semantic-graph/union.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef LIBXSD_FRONTEND_SEMANTIC_GRAPH_UNION_HXX
+#define LIBXSD_FRONTEND_SEMANTIC_GRAPH_UNION_HXX
+
+#include <libxsd-frontend/semantic-graph/elements.hxx>
+
+namespace XSDFrontend
+{
+ namespace SemanticGraph
+ {
+ class Union: public virtual Specialization
+ {
+ public:
+ Union (Path const& file, unsigned long line, unsigned long column);
+ };
+ }
+}
+
+#endif // LIBXSD_FRONTEND_SEMANTIC_GRAPH_UNION_HXX