summaryrefslogtreecommitdiff
path: root/CIAO/CCF/Test/CIDL/Compiler
diff options
context:
space:
mode:
Diffstat (limited to 'CIAO/CCF/Test/CIDL/Compiler')
-rw-r--r--CIAO/CCF/Test/CIDL/Compiler/Generator.cpp32
-rw-r--r--CIAO/CCF/Test/CIDL/Compiler/Generator.hpp34
-rw-r--r--CIAO/CCF/Test/CIDL/Compiler/GeneratorImpl.hpp228
-rw-r--r--CIAO/CCF/Test/CIDL/Compiler/driver.cpp97
-rw-r--r--CIAO/CCF/Test/CIDL/Compiler/result.cidl.orig14
-rw-r--r--CIAO/CCF/Test/CIDL/Compiler/test.cidl21
6 files changed, 426 insertions, 0 deletions
diff --git a/CIAO/CCF/Test/CIDL/Compiler/Generator.cpp b/CIAO/CCF/Test/CIDL/Compiler/Generator.cpp
new file mode 100644
index 00000000000..278278b3360
--- /dev/null
+++ b/CIAO/CCF/Test/CIDL/Compiler/Generator.cpp
@@ -0,0 +1,32 @@
+// file : Test/CIDL/Compiler/Generator.cpp
+// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
+// cvs-id : $Id$
+
+#include "Generator.hpp"
+#include "GeneratorImpl.hpp"
+
+namespace CIDL
+{
+ Generator::
+ ~Generator ()
+ {
+ }
+
+ Generator::
+ Generator ()
+ : pimpl_ (new GeneratorImpl), impl_ (*pimpl_)
+ {
+ }
+
+ Generator::
+ Generator (GeneratorImpl& gi)
+ : pimpl_ (), impl_ (gi)
+ {
+ }
+
+ void Generator::
+ generate (CCF::IDL3::SemanticGraph::TranslationUnit& tu)
+ {
+ impl_.generate (tu);
+ }
+}
diff --git a/CIAO/CCF/Test/CIDL/Compiler/Generator.hpp b/CIAO/CCF/Test/CIDL/Compiler/Generator.hpp
new file mode 100644
index 00000000000..3876195469d
--- /dev/null
+++ b/CIAO/CCF/Test/CIDL/Compiler/Generator.hpp
@@ -0,0 +1,34 @@
+// file : Test/CIDL/Compiler/Generator.hpp
+// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
+// cvs-id : $Id$
+
+#ifndef TEST_CIDL_COMPILER_GENERATOR_HPP
+#define TEST_CIDL_COMPILER_GENERATOR_HPP
+
+#include <memory>
+
+#include "CCF/CIDL/SemanticGraph.hpp"
+
+namespace CIDL
+{
+ class GeneratorImpl;
+
+ class Generator
+ {
+ public:
+ ~Generator ();
+ Generator ();
+
+ void
+ generate (CCF::CIDL::SemanticGraph::TranslationUnit& tu);
+
+ protected:
+ Generator (GeneratorImpl&);
+
+ protected:
+ std::auto_ptr<GeneratorImpl> pimpl_;
+ GeneratorImpl& impl_;
+ };
+}
+
+#endif // TEST_CIDL_COMPILER_GENERATOR_HPP
diff --git a/CIAO/CCF/Test/CIDL/Compiler/GeneratorImpl.hpp b/CIAO/CCF/Test/CIDL/Compiler/GeneratorImpl.hpp
new file mode 100644
index 00000000000..169fb57ace3
--- /dev/null
+++ b/CIAO/CCF/Test/CIDL/Compiler/GeneratorImpl.hpp
@@ -0,0 +1,228 @@
+// file : Test/CIDL/Compiler/GeneratorImpl.hpp
+// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
+// cvs-id : $Id$
+
+#ifndef TEST_CIDL_COMPILER_GENERATOR_IMPL_HPP
+#define TEST_CIDL_COMPILER_GENERATOR_IMPL_HPP
+
+#include <iostream>
+
+#include "CCF/CodeGenerationKit/IndentationIDL.hpp"
+#include "CCF/CodeGenerationKit/IndentationImplanter.hpp"
+
+#include "CCF/CIDL/SemanticGraph.hpp"
+#include "CCF/CIDL/Traversal.hpp"
+
+#include "../../IDL3/Compiler/GeneratorImpl.hpp"
+
+namespace CIDL
+{
+ using namespace CCF::CIDL;
+
+ using std::cout;
+ using std::endl;
+
+ class GeneratorImpl : public IDL3::GeneratorImpl
+ {
+ protected:
+ // Layer 1
+ //
+
+ // Layer 2
+ //
+
+ // Layer 3
+ //
+
+ //--
+
+ struct Composition : Traversal::Composition
+ {
+ virtual void
+ pre (Type& c)
+ {
+ //@@ TODO kind
+ cout << "composition " << "session" << " ";
+ }
+
+ virtual void
+ name (Type& i)
+ {
+ cout << i.name ();
+ }
+
+ virtual void
+ names_pre (Type&)
+ {
+ cout << "{";
+ }
+
+ virtual void
+ names_post (Type&)
+ {
+ cout << "}";
+ }
+
+ virtual void
+ post (Type&)
+ {
+ cout << ";";
+ }
+ };
+
+
+ struct HomeExecutor : Traversal::HomeExecutor
+ {
+ virtual void
+ pre (Type&)
+ {
+ cout << "home executor ";
+ }
+
+ virtual void
+ name (Type& he)
+ {
+ cout << he.name () << "{";
+ }
+
+ virtual void
+ implements_pre (Type&)
+ {
+ cout << "implements ";
+ }
+
+ virtual void
+ implements_post (Type&)
+ {
+ cout << ";";
+ }
+
+ virtual void
+ manages_pre (Type&)
+ {
+ cout << "manages ";
+ }
+
+ virtual void
+ manages_post (Type&)
+ {
+ cout << ";";
+ }
+
+ virtual void
+ post (Type& he)
+ {
+ cout << "};";
+ }
+ };
+
+
+ // Layer 4
+ //
+
+ //--
+
+ // Layer 5
+ //
+
+ //--
+
+ struct SimpleName : Traversal::Nameable
+ {
+ virtual void
+ traverse (Type& n)
+ {
+ cout << n.name ();
+ }
+ };
+
+ public:
+
+ GeneratorImpl ()
+ {
+ // Layer 1
+ //
+
+ // Layer 2
+ //
+
+ // Layer 3
+ //
+
+ //--
+
+ defines.node_traverser (composition);
+
+ // Layer 4
+ //
+
+ composition.edge_traverser (composition_defines);
+
+ //--
+
+ composition_defines.node_traverser (home_executor);
+
+ // Layer 5
+ //
+ home_executor.edge_traverser (home_executor_implements);
+ home_executor.edge_traverser (home_executor_manages);
+
+ //--
+
+ home_executor_implements.node_traverser (type_name);
+ home_executor_manages.node_traverser (simple_name);
+
+ // Layer 6
+ //
+
+ }
+
+ protected:
+ // Layer 1
+ //
+
+ // Layer 2
+ //
+
+ // Layer 3
+ //
+
+ //--
+
+ Composition composition;
+
+ // Layer 4
+ //
+
+ Traversal::Defines composition_defines;
+
+ //--
+
+ HomeExecutor home_executor;
+
+ // Layer 5
+ //
+ Traversal::Implements home_executor_implements;
+ Traversal::Manages home_executor_manages;
+
+ //--
+
+ SimpleName simple_name;
+
+ // Layer 6
+ //
+
+ public:
+ void
+ generate (CCF::CIDL::SemanticGraph::TranslationUnit& tu)
+ {
+ // Plug automatic IDL indenter.
+ //
+ Indentation::Implanter<Indentation::IDL> guard (cout);
+
+ unit.traverse (tu);
+ }
+ };
+}
+
+#endif // TEST_CIDL_COMPILER_GENERATOR_IMPL_HPP
diff --git a/CIAO/CCF/Test/CIDL/Compiler/driver.cpp b/CIAO/CCF/Test/CIDL/Compiler/driver.cpp
new file mode 100644
index 00000000000..222dd8f851c
--- /dev/null
+++ b/CIAO/CCF/Test/CIDL/Compiler/driver.cpp
@@ -0,0 +1,97 @@
+// file : Test/CIDL/Compiler/driver.cpp
+// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
+// cvs-id : $Id$
+
+#include "CCF/CompilerElements/Context.hpp"
+#include "CCF/CompilerElements/FileSystem.hpp"
+#include "CCF/CompilerElements/Diagnostic.hpp"
+#include "CCF/CompilerElements/TokenStream.hpp"
+#include "CCF/CompilerElements/Preprocessor.hpp"
+
+#include "CCF/CIDL/LexicalAnalyzer.hpp"
+#include "CCF/CIDL/Parser.hpp"
+#include "CCF/CIDL/SemanticGraph.hpp"
+#include "CCF/CIDL/SemanticAction/Impl/Factory.hpp"
+
+#include "Generator.hpp"
+
+#include <iostream>
+
+using std::cerr;
+using std::cout;
+using std::endl;
+
+using namespace CCF::CompilerElements;
+using namespace CCF::CIDL;
+using namespace SemanticGraph;
+
+int
+main ()
+{
+ try
+ {
+ Diagnostic::Stream dout;
+
+ fs::path file_path ("stdout");
+
+ InputStreamAdapter isa (std::cin);
+ CPP::Preprocessor pp (isa);
+
+ LexicalAnalyzer lexer (pp);
+
+ TokenList token_stream;
+
+ //@@ bad token comparison
+ for (TokenPtr token = lexer.next ();; token = lexer.next ())
+ {
+ token_stream.push_back (token);
+ if (ReferenceCounting::strict_cast<EndOfStream> (token) != 0) break;
+ }
+
+ if (token_stream.size () < 2)
+ {
+ cerr << "no tokens produced so nothing to parse" << endl;
+ return 0;
+ }
+
+ TranslationUnit tu;
+
+ // Compilation context.
+ //
+ CCF::CompilerElements::Context context;
+ context.set ("file-path", file_path);
+ context.set ("trace-semantic-action", false);
+
+
+ SemanticAction::Impl::Factory actions (context, dout, tu);
+
+ Parser parser (context, dout, lexer, actions);
+
+ //@@ should be able to use IDL3 here. Or better yet get rid of this
+ // function completely.
+ //
+ CCF::IDL2::Parsing::parse (token_stream.begin (),
+ token_stream.end (),
+ parser.start ());
+
+ if (dout.error_count () != 0) return -1;
+
+ CIDL::Generator g;
+
+ g.generate (tu);
+
+ }
+ catch (std::bad_cast const&)
+ {
+ cerr << "bad cast exception" << endl;
+ }
+ catch (InvalidName const&)
+ {
+ cerr << "invalid name exception" << endl;
+ }
+ catch (...)
+ {
+ cerr << "caught unknown exception" << endl;
+ return -1;
+ }
+}
diff --git a/CIAO/CCF/Test/CIDL/Compiler/result.cidl.orig b/CIAO/CCF/Test/CIDL/Compiler/result.cidl.orig
new file mode 100644
index 00000000000..6ba766db738
--- /dev/null
+++ b/CIAO/CCF/Test/CIDL/Compiler/result.cidl.orig
@@ -0,0 +1,14 @@
+component C
+{
+};
+home H manages ::C
+{
+};
+composition session SC
+{
+ home executor H_Exec
+ {
+ implements ::H;
+ manages C_Exec;
+ };
+};
diff --git a/CIAO/CCF/Test/CIDL/Compiler/test.cidl b/CIAO/CCF/Test/CIDL/Compiler/test.cidl
new file mode 100644
index 00000000000..349712a18df
--- /dev/null
+++ b/CIAO/CCF/Test/CIDL/Compiler/test.cidl
@@ -0,0 +1,21 @@
+// file : CCF/Test/CIDL/Compiler/test.cidl
+// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
+// cvs-id : $Id$
+
+component C
+{
+};
+
+home H manages C
+{
+};
+
+composition session SC
+{
+ home executor H_Exec
+ {
+ implements H;
+ manages C_Exec;
+ };
+};
+