diff options
author | Abdullah Sowayan <sowayan@users.noreply.github.com> | 2007-03-18 22:23:37 +0000 |
---|---|---|
committer | Abdullah Sowayan <sowayan@users.noreply.github.com> | 2007-03-18 22:23:37 +0000 |
commit | 06a34455bd98b1379cc69bbc5b2cf085e0fc0d9b (patch) | |
tree | 8815ce3b3a85c3c4285429295f338e00ea4497f4 /CIAO/CCF/Test/IDL3/Compiler/driver.cpp | |
parent | d66fcc9b4aaec8e88eeb83fc578fdf8a3cc963de (diff) | |
download | ATCD-06a34455bd98b1379cc69bbc5b2cf085e0fc0d9b.tar.gz |
Diffstat (limited to 'CIAO/CCF/Test/IDL3/Compiler/driver.cpp')
-rw-r--r-- | CIAO/CCF/Test/IDL3/Compiler/driver.cpp | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/CIAO/CCF/Test/IDL3/Compiler/driver.cpp b/CIAO/CCF/Test/IDL3/Compiler/driver.cpp new file mode 100644 index 00000000000..d2f8ff91ba0 --- /dev/null +++ b/CIAO/CCF/Test/IDL3/Compiler/driver.cpp @@ -0,0 +1,97 @@ +// file : Test/IDL3/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/IDL3/LexicalAnalyzer.hpp" +#include "CCF/IDL3/Parser.hpp" +#include "CCF/IDL3/SemanticGraph.hpp" +#include "CCF/IDL3/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::IDL3; +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; + + IDL3::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; + } +} |