summaryrefslogtreecommitdiff
path: root/TAO/CIAO/CCF/Test/IDL2/Compiler
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/CIAO/CCF/Test/IDL2/Compiler')
-rw-r--r--TAO/CIAO/CCF/Test/IDL2/Compiler/Makefile.alt33
-rw-r--r--TAO/CIAO/CCF/Test/IDL2/Compiler/driver.cpp93
-rw-r--r--TAO/CIAO/CCF/Test/IDL2/Compiler/result.idl.orig88
-rw-r--r--TAO/CIAO/CCF/Test/IDL2/Compiler/test.idl151
4 files changed, 365 insertions, 0 deletions
diff --git a/TAO/CIAO/CCF/Test/IDL2/Compiler/Makefile.alt b/TAO/CIAO/CCF/Test/IDL2/Compiler/Makefile.alt
new file mode 100644
index 00000000000..ac86d6e10ac
--- /dev/null
+++ b/TAO/CIAO/CCF/Test/IDL2/Compiler/Makefile.alt
@@ -0,0 +1,33 @@
+# file : Test/IDL2/Compiler/Makefile.alt
+# author : Boris Kolpackov <boris@dre.vanderbilt.edu>
+# cvs-id : $Id$
+
+root = ../../..
+
+include $(root)/Bootstrap.rules
+
+$(call include, $(root)/Config.rules)
+
+$(call include, $(UTILITY_ROOT)/BuildRules/Executable.pre.rules)
+
+cxx_translation_units := driver.cpp
+
+translated_units += ../Traversal/Recreate/Generator.o
+
+module_base := driver
+module_prefix :=
+module_suffix :=
+
+CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT)
+
+# -L$(root)/CCF/CompilerElements \
+# -lCompilerElements \
+
+CXX_LINK_LIBS += -L$(root)/CCF/IDL2 \
+ -lIDL2 \
+ -L$(UTILITY_ROOT)/Utility/Introspection \
+ -lIntrospection \
+ -L$(BOOST_ROOT)/lib \
+ -lboost_filesystem
+
+$(call include, $(UTILITY_ROOT)/BuildRules/Executable.post.rules)
diff --git a/TAO/CIAO/CCF/Test/IDL2/Compiler/driver.cpp b/TAO/CIAO/CCF/Test/IDL2/Compiler/driver.cpp
new file mode 100644
index 00000000000..16f8fce9656
--- /dev/null
+++ b/TAO/CIAO/CCF/Test/IDL2/Compiler/driver.cpp
@@ -0,0 +1,93 @@
+// file : Test/IDL2/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/IDL2/LexicalAnalyzer.hpp"
+#include "CCF/IDL2/Parser.hpp"
+#include "CCF/IDL2/SemanticGraph.hpp"
+#include "CCF/IDL2/SemanticAction/Impl/Factory.hpp"
+
+#include "../Traversal/Recreate/Generator.hpp"
+
+#include <iostream>
+
+using std::cerr;
+using std::cout;
+using std::endl;
+
+using namespace CCF::IDL2;
+using namespace CCF::IDL2::SemanticGraph;
+
+int
+main ()
+{
+ try
+ {
+ Diagnostic::Stream dout;
+
+ fs::path file_path ("stdout");
+
+ CCF::InputStreamAdapter isa (std::cin);
+ CCF::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);
+
+ Parsing::parse (token_stream.begin (),
+ token_stream.end (),
+ parser.start ());
+
+ if (dout.error_count () != 0) return -1;
+
+ IDL2::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/TAO/CIAO/CCF/Test/IDL2/Compiler/result.idl.orig b/TAO/CIAO/CCF/Test/IDL2/Compiler/result.idl.orig
new file mode 100644
index 00000000000..a29258b9e6f
--- /dev/null
+++ b/TAO/CIAO/CCF/Test/IDL2/Compiler/result.idl.orig
@@ -0,0 +1,88 @@
+module AttributeTest
+{
+ interface I
+ {
+ attribute long a;
+ attribute string foo;
+ };
+};
+module InterfaceTest
+{
+ abstract interface AI;
+ local interface LI;
+ interface I;
+ abstract interface AI
+ {
+ };
+ interface I : ::InterfaceTest::AI
+ {
+ };
+ local interface LI : ::InterfaceTest::I, ::InterfaceTest::AI
+ {
+ };
+};
+module MemberTest
+{
+ typedef long Id;
+ struct S
+ {
+ long id;
+ string foo;
+ string bar;
+ string baz;
+ };
+};
+module ModuleTest
+{
+ module M
+ {
+ module N
+ {
+ typedef long L;
+ };
+ };
+ module M
+ {
+ typedef long L;
+ };
+ module N
+ {
+ typedef long L;
+ };
+};
+module OperationTest
+{
+ interface I
+ {
+ long f (in string a, out long b, inout octet c);
+ };
+};
+module Sequence
+{
+ typedef sequence<octet> OctetSeq;
+ typedef sequence<octet> RawSeq;
+ typedef sequence<string> StringSeq;
+ typedef sequence<string> StrSeq;
+};
+module StructTest
+{
+ struct S;
+ struct S
+ {
+ long m;
+ };
+};
+module TypeidTest
+{
+ interface I;
+ typeid ::TypeidTest::I "Foo";
+ typeprefix ::TypeidTest "Bar";
+};
+module TypedefTest
+{
+ interface I;
+ typedef ::TypedefTest::I J;
+ interface I
+ {
+ };
+};
diff --git a/TAO/CIAO/CCF/Test/IDL2/Compiler/test.idl b/TAO/CIAO/CCF/Test/IDL2/Compiler/test.idl
new file mode 100644
index 00000000000..1d18e7118fe
--- /dev/null
+++ b/TAO/CIAO/CCF/Test/IDL2/Compiler/test.idl
@@ -0,0 +1,151 @@
+// file : CCF/Test/IDL2/Compiler/test.idl
+// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
+// cvs-id : $Id$
+
+// Attribute
+//
+//
+module AttributeTest
+{
+ interface I
+ {
+ attribute long a;
+ attribute string foo;
+ };
+};
+
+// Interface
+//
+//
+module InterfaceTest
+{
+ abstract interface AI;
+ local interface LI;
+ interface I;
+
+ abstract interface AI
+ {
+ };
+
+ interface I : AI
+ {
+ };
+
+ local interface LI : I, AI
+ {
+ };
+};
+
+// Member
+//
+//
+module MemberTest
+{
+ typedef long Id;
+
+ struct S
+ {
+ Id id;
+ string foo, bar, baz;
+ };
+};
+
+// Module
+//
+//
+module ModuleTest
+{
+ module M
+ {
+ module N
+ {
+ typedef long L;
+ };
+ };
+
+ module M
+ {
+ typedef N::L L;
+ };
+
+ module N
+ {
+ typedef M::N::L L;
+ };
+};
+
+
+// Operation
+//
+//
+module OperationTest
+{
+ interface I
+ {
+ long f (in string a, out long b, inout octet c);
+ };
+};
+
+
+// Sequence
+//
+//
+module Sequence
+{
+ typedef sequence<octet> OctetSeq;
+
+ typedef OctetSeq RawSeq;
+
+ typedef sequence<string> StringSeq, StrSeq;
+};
+
+
+// Struct
+//
+//
+module StructTest
+{
+ struct S;
+
+ struct S
+ {
+ long m; // Struct cannot be empty.
+ };
+
+};
+
+// Typeid
+//
+//
+module TypeidTest
+{
+ interface I;
+
+ typeid I "Foo";
+ typeprefix TypeidTest "Bar";
+};
+
+
+// Typedef
+//
+//
+
+module TypedefTest
+{
+ interface I;
+
+ typedef I J;
+
+ interface I
+ {
+ /*
+ struct S
+ {
+ long l;
+ };
+
+ J::S op ();
+ */
+ };
+};
+