diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-05-31 00:56:39 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-05-31 00:56:39 +0000 |
commit | 0a0416f0d11c724103868c0b091a7138f6999443 (patch) | |
tree | 1585434c354d7ff77b14ded3fd6f8775584781b5 /TAO/CIAO/CCF/CCF/IDL3 | |
parent | 8ec551a46536d0949f10a9b87f065b8bd74b1ffc (diff) | |
download | ATCD-0a0416f0d11c724103868c0b091a7138f6999443.tar.gz |
ChangeLogTag: Fri May 30 19:33:36 2003 Jeff Parsons <j.parsons@vanderbilt.edu>
Diffstat (limited to 'TAO/CIAO/CCF/CCF/IDL3')
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL3/IDL3.cpp | 1 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL3/IDL3.vcproj | 156 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL3/IDL3_LexicalAnalyzer.hpp | 59 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL3/IDL3_Parser.hpp | 425 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL3/IDL3_SemanticAction.hpp | 179 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL3/IDL3_SemanticActionImpl.hpp | 1365 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTree.cpp | 186 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTree.hpp | 627 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTreeFwd.hpp | 69 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTree_EventType.cpp | 22 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTree_EventType.hpp | 215 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL3/IDL3_Traversal.cpp | 184 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL3/IDL3_Traversal.hpp | 175 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL3/MSVC_Pragmas.hpp | 16 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL3/Makefile | 22 |
15 files changed, 3701 insertions, 0 deletions
diff --git a/TAO/CIAO/CCF/CCF/IDL3/IDL3.cpp b/TAO/CIAO/CCF/CCF/IDL3/IDL3.cpp new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/IDL3.cpp @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/CIAO/CCF/CCF/IDL3/IDL3.vcproj b/TAO/CIAO/CCF/CCF/IDL3/IDL3.vcproj new file mode 100644 index 00000000000..43895adcdd2 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/IDL3.vcproj @@ -0,0 +1,156 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="IDL3" + ProjectGUID="{97D61986-05D8-4B2A-B8B2-5095E58909FE}" + Keyword="Win32Proj"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectDir)" + IntermediateDirectory="Debug" + ConfigurationType="4" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../..;../../External/Utility" + PreprocessorDefinitions="WIN32;_DEBUG;_LIB" + MinimalRebuild="TRUE" + BasicRuntimeChecks="3" + RuntimeLibrary="5" + ForceConformanceInForLoopScope="TRUE" + RuntimeTypeInfo="TRUE" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="4"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)/IDL3.lib"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="4" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="WIN32;NDEBUG;_LIB" + RuntimeLibrary="4" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)/IDL3.lib"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> + <File + RelativePath=".\IDL3_SyntaxTree.cpp"> + </File> + <File + RelativePath=".\IDL3_SyntaxTree_EventType.cpp"> + </File> + <File + RelativePath=".\IDL3_Traversal.cpp"> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> + <File + RelativePath=".\IDL3_LexicalAnalyzer.hpp"> + </File> + <File + RelativePath=".\IDL3_Parser.hpp"> + </File> + <File + RelativePath=".\IDL3_SemanticAction.hpp"> + </File> + <File + RelativePath=".\IDL3_SemanticActionImpl.hpp"> + </File> + <File + RelativePath=".\IDL3_SyntaxTree.hpp"> + </File> + <File + RelativePath=".\IDL3_SyntaxTree_EventType.hpp"> + </File> + <File + RelativePath=".\IDL3_SyntaxTreeFwd.hpp"> + </File> + <File + RelativePath=".\IDL3_Traversal.hpp"> + </File> + <File + RelativePath=".\MSVC_Pragmas.hpp"> + </File> + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"> + </Filter> + <File + RelativePath=".\ReadMe.txt"> + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/TAO/CIAO/CCF/CCF/IDL3/IDL3_LexicalAnalyzer.hpp b/TAO/CIAO/CCF/CCF/IDL3/IDL3_LexicalAnalyzer.hpp new file mode 100644 index 00000000000..610e047f294 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/IDL3_LexicalAnalyzer.hpp @@ -0,0 +1,59 @@ +// $Id$ +#ifndef CCF_IDL3_LEXICAL_ANALYZER_HPP +#define CCF_IDL3_LEXICAL_ANALYZER_HPP + +#include "MSVC_Pragmas.hpp" + +#include "CCF/IDL2/IDL2_LexicalAnalyzer.hpp" + +#include <string> + +namespace IDL3 +{ + class LexicalAnalyzer : public virtual IDL2::LexicalAnalyzer + { + public: + virtual + ~LexicalAnalyzer () throw () {} + + public: + + // Keywords (alphabetic order). + + KeywordPtr component; + KeywordPtr consumes; + KeywordPtr emits; + KeywordPtr eventtype; + KeywordPtr home; + KeywordPtr manages; + KeywordPtr provides; + KeywordPtr publishes; + KeywordPtr uses; + + LexicalAnalyzer (CCF::TokenStream<char>& is) + : IDL2::LexicalAnalyzer (is), + + component (new Keyword), + consumes (new Keyword), + emits (new Keyword), + eventtype (new Keyword), + home (new Keyword), + manages (new Keyword), + provides (new Keyword), + publishes (new Keyword), + uses (new Keyword) + { + keyword_table_["component"] = component; + keyword_table_["consumes" ] = consumes; + keyword_table_["emits" ] = emits; + keyword_table_["eventtype"] = eventtype; + keyword_table_["home" ] = home; + keyword_table_["manages" ] = manages; + keyword_table_["provides" ] = provides; + keyword_table_["publishes"] = publishes; + keyword_table_["uses" ] = uses; + } + }; +} + +#endif // CCF_IDL3_LEXICAL_ANALYZER_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/IDL3_Parser.hpp b/TAO/CIAO/CCF/CCF/IDL3/IDL3_Parser.hpp new file mode 100644 index 00000000000..97cade9dca1 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/IDL3_Parser.hpp @@ -0,0 +1,425 @@ +// $Id$ +#ifndef CCF_IDL3_PARSER_HPP +#define CCF_IDL3_PARSER_HPP + + +#include "MSVC_Pragmas.hpp" + +#include "CCF/CompilerElements/Parser.hpp" +#include "CCF/IDL2/IDL2_Parser.hpp" +#include "CCF/IDL3/IDL3_LexicalAnalyzer.hpp" +#include "CCF/IDL3/IDL3_SemanticAction.hpp" + +namespace IDL3 +{ + class Parser : public virtual IDL2::Parser + { + public: + virtual + ~Parser () throw () {} + + protected: + + // + // Semanic action types + // + typedef + SemanticAction::Component + Component; + + typedef + SemanticAction::Provides + Provides; + + typedef + SemanticAction::Uses + Uses; + + typedef + SemanticAction::Publishes + Publishes; + + typedef + SemanticAction::Emits + Emits; + + typedef + SemanticAction::Consumes + Consumes; + + typedef + SemanticAction::EventType + EventType; + + typedef + SemanticAction::Home + Home; + + typedef + SemanticAction::HomeFactory + HomeFactory; + + // + // Primitives (alphabetic order). + // + KeywordParser COMPONENT; + KeywordParser CONSUMES; + KeywordParser EMITS; + KeywordParser EVENTTYPE; + KeywordParser HOME; + KeywordParser MANAGES; + KeywordParser PROVIDES; + KeywordParser PUBLISHES; + KeywordParser USES; + + + // + // Language + // + + Rule extension; + + // Component + Rule component_decl; + Rule component_header; + Rule component_inheritance_spec; + Rule component_support_spec; + Rule component_body; + + // Component body elements + Rule provides_decl; + Rule uses_decl; + Rule emits_decl; + Rule publishes_decl; + Rule consumes_decl; + + // Eventtype + Rule eventtype_decl; + Rule eventtype_header; + Rule eventtype_inheritance_spec; + Rule eventtype_body; + + // Home + Rule home_decl; + Rule home_header; + Rule home_inheritance_spec; + Rule home_support_spec; + Rule home_manage_spec; + Rule home_body; + + Rule home_factory_decl; + Rule home_factory_parameter_list; + Rule home_factory_parameter; + + + public: + + Parser (LexicalAnalyzer const& l, SemanticActionFactory& f) + : IDL2::Parser (l, f), + + COMPONENT (l.component), + CONSUMES (l.consumes), + EMITS (l.emits), + EVENTTYPE (l.eventtype), + HOME (l.home), + MANAGES (l.manages), + PROVIDES (l.provides), + PUBLISHES (l.publishes), + USES (l.uses), + + act_component_begin (f.component (), &Component::begin), + act_component_inherits (f.component (), &Component::inherits), + act_component_supports (f.component (), &Component::supports), + act_component_open_scope (f.component (), &Component::open_scope), + act_component_close_scope (f.component (), &Component::close_scope), + act_component_end (f.component (), &Component::end), + + act_provides_type (f.provides (), &Provides::type), + act_provides_name (f.provides (), &Provides::name), + + act_uses_type (f.uses (), &Uses::type), + act_uses_name (f.uses (), &Uses::name), + + act_publishes_type (f.publishes (), &Publishes::type), + act_publishes_name (f.publishes (), &Publishes::name), + + act_emits_type (f.emits (), &Emits::type), + act_emits_name (f.emits (), &Emits::name), + + act_consumes_type (f.consumes (), &Consumes::type), + act_consumes_name (f.consumes (), &Consumes::name), + + act_event_type_begin (f.event_type (), &EventType::begin), + act_event_type_inherits (f.event_type (), &EventType::inherits), + act_event_type_open_scope (f.event_type (), &EventType::open_scope), + act_event_type_close_scope (f.event_type (), &EventType::close_scope), + act_event_type_end (f.event_type (), &EventType::end), + + act_home_begin (f.home (), &Home::begin), + act_home_inherits (f.home (), &Home::inherits), + act_home_supports (f.home (), &Home::supports), + act_home_manages (f.home (), &Home::manages), + act_home_open_scope (f.home (), &Home::open_scope), + act_home_close_scope (f.home (), &Home::close_scope), + act_home_end (f.home (), &Home::end), + + act_home_factory_begin (f.home_factory (), &HomeFactory::begin), + act_home_factory_parameter (f.home_factory (), + &HomeFactory::parameter), + act_home_factory_end (f.home_factory (), &HomeFactory::end) + + { + IDL2::Parser::extension = + component_decl + | eventtype_decl + | home_decl + | extension + ; + + // + // Component + // + component_decl = + component_header + >> + ( + SEMI[act_component_end] + | + ( + !(COLON >> component_inheritance_spec) + >> !(SUPPORTS >> component_support_spec) + >> LBRACE[act_component_open_scope] + >> component_body + >> RBRACE[act_component_close_scope] + >> SEMI[act_component_end] + ) + ) + ; + + component_header = + COMPONENT + >> simple_identifier[act_component_begin] + ; + + component_inheritance_spec = identifier[act_component_inherits] + ; + + component_support_spec = + identifier[act_component_supports] + >> *(COMMA >> identifier[act_component_supports]) + ; + + component_body = + *( provides_decl + | uses_decl + | emits_decl + | publishes_decl + | consumes_decl + | attribute_decl + ) + ; + + // + // Component body elements + // + provides_decl = + PROVIDES + >> identifier[act_provides_type] + >> simple_identifier[act_provides_name] + >> SEMI + ; + + uses_decl = + USES + >> identifier[act_uses_type] + >> simple_identifier[act_uses_name] + >> SEMI + ; + + emits_decl = + EMITS + >> identifier[act_emits_type] + >> simple_identifier[act_emits_name] + >> SEMI + ; + + publishes_decl = + PUBLISHES + >> identifier[act_publishes_type] + >> simple_identifier[act_publishes_name] + >> SEMI + ; + + consumes_decl = + CONSUMES + >> identifier[act_consumes_type] + >> simple_identifier[act_consumes_name] + >> SEMI + ; + + // + // Eventtype + // + eventtype_decl = + eventtype_header + >> + ( + SEMI[act_event_type_end] + | + ( + !(COLON >> eventtype_inheritance_spec) + >> LBRACE[act_event_type_open_scope] +// >> eventtype_body + >> RBRACE[act_event_type_close_scope] + >> SEMI[act_event_type_end] + ) + ) + ; + + eventtype_header = + !(ABSTRACT) + >> EVENTTYPE + >> simple_identifier[act_event_type_begin] + ; + + eventtype_inheritance_spec = + identifier[act_event_type_inherits] + >> *(COMMA >> identifier[act_event_type_inherits]) + ; + + // + // Home + // + home_decl = + home_header + >> !(COLON >> home_inheritance_spec) + >> !(SUPPORTS >> home_support_spec) + >> MANAGES >> home_manage_spec + >> LBRACE[act_home_open_scope] + >> home_body + >> RBRACE[act_home_close_scope] + >> SEMI[act_home_end] + ; + + home_header = HOME >> simple_identifier[act_home_begin] + ; + + home_inheritance_spec = identifier[act_home_inherits] + ; + + home_support_spec = + identifier[act_home_supports] + >> *(COMMA >> identifier[act_home_supports]) + ; + + home_manage_spec = identifier[act_home_manages] + ; + + home_body = + *( + attribute_decl + | operation_decl + | home_factory_decl + ) + ; + + // + // Home factory + // + home_factory_decl = + FACTORY + >> simple_identifier[act_home_factory_begin] + >> LPAREN + >> home_factory_parameter_list + >> RPAREN + >> SEMI[act_home_factory_end] + ; + + home_factory_parameter_list = + *( + home_factory_parameter + >> *(COMMA >> home_factory_parameter) + ) + ; + + home_factory_parameter = + IN + >> (identifier >> simple_identifier)[act_home_factory_parameter] + ; + + } + + protected: + // + // + // + OneArgAction<SimpleIdentifierPtr, Component> act_component_begin; + OneArgAction<IdentifierPtr, Component> act_component_inherits; + OneArgAction<IdentifierPtr, Component> act_component_supports; + ScopeAction act_component_open_scope; + ScopeAction act_component_close_scope; + NoArgAction<Component> act_component_end; + + // + // Provides + // + OneArgAction<IdentifierPtr, Provides> act_provides_type; + OneArgAction<SimpleIdentifierPtr, Provides> act_provides_name; + + // + // Uses + // + OneArgAction<IdentifierPtr, Uses> act_uses_type; + OneArgAction<SimpleIdentifierPtr, Uses> act_uses_name; + + // + // Publishes + // + OneArgAction<IdentifierPtr, Publishes> act_publishes_type; + OneArgAction<SimpleIdentifierPtr, Publishes> act_publishes_name; + + // + // Emits + // + OneArgAction<IdentifierPtr, Emits> act_emits_type; + OneArgAction<SimpleIdentifierPtr, Emits> act_emits_name; + + // + // Consumes + // + OneArgAction<IdentifierPtr, Consumes> act_consumes_type; + OneArgAction<SimpleIdentifierPtr, Consumes> act_consumes_name; + + // + // + // + OneArgAction<SimpleIdentifierPtr, EventType> act_event_type_begin; + OneArgAction<IdentifierPtr, EventType> act_event_type_inherits; + ScopeAction act_event_type_open_scope; + ScopeAction act_event_type_close_scope; + NoArgAction<EventType> act_event_type_end; + + // + // + // + OneArgAction<SimpleIdentifierPtr, Home> act_home_begin; + OneArgAction<IdentifierPtr, Home> act_home_inherits; + OneArgAction<IdentifierPtr, Home> act_home_supports; + OneArgAction<IdentifierPtr, Home> act_home_manages; + ScopeAction act_home_open_scope; + ScopeAction act_home_close_scope; + NoArgAction<Home> act_home_end; + + // + // Home + // + OneArgAction<SimpleIdentifierPtr, HomeFactory> act_home_factory_begin; + TwoArgAction<IdentifierPtr, + SimpleIdentifierPtr, + HomeFactory> act_home_factory_parameter; + NoArgAction<HomeFactory> act_home_factory_end; + + }; +} + +#endif // CCF_IDL3_PARSER_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/IDL3_SemanticAction.hpp b/TAO/CIAO/CCF/CCF/IDL3/IDL3_SemanticAction.hpp new file mode 100644 index 00000000000..51f21d077e3 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/IDL3_SemanticAction.hpp @@ -0,0 +1,179 @@ +// $Id$ +#ifndef CCF_IDL3_SEMANTIC_ACTION_HPP +#define CCF_IDL3_SEMANTIC_ACTION_HPP + +#include "MSVC_Pragmas.hpp" + +#include "CCF/IDL2/IDL2_SemanticAction.hpp" + +namespace IDL3 +{ + namespace SemanticAction + { + using namespace IDL2::SemanticAction; + + class Component : public virtual Scope + { + public: + + virtual void + begin (SimpleIdentifierPtr const& id) = 0; + + virtual void + inherits (IdentifierPtr const& id) = 0; + + virtual void + supports (IdentifierPtr const& id) = 0; + + virtual void + end () = 0; + }; + + class Provides + { + public: + virtual + ~Provides () throw () {} + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + + class Uses + { + public: + virtual + ~Uses () throw () {} + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + + class Publishes + { + public: + virtual + ~Publishes () throw () {} + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + + class Emits + { + public: + virtual + ~Emits () throw () {} + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + + class Consumes + { + public: + virtual + ~Consumes () throw () {} + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + + class EventType : public virtual Scope + { + public: + + virtual void + begin (SimpleIdentifierPtr const& id) = 0; + + virtual void + inherits (IdentifierPtr const& id) = 0; + + virtual void + end () = 0; + }; + + class Home : public virtual Scope + { + public: + + virtual void + begin (SimpleIdentifierPtr const& id) = 0; + + virtual void + inherits (IdentifierPtr const& id) = 0; + + virtual void + supports (IdentifierPtr const& id) = 0; + + virtual void + manages (IdentifierPtr const& id) = 0; + + virtual void + end () = 0; + }; + + class HomeFactory + { + public: + + virtual void + begin (SimpleIdentifierPtr const& id) = 0; + + virtual void + parameter (IdentifierPtr const& type, + SimpleIdentifierPtr const& name) = 0; + + virtual void + end () = 0; + }; + } + + class SemanticActionFactory : public virtual IDL2::SemanticActionFactory + { + public: + virtual SemanticAction::Component& + component () = 0; + + virtual SemanticAction::Provides& + provides () = 0; + + virtual SemanticAction::Uses& + uses () = 0; + + virtual SemanticAction::Publishes& + publishes () = 0; + + virtual SemanticAction::Emits& + emits () = 0; + + virtual SemanticAction::Consumes& + consumes () = 0; + + virtual SemanticAction::EventType& + event_type () = 0; + + virtual SemanticAction::Home& + home () = 0; + + virtual SemanticAction::HomeFactory& + home_factory () = 0; + }; +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/IDL3_SemanticActionImpl.hpp b/TAO/CIAO/CCF/CCF/IDL3/IDL3_SemanticActionImpl.hpp new file mode 100644 index 00000000000..9cbf1c49c9b --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/IDL3_SemanticActionImpl.hpp @@ -0,0 +1,1365 @@ +// $Id$ +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_HPP + +#include "MSVC_Pragmas.hpp" + +#include "CCF/IDL3/IDL3_SyntaxTree.hpp" +#include "CCF/IDL3/IDL3_SyntaxTree_EventType.hpp" + +#include "CCF/IDL3/IDL3_SemanticAction.hpp" +#include "CCF/IDL2/IDL2_SemanticActionImpl.hpp" + +//@@ needed for include handling +#include "CCF/CompilerElements/TokenStream.hpp" +#include "CCF/CompilerElements/Preprocessor.hpp" + +namespace IDL3 +{ + namespace SemanticAction + { + namespace Impl + { + using IDL2::SemanticAction::Impl::ScopeBase; + + // Note: overriding IDL2 include to allow inclusiion of IDL3 files + // + // + class Include : public virtual SemanticAction::Include + { + public: + virtual + ~Include () throw () {} + + Include (SemanticActionFactory& action_factory, + SyntaxTree::TranslationRegionPtr const& region, + SyntaxTree::ScopePtr& scope) + : action_factory_ (action_factory), + scope_ (scope) + { + stack_.push (region); + } + + virtual void + begin (StringLiteralPtr const& sl) + { + cerr << "include \"" << sl << "\"" << endl; + + using namespace SyntaxTree; + + try + { + fs::path file_path (sl->value ()); + + if(!include_file_set_.insert (file_path).second) + { + cerr << "warning: skipping already included file \'" + << sl << "\'" << endl; + return; + } + + fs::ifstream ifs; + ifs.exceptions (ios_base::badbit | ios_base::failbit); + ifs.open (file_path, std::ios_base::in); + + //@@ for some reason ifs throws exception if I don't reset it to + // original state. It probably has something to do with call to + // get after eof. + ifs.exceptions (ios_base::iostate (0)); + + TranslationRegionPtr r ( + new IncludeTranslationRegion (file_path, + stack_.top ()->table (), + stack_.top ()->create_order ())); + + stack_.top ()->insert (r); + stack_.push (r); + + cerr << "push file scope: old scope " << scope_->order (); + + scope_ = stack_.top ()->scope (); + + cerr << "; new scope " << scope_->order () << endl; + + //@@ this code is highly experimental + CCF::InputStreamAdapter isa (ifs); + CCF::Preprocessor pp (isa); + IDL3::LexicalAnalyzer lexer (pp); + + TokenStream token_stream; + + //@@ bad token comparison + for (TokenPtr token = lexer.next (); + token.in () != lexer.eos.in (); + token = lexer.next ()) + { + token_stream.push_back (token); + } + + if (token_stream.size () != 0) + { + IDL3::Parser parser (lexer, action_factory_); + + /*bool result = */Details::parse (token_stream.begin (), + token_stream.end (), + parser.start ()); + } + + cerr << "pop file scope: old scope " << scope_->order (); + + stack_.pop (); + scope_ = stack_.top ()->scope (); + + cerr << "; new scope " << scope_->order () << endl; + } + catch (fs::filesystem_error const&) + { + cerr << sl << ": error: unable to open in read mode" << endl; + } + catch (ios_base::failure const&) + { + cerr << sl << ": error: unable to open in read mode" << endl; + } + } + + virtual void + end () + { + cerr << "end" << endl; + } + + public: + SemanticActionFactory& action_factory_; + SyntaxTree::ScopePtr& scope_; + std::stack<SyntaxTree::TranslationRegionPtr> stack_; + struct FilePathComparator + { + bool operator () (fs::path const& x, fs::path const& y) const + { + return x.string () < y.string (); + } + }; + + std::set<fs::path, FilePathComparator> include_file_set_; + }; + + + // + // + // + class Component : public virtual SemanticAction::Component, + public virtual ScopeBase<SyntaxTree::ComponentDeclPtr> + { + public: + virtual + ~Component () throw () {} + + + Component (SyntaxTree::ScopePtr& scope) + : ScopeBase<SyntaxTree::ComponentDeclPtr> (scope), + name_ (""), + inherits_ ("") + { + } + + virtual void + begin (SimpleIdentifierPtr const& id) + { + cerr << "component " << id << endl; + + name_ = SyntaxTree::SimpleName (id->value ()); + } + + virtual void + inherits (IdentifierPtr const& id) + { + cerr << "inherits " << id << endl; + + using namespace SyntaxTree; + + Name name (id->value ()); + + struct InheritancePredicate : + public DeclarationTable::ResolvePredicate + { + struct IncompatibleType : + public DeclarationTable::ResolutionFailure + { + IncompatibleType (std::string const& t) : type (t) {} + std::string type; + }; + + virtual bool + test (DeclarationPtr const& d) + throw (IncompatibleType) + { + std::string type = d->declaration_type (); + + if (type != "component") throw IncompatibleType (type); + + return strict_cast<TypeDecl> (d)->defined (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + inherits_ = sn; + } + catch (InheritancePredicate::IncompatibleType const& e) + { + cerr << "error: invalid inheritance specification" << endl; + + cerr << "inheritance of "; + cerr << "component \'" << name_ <<"\' from " + << e.type << " \'" << name << "\' is illegal" << endl; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid inheritance specification" << endl; + cerr << "no component with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid inheritance specification" << endl; + cerr << "no defined component with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + cerr << "inheritance from forward-declared component is illegal" + << endl; + } + } + + + virtual void + supports (IdentifierPtr const& id) + { + cerr << "supports " << id << endl; + + using namespace SyntaxTree; + + Name name (id->value ()); + + struct SupportsPredicate : + public DeclarationTable::ResolvePredicate + { + struct IncompatibleType : + public DeclarationTable::ResolutionFailure + { + IncompatibleType (std::string const& t) : type (t) {} + std::string type; + }; + + virtual bool + test (DeclarationPtr const& d) + throw (IncompatibleType) + { + std::string type = d->declaration_type (); + + // Spec doesn't say anything about which interfaces + // component can support. + if (type != "unconstrained interface") + throw IncompatibleType (type); + + return strict_cast<TypeDecl> (d)->defined (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + if (supports_.insert (sn).second == false) + { + cerr << "error: invalid support specification" << endl; + cerr << "directly supporting interface \'" + << sn << "\' more than once is illegal" << endl; + } + } + catch (SupportsPredicate::IncompatibleType const& e) + { + cerr << "error: invalid support specification" << endl; + + cerr << "specifying " << e.type << " \'" << name + << "\' in component\'s support clause is illegal" + << endl; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid support specification" << endl; + cerr << "no interface with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid support specification" << endl; + cerr << "no defined interface with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + cerr << "supporting forward-declared interface is illegal" + << endl; + } + } + + virtual void + open_scope () + { + using namespace SyntaxTree; + + ComponentDefPtr def; + + if (inherits_ == ScopedName ("")) + { + def = ComponentDefPtr (new ComponentDef ( + name_, + scope_, + supports_)); + } + else + { + def = ComponentDefPtr (new ComponentDef ( + name_, + scope_, + inherits_, + supports_)); + } + + scope_->insert (def); + push (def); + scope_ = def; + + name_ = SimpleName (""); //indicate that we are done + inherits_ = ScopedName (""); + supports_.clear (); + } + + virtual void + close_scope () + { + scope_ = scope_->scope (); + } + + virtual void + end () + { + cerr << "end" << endl; + + using namespace SyntaxTree; + + if (name_ != SimpleName ("")) + { + ComponentDeclPtr decl (new ComponentForwardDecl (name_, scope_)); + scope_->insert (decl); + } + else + { + pop (); + } + } + private: + SyntaxTree::SimpleName name_; + SyntaxTree::ScopedName inherits_; + SyntaxTree::ScopedNameSet supports_; + }; + + + class Provides : public virtual SemanticAction::Provides + { + public: + virtual + ~Provides () throw () {} + + Provides (SyntaxTree::ScopePtr& current) + : scope_ (current), + type_ ("") + { + } + + virtual void + type (IdentifierPtr const& id) + { + cerr << "provides " << id; + + using namespace SyntaxTree; + + Name name (id->value ()); + + struct Predicate : public DeclarationTable::ResolvePredicate + { + virtual bool + test (DeclarationPtr const& d) throw () + { + return strict_cast<InterfaceDecl> (d) != 0; + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + type_ = sn; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid provides declaration" << endl; + cerr << "no interface type with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid provides declaration" << endl; + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << scope_->name () + << "\' is not an interface type declaration" << endl; + cerr << "using non-<interface type> in provides " + << "declaration is illegal" << endl; + } + } + + virtual void + name (SimpleIdentifierPtr const& id) + { + cerr << " " << id << endl; + + using namespace SyntaxTree; + + SimpleName name (id->value ()); + + DeclarationPtr d ( + new SyntaxTree::ProvidesDecl (name, type_, scope_)); + + scope_->insert (d); + + type_ = ScopedName (""); + } + + private: + SyntaxTree::ScopePtr& scope_; + SyntaxTree::ScopedName type_; + }; + + class Uses : public virtual SemanticAction::Uses + { + public: + virtual + ~Uses () throw () {} + + Uses (SyntaxTree::ScopePtr& current) + : scope_ (current), + type_ ("") + { + } + + virtual void + type (IdentifierPtr const& id) + { + cerr << "uses " << id; + + using namespace SyntaxTree; + + Name name (id->value ()); + + struct Predicate : public DeclarationTable::ResolvePredicate + { + virtual bool + test (DeclarationPtr const& d) throw () + { + return strict_cast<InterfaceDecl> (d) != 0; + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + type_ = sn; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid uses declaration" << endl; + cerr << "no interface type with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid uses declaration" << endl; + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << scope_->name () + << "\' is not an interface type declaration" << endl; + cerr << "using non-<interface type> in uses " + << "declaration is illegal" << endl; + } + } + + virtual void + name (SimpleIdentifierPtr const& id) + { + cerr << " " << id << endl; + + using namespace SyntaxTree; + + SimpleName name (id->value ()); + + DeclarationPtr d ( + new SyntaxTree::UsesDecl (name, type_, scope_)); + + scope_->insert (d); + + type_ = ScopedName (""); + } + + private: + SyntaxTree::ScopePtr& scope_; + SyntaxTree::ScopedName type_; + }; + + + class Publishes : public virtual SemanticAction::Publishes + { + public: + virtual + ~Publishes () throw () {} + + Publishes (SyntaxTree::ScopePtr& current) + : scope_ (current), + type_ ("") + { + } + + virtual void + type (IdentifierPtr const& id) + { + cerr << "publishes " << id; + + using namespace SyntaxTree; + + Name name (id->value ()); + + struct Predicate : public DeclarationTable::ResolvePredicate + { + virtual bool + test (DeclarationPtr const& d) throw () + { + return strict_cast<EventTypeDef> (d) != 0; + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + type_ = sn; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid publishes declaration" << endl; + cerr << "no event type with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid publishes declaration" << endl; + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << scope_->name () + << "\' is not a defined event type" << endl; + cerr << "using non-<defined event type> in publishes " + << "declaration is illegal" << endl; + } + } + + virtual void + name (SimpleIdentifierPtr const& id) + { + cerr << " " << id << endl; + + using namespace SyntaxTree; + + SimpleName name (id->value ()); + + DeclarationPtr d ( + new SyntaxTree::PublishesDecl (name, type_, scope_)); + + scope_->insert (d); + + type_ = ScopedName (""); + } + + private: + SyntaxTree::ScopePtr& scope_; + SyntaxTree::ScopedName type_; + }; + + class Emits : public virtual SemanticAction::Emits + { + public: + virtual + ~Emits () throw () {} + + Emits (SyntaxTree::ScopePtr& current) + : scope_ (current), + type_ ("") + { + } + + virtual void + type (IdentifierPtr const& id) + { + cerr << "emits " << id; + + using namespace SyntaxTree; + + Name name (id->value ()); + + struct Predicate : public DeclarationTable::ResolvePredicate + { + virtual bool + test (DeclarationPtr const& d) throw () + { + return strict_cast<EventTypeDef> (d) != 0; + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + type_ = sn; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid emits declaration" << endl; + cerr << "no event type with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid emits declaration" << endl; + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << scope_->name () + << "\' is not a defined event type" << endl; + cerr << "using non-<defined event type> in emits " + << "declaration is illegal" << endl; + } + } + + virtual void + name (SimpleIdentifierPtr const& id) + { + cerr << " " << id << endl; + + using namespace SyntaxTree; + + SimpleName name (id->value ()); + + DeclarationPtr d ( + new SyntaxTree::EmitsDecl (name, type_, scope_)); + + scope_->insert (d); + + type_ = ScopedName (""); + } + + private: + SyntaxTree::ScopePtr& scope_; + SyntaxTree::ScopedName type_; + }; + + class Consumes : public virtual SemanticAction::Consumes + { + public: + virtual + ~Consumes () throw () {} + + Consumes (SyntaxTree::ScopePtr& current) + : scope_ (current), + type_ ("") + { + } + + virtual void + type (IdentifierPtr const& id) + { + cerr << "consumes " << id; + + using namespace SyntaxTree; + + Name name (id->value ()); + + struct Predicate : public DeclarationTable::ResolvePredicate + { + virtual bool + test (DeclarationPtr const& d) throw () + { + return strict_cast<EventTypeDef> (d) != 0; + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + type_ = sn; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid consumes declaration" << endl; + cerr << "no event type with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid consumes declaration" << endl; + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << scope_->name () + << "\' is not a defined event type" << endl; + cerr << "using non-<defined event type> in consumes " + << "declaration is illegal" << endl; + } + } + + virtual void + name (SimpleIdentifierPtr const& id) + { + cerr << " " << id << endl; + + using namespace SyntaxTree; + + SimpleName name (id->value ()); + + DeclarationPtr d ( + new SyntaxTree::ConsumesDecl (name, type_, scope_)); + + scope_->insert (d); + + type_ = ScopedName (""); + } + + private: + SyntaxTree::ScopePtr& scope_; + SyntaxTree::ScopedName type_; + }; + + // + // + // + class EventType : public virtual SemanticAction::EventType, + public virtual ScopeBase<SyntaxTree::EventTypeDeclPtr> + { + public: + virtual + ~EventType () throw () {} + + EventType (SyntaxTree::ScopePtr& scope) + : ScopeBase<SyntaxTree::EventTypeDeclPtr> (scope), + name_ ("") + { + } + + public: + + virtual void + begin (SimpleIdentifierPtr const& id) + { + cerr << "eventtype " << id << endl; + name_ = SyntaxTree::SimpleName (id->value ()); + } + + virtual void + inherits (IdentifierPtr const& id) + { + cerr << "inherits " << id << endl; + } + + virtual void + open_scope () + { + using namespace SyntaxTree; + + ConcreteEventTypeDefPtr et( new ConcreteEventTypeDef ( + name_, + scope_, + inherits_)); + scope_->insert (et); + push (et); + scope_ = et; + + name_ = SimpleName (""); //indicate that we are done + inherits_.clear (); + } + + virtual void + close_scope () + { + scope_ = scope_->scope (); + } + + virtual void + end () + { + cerr << "end" << endl; + pop (); + } + + private: + SyntaxTree::SimpleName name_; + SyntaxTree::ScopedNameSet inherits_; + }; + + + // + // + // + class Home : public virtual SemanticAction::Home, + public virtual ScopeBase<SyntaxTree::HomeDefPtr> + { + public: + virtual + ~Home () throw () {} + + Home (SyntaxTree::ScopePtr& scope) + : ScopeBase<SyntaxTree::HomeDefPtr> (scope), + name_ (""), + inherits_ (""), + manages_ ("") + + { + } + + virtual void + begin (SimpleIdentifierPtr const& id) + { + cerr << "home " << id << endl; + name_ = SyntaxTree::SimpleName (id->value ()); + } + + + virtual void + inherits (IdentifierPtr const& id) + { + cerr << "inherits " << id << endl; + + using namespace SyntaxTree; + + Name name (id->value ()); + + struct InheritancePredicate : + public DeclarationTable::ResolvePredicate + { + struct IncompatibleType : + public DeclarationTable::ResolutionFailure + { + IncompatibleType (std::string const& t) : type (t) {} + std::string type; + }; + + virtual bool + test (DeclarationPtr const& d) + throw (IncompatibleType) + { + std::string type = d->declaration_type (); + + if (type != "home") throw IncompatibleType (type); + + // This is not really necessary since home cannot be + // forward-declared (yet ;-). + return strict_cast<TypeDecl> (d)->defined (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + inherits_ = sn; + } + catch (InheritancePredicate::IncompatibleType const& e) + { + cerr << "error: invalid inheritance specification" << endl; + + cerr << "inheritance of "; + cerr << "home \'" << name_ <<"\' from " + << e.type << " \'" << name << "\' is illegal" << endl; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid inheritance specification" << endl; + cerr << "no home with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid inheritance specification" << endl; + cerr << "no defined home with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + cerr << "inheritance from forward-declared home is illegal" + << endl; + } + } + + + virtual void + supports (IdentifierPtr const& id) + { + cerr << "supports " << id << endl; + + using namespace SyntaxTree; + + Name name (id->value ()); + + struct SupportsPredicate : + public DeclarationTable::ResolvePredicate + { + struct IncompatibleType : + public DeclarationTable::ResolutionFailure + { + IncompatibleType (std::string const& t) : type (t) {} + std::string type; + }; + + virtual bool + test (DeclarationPtr const& d) + throw (IncompatibleType) + { + std::string type = d->declaration_type (); + + // Spec doesn't say anything about which interfaces + // component can support. + if (type != "unconstrained interface") + throw IncompatibleType (type); + + return strict_cast<TypeDecl> (d)->defined (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + if (supports_.insert (sn).second == false) + { + cerr << "error: invalid support specification" << endl; + cerr << "directly supporting interface \'" + << sn << "\' more than once is illegal" << endl; + } + } + catch (SupportsPredicate::IncompatibleType const& e) + { + cerr << "error: invalid support specification" << endl; + + cerr << "specifying " << e.type << " \'" << name + << "\' in home\'s support clause is illegal" + << endl; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid support specification" << endl; + cerr << "no interface with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid support specification" << endl; + cerr << "no defined interface with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + cerr << "supporting forward-declared interface is illegal" + << endl; + } + } + + + virtual void + manages (IdentifierPtr const& id) + { + cerr << "manages " << id << endl; + + using namespace SyntaxTree; + + Name name (id->value ()); + + struct ManagesPredicate : + public DeclarationTable::ResolvePredicate + { + struct IncompatibleType : + public DeclarationTable::ResolutionFailure + { + IncompatibleType (std::string const& t) : type (t) {} + std::string type; + }; + + virtual bool + test (DeclarationPtr const& d) + throw (IncompatibleType) + { + std::string type = d->declaration_type (); + + if (type != "component") throw IncompatibleType (type); + + return strict_cast<TypeDecl> (d)->defined (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + manages_ = sn; + } + catch (ManagesPredicate::IncompatibleType const& e) + { + cerr << "error: invalid manages specification" << endl; + + cerr << "specifying " << e.type << " \'" << name + << "\' in home manages clause is illegal" << endl; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid manages specification" << endl; + cerr << "no component with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid manages specification" << endl; + cerr << "no defined component with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + cerr << "managing of forward-declared component is illegal" + << endl; + } + } + + virtual void + open_scope () + { + using namespace SyntaxTree; + + HomeDefPtr def (new HomeDef ( + name_, + scope_, + inherits_, + supports_, + manages_)); + + if (inherits_ == ScopedName ("")) + { + def = HomeDefPtr (new HomeDef ( + name_, + scope_, + supports_, + manages_)); + } + else + { + def = HomeDefPtr (new HomeDef ( + name_, + scope_, + inherits_, + supports_, + manages_)); + } + + + scope_->insert (def); + push (def); + scope_ = def; + + name_ = SimpleName (""); //indicate that we are done + inherits_ = ScopedName (""); + supports_.clear (); + manages_ = ScopedName (""); + } + + virtual void + close_scope () + { + scope_ = scope_->scope (); + } + + virtual void + end () + { + cerr << "end" << endl; + + using namespace SyntaxTree; + + if (name_ != SimpleName ("")) + { + // this is not supported by spec yet + } + else + { + pop (); + } + } + private: + SyntaxTree::SimpleName name_; + SyntaxTree::ScopedName inherits_; + SyntaxTree::ScopedNameSet supports_; + SyntaxTree::ScopedName manages_; + }; + + // + // + // + //@@ Name is inconsistent with HomeFactoryDecl + class HomeFactory : public virtual SemanticAction::HomeFactory + { + public: + virtual + ~HomeFactory () throw () + { + } + + HomeFactory (SyntaxTree::ScopePtr& current) + : scope_ (current) + { + } + + virtual void + begin (SimpleIdentifierPtr const& id) + { + cerr << "home factory " << id << endl; + + using namespace SyntaxTree; + + HomeDefPtr home (scope_->dynamic_type<HomeDef> ()); + + if (home == 0) + { + //@@ internal compiler error + } + + ComponentDefPtr component (home->manages ()); + + home_factory_ = HomeFactoryDeclPtr ( + new HomeFactoryDecl (SimpleName (id->value ()), + component->name (), + scope_)); + } + + virtual void + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) + { + cerr << "parameter " << type_id << " " << name_id << endl; + + using namespace IDL3::SyntaxTree; + + Name type_name (type_id->value ()); + + struct Predicate : public DeclarationTable::ResolvePredicate + { + virtual bool + test (DeclarationPtr const& d) throw () + { + return strict_cast<TypeDecl> (d) != 0; + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + type_name, + scope_->name (), + scope_->peek_order (), + p); + + HomeFactoryParameterPtr p ( + new HomeFactoryParameter (sn, + SimpleName (name_id->value ()), + scope_->table ())); + + home_factory_->insert (p); + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid home factory declaration" << endl; + cerr << "no type with name \'" + << type_name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid home factory declaration" << endl; + cerr << "declaration with name \'" << type_name + << "\' visible from scope \'" << scope_->name () + << "\' is not a type declaration" << endl; + cerr << "using non-type as home factory parameter type is illegal" + << endl; + } + } + + virtual void + end () + { + cerr << "end" << endl; + scope_->insert (home_factory_); + home_factory_ = SyntaxTree::HomeFactoryDeclPtr (); + } + private: + SyntaxTree::ScopePtr& scope_; + SyntaxTree::HomeFactoryDeclPtr home_factory_; + }; + } + } + + class SemanticActionFactoryImpl : + public virtual IDL3::SemanticActionFactory, + public virtual IDL2::SemanticActionFactoryImpl + { + public: + virtual + ~SemanticActionFactoryImpl () throw () {} + + SemanticActionFactoryImpl (SyntaxTree::TranslationRegionPtr const& r) + : IDL2::SemanticActionFactoryImpl (r), + + include_ (*this, r, scope_), + component_ (scope_), + provides_ (scope_), + uses_ (scope_), + publishes_ (scope_), + emits_ (scope_), + consumes_ (scope_), + event_type_ (scope_), + home_ (scope_), + home_factory_ (scope_) + { + + } + + public: + + virtual SemanticAction::Include& + include () + { + return include_; + } + + virtual SemanticAction::Component& + component () + { + return component_; + } + + virtual SemanticAction::Provides& + provides () + { + return provides_; + } + + virtual SemanticAction::Uses& + uses () + { + return uses_; + } + + virtual SemanticAction::Publishes& + publishes () + { + return publishes_; + } + + virtual SemanticAction::Emits& + emits () + { + return emits_; + } + + virtual SemanticAction::Consumes& + consumes () + { + return consumes_; + } + + + virtual SemanticAction::EventType& + event_type () + { + return event_type_; + } + + virtual SemanticAction::Home& + home () + { + return home_; + } + + virtual SemanticAction::HomeFactory& + home_factory () + { + return home_factory_; + } + + + private: + + SemanticAction::Impl::Include include_; + + SemanticAction::Impl::Component component_; + SemanticAction::Impl::Provides provides_; + SemanticAction::Impl::Uses uses_; + SemanticAction::Impl::Publishes publishes_; + SemanticAction::Impl::Emits emits_; + SemanticAction::Impl::Consumes consumes_; + SemanticAction::Impl::EventType event_type_; + SemanticAction::Impl::Home home_; + SemanticAction::Impl::HomeFactory home_factory_; + }; +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTree.cpp b/TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTree.cpp new file mode 100644 index 00000000000..d8afe5f49e4 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTree.cpp @@ -0,0 +1,186 @@ +// $Id$ +#include "IDL3_Traversal.hpp" +#include "IDL3_SyntaxTree.hpp" + +namespace IDL3 +{ + namespace SyntaxTree + { + using CCF::Traversal::try_visit; + + namespace + { + //@@ repetition of what's already in IDL2 + bool + try_visit_scope (CCF::Traversal::Visitor* v, + ScopePtr const& node) + { + return try_visit<Traversal::Scope> ( + &Traversal::Scope::visit_scope, + v, + node); + } + + bool + try_visit_component_decl (CCF::Traversal::Visitor* v, + ComponentDeclPtr const& node) + { + return try_visit<Traversal::ComponentDecl> ( + &Traversal::ComponentDecl::visit_component_decl, + v, + node); + } + } + + + // + // ComponentDecl + // + + void ComponentDecl:: + accept (CCF::Traversal::Visitor* v) + { + ComponentDeclPtr self (ReferenceCounting::add_ref (this)); + + try_visit_component_decl (v, self); + } + + // + // ComponentForwardDecl + // + + void ComponentForwardDecl:: + accept (CCF::Traversal::Visitor* v) + { + } + + // + // ComponentDef + // + + void ComponentDef:: + accept (CCF::Traversal::Visitor* v) + { + ComponentDefPtr self (ReferenceCounting::add_ref (this)); + + if(!try_visit<Traversal::ComponentDef> ( + &Traversal::ComponentDef::visit_component_def, + v, + self)) + { + try_visit_component_decl (v, self); + try_visit_scope (v, self); + } + } + + // + // ProvidesDecl + // + + void ProvidesDecl:: + accept (CCF::Traversal::Visitor* v) + { + ProvidesDeclPtr self (ReferenceCounting::add_ref (this)); + try_visit<Traversal::ProvidesDecl> ( + &Traversal::ProvidesDecl::visit_provides_decl, + v, + self); + } + + // + // UsesDecl + // + + void UsesDecl:: + accept (CCF::Traversal::Visitor* v) + { + UsesDeclPtr self (ReferenceCounting::add_ref (this)); + try_visit<Traversal::UsesDecl> ( + &Traversal::UsesDecl::visit_uses_decl, + v, + self); + } + + // + // PublishesDecl + // + + void PublishesDecl:: + accept (CCF::Traversal::Visitor* v) + { + PublishesDeclPtr self (ReferenceCounting::add_ref (this)); + try_visit<Traversal::PublishesDecl> ( + &Traversal::PublishesDecl::visit_publishes_decl, + v, + self); + } + + // + // EmitsDecl + // + + void EmitsDecl:: + accept (CCF::Traversal::Visitor* v) + { + EmitsDeclPtr self (ReferenceCounting::add_ref (this)); + try_visit<Traversal::EmitsDecl> ( + &Traversal::EmitsDecl::visit_emits_decl, + v, + self); + } + + // + // ConsumesDecl + // + + void ConsumesDecl:: + accept (CCF::Traversal::Visitor* v) + { + ConsumesDeclPtr self (ReferenceCounting::add_ref (this)); + try_visit<Traversal::ConsumesDecl> ( + &Traversal::ConsumesDecl::visit_consumes_decl, + v, + self); + } + + + // + // HomeDef + // + + void HomeDef:: + accept (CCF::Traversal::Visitor* v) + { + HomeDefPtr self (ReferenceCounting::add_ref (this)); + + if(!try_visit<Traversal::HomeDef> ( + &Traversal::HomeDef::visit_home_def, + v, + self)) + { + try_visit_scope (v, self); + } + } + + // + // HomeFactoryDecl + // + + void HomeFactoryDecl:: + accept (CCF::Traversal::Visitor* v) + { + HomeFactoryDeclPtr self (ReferenceCounting::add_ref (this)); + + if(!try_visit<Traversal::HomeFactoryDecl> ( + &Traversal::HomeFactoryDecl::visit_home_factory_decl, + v, + self)) + { + try_visit<Traversal::OperationDecl> ( + &Traversal::OperationDecl::visit_operation_decl, + v, + self); + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTree.hpp b/TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTree.hpp new file mode 100644 index 00000000000..2ea652787c5 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTree.hpp @@ -0,0 +1,627 @@ +// $Id$ +#ifndef CCF_IDL3_SYNTAX_TREE_HPP +#define CCF_IDL3_SYNTAX_TREE_HPP + +#include "MSVC_Pragmas.hpp" + +#include "CCF/IDL2/IDL2_SyntaxTree.hpp" + +namespace IDL3 +{ + namespace SyntaxTree + { + // Import nodes from IDL2 + using namespace IDL2::SyntaxTree; + + + // + // + // + class ComponentDecl : public virtual TypeDecl + { + public: + virtual + ~ComponentDecl () throw () {} + + ComponentDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope) + { + } + + // Runtime declaration type information + public: + virtual std::string + declaration_type () + { + return "component"; + } + + + // Traversal + public: + virtual void + accept (CCF::Traversal::Visitor* v); + }; + + typedef + StrictPtr<ComponentDecl> + ComponentDeclPtr; + + typedef + DeclarationRef<ComponentDecl> + ComponentDeclRef; + + + // + // + // + class ComponentForwardDecl : public virtual ComponentDecl, + public virtual TypeForwardDecl + { + public: + virtual + ~ComponentForwardDecl () throw () {} + + ComponentForwardDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + ComponentDecl (name, scope), + TypeForwardDecl (name, scope) + { + } + + // Runtime declaration type information + public: + virtual std::string + declaration_type () + { + return "component"; + } + + + // Traversal + public: + virtual void + accept (CCF::Traversal::Visitor* v); + }; + + + + // + // + // + class ComponentDef; + + typedef + StrictPtr<ComponentDef> + ComponentDefPtr; + + typedef + DeclarationRef<ComponentDef> + ComponentDefRef; + + class ComponentDef : public virtual TypeDef, + public virtual ComponentDecl, + public virtual Scope + { + public: + virtual + ~ComponentDef () throw () {} + + class DuplicateName {}; + + ComponentDef (SimpleName const& name, + ScopePtr const& scope, + ScopedName const& inherits, + ScopedNameSet const& supports) throw (DuplicateName) + : Declaration (name, scope), + TypeDecl (name, scope), + TypeDef (name, scope), + ComponentDecl (name, scope), + Scope (name, scope), + inherits_ (scope->table (), inherits) + { + copy_supports_list (supports); + } + + ComponentDef (SimpleName const& name, + ScopePtr const& scope, + ScopedNameSet const& supports) throw (DuplicateName) + : Declaration (name, scope), + TypeDecl (name, scope), + TypeDef (name, scope), + ComponentDecl (name, scope), + Scope (name, scope), + inherits_ (scope->table ()) + { + copy_supports_list (supports); + } + + private: + void + copy_supports_list (ScopedNameSet const& supports) + { + for (ScopedNameSet::const_iterator i = supports.begin (); + i != supports.end (); + i++) + { + if (!supports_.insert ( + InterfaceDefRef (scope ()->table (), *i)).second) + { + //@@ this never happens + throw DuplicateName (); + } + } + } + + + public: + ComponentDefRef + inherits () + { + return inherits_; + } + + + public: + + typedef + InterfaceDefRefSetName::const_iterator + Iterator; + + Iterator + supports_begin () const + { + return supports_.begin (); + } + + Iterator + supports_end () const + { + return supports_.end (); + } + + // Traversal + public: + virtual void + accept (CCF::Traversal::Visitor* v); + + // Runtime declaration type information + public: + virtual std::string + declaration_type () + { + return "component"; + } + + private: + ComponentDefRef inherits_; + InterfaceDefRefSetName supports_; + }; + + typedef + DeclarationOrderComparator<ComponentDefPtr> + ComponentDefOrderComparator; + + typedef + std::set<ComponentDefPtr, ComponentDefOrderComparator> + ComponentDefSet; + + // + // + // + class ProvidesDecl : public virtual Declaration + { + public: + virtual + ~ProvidesDecl () throw () {} + + ProvidesDecl (SimpleName const& name, + ScopedName const& type, + ScopePtr const& scope) + : Declaration (name, scope), + type_ (scope->table (), type) + { + } + + public: + InterfaceDeclPtr + type () + { + return type_.resolve (); + } + + + // Runtime declaration type information + public: + virtual std::string + declaration_type () + { + return "provides"; + } + + // Traversal + public: + virtual void + accept (CCF::Traversal::Visitor* v); + + private: + InterfaceDeclRef type_; + }; + + + // + // + // + class UsesDecl : public virtual Declaration + { + public: + virtual + ~UsesDecl () throw () {} + + UsesDecl (SimpleName const& name, + ScopedName const& type, + ScopePtr const& scope) + : Declaration (name, scope), + type_ (scope->table (), type) + + { + } + + public: + TypeDeclPtr + type () + { + return type_.resolve (); + } + + + // Runtime declaration type information + public: + virtual std::string + declaration_type () + { + return "uses"; + } + + // Traversal + public: + virtual void + accept (CCF::Traversal::Visitor* v); + + private: + TypeDeclRef type_; + }; + + + // + // + // + class PublishesDecl : public virtual Declaration + { + public: + virtual + ~PublishesDecl () throw () {} + + PublishesDecl (SimpleName const& name, + ScopedName const& type, + ScopePtr const& scope) + : Declaration (name, scope), + type_ (scope->table (), type) + { + } + + public: + TypeDeclPtr + type () + { + return type_.resolve (); + } + + + // Runtime declaration type information + public: + virtual std::string + declaration_type () + { + return "publishes"; + } + + // Traversal + public: + virtual void + accept (CCF::Traversal::Visitor* v); + + private: + TypeDeclRef type_; + }; + + + // + // + // + class EmitsDecl : public virtual Declaration + { + public: + virtual + ~EmitsDecl () throw () {} + + EmitsDecl (SimpleName const& name, + ScopedName const& type, + ScopePtr const& scope) + : Declaration (name, scope), + type_ (scope->table (), type) + { + } + + public: + TypeDeclPtr + type () + { + return type_.resolve (); + } + + + // Runtime declaration type information + public: + virtual std::string + declaration_type () + { + return "emits"; + } + + // Traversal + public: + virtual void + accept (CCF::Traversal::Visitor* v); + + private: + TypeDeclRef type_; + }; + + + // + // + // + class ConsumesDecl : public virtual Declaration + { + public: + virtual + ~ConsumesDecl () throw () {} + + ConsumesDecl (SimpleName const& name, + ScopedName const& type, + ScopePtr const& scope) + : Declaration (name, scope), + type_ (scope->table (), type) + { + } + + public: + TypeDeclPtr + type () + { + return type_.resolve (); + } + + + // Runtime declaration type information + public: + virtual std::string + declaration_type () + { + return "consumes"; + } + + // Traversal + public: + virtual void + accept (CCF::Traversal::Visitor* v); + + private: + TypeDeclRef type_; + }; + + + + // According to the spec Home cannot be forward-declared. Did they + // goof again? - you would probably think... + // + + class HomeDef; + + typedef + StrictPtr<HomeDef> + HomeDefPtr; + + typedef + DeclarationRef<HomeDef> + HomeDefRef; + + class HomeDef : public virtual TypeDef, + public virtual Scope + { + public: + virtual + ~HomeDef () throw () {} + + class DuplicateName {}; + + HomeDef (SimpleName const& name, + ScopePtr const& scope, + ScopedName const& inherits, + ScopedNameSet const& supports, + ScopedName const& manages) throw (DuplicateName) + + : Declaration (name, scope), + TypeDecl (name, scope), + TypeDef (name, scope), + Scope (name, scope), + inherits_ (scope->table (), inherits), + manages_ (scope->table (), manages) + { + copy_supports_list (supports); + } + + HomeDef (SimpleName const& name, + ScopePtr const& scope, + ScopedNameSet const& supports, + ScopedName const& manages) throw (DuplicateName) + + : Declaration (name, scope), + TypeDecl (name, scope), + TypeDef (name, scope), + Scope (name, scope), + inherits_ (scope->table ()), + manages_ (scope->table (), manages) + { + copy_supports_list (supports); + } + + private: + void + copy_supports_list (ScopedNameSet const& supports) + { + for (ScopedNameSet::const_iterator i = supports.begin (); + i != supports.end (); + i++) + { + if (!supports_.insert ( + InterfaceDefRef (scope ()->table (), *i)).second) + { + //@@ this never happens + throw DuplicateName (); + } + } + } + + public: + HomeDefRef + inherits () + { + return inherits_; + } + + public: + typedef + InterfaceDefRefSetName::const_iterator + Iterator; + + Iterator + supports_begin () + { + return supports_.begin (); + } + + Iterator + supports_end () + { + return supports_.end (); + } + + public: + ComponentDefPtr + manages () const + { + return manages_.resolve (); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_type () + { + return "home"; + } + + // Traversal + public: + virtual void + accept (CCF::Traversal::Visitor* v); + + private: + HomeDefRef inherits_; + InterfaceDefRefSetName supports_; + ComponentDefRef manages_; + }; + + typedef + DeclarationOrderComparator<HomeDefPtr> + HomeDefOrderComparator; + + typedef + std::set<HomeDefPtr, HomeDefOrderComparator> + HomeDefSet; + + + // + // + // + class HomeFactoryParameter : public virtual OperationParameter + { + public: + virtual + ~HomeFactoryParameter () throw () + { + } + + HomeFactoryParameter (ScopedName type, + SimpleName name, + DeclarationTable const& table) + : OperationParameter (Direction::IN, type, name, table) + { + } + }; + + typedef + StrictPtr<HomeFactoryParameter> + HomeFactoryParameterPtr; + + // + // + // + class HomeFactoryDecl : public virtual OperationDecl + { + public: + virtual + ~HomeFactoryDecl () throw () {} + + HomeFactoryDecl (SimpleName const& name, + ScopedName const& type, + ScopePtr const& scope) + : Declaration (name, scope), + OperationDecl (name, type, scope) + { + } + + //@@ It would be nice to be able to kind of virtual override + // type () mf from OperationDecl with covariant return type + // technique. + + + // Runtime declaration type information + public: + virtual std::string + declaration_type () + { + return "home factory"; + } + + // Traversal + public: + virtual void + accept (CCF::Traversal::Visitor* v); + }; + typedef + StrictPtr<HomeFactoryDecl> + HomeFactoryDeclPtr; + } +} + +//@@ tmp +#include "CCF/IDL3/IDL3_SyntaxTree_EventType.hpp" + +#endif // CCF_IDL3_SYNTAX_TREE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTreeFwd.hpp b/TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTreeFwd.hpp new file mode 100644 index 00000000000..d581ad0daa5 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTreeFwd.hpp @@ -0,0 +1,69 @@ +// $Id$ +#ifndef CCF_IDL3_SYNTAX_TREE_FWD_HPP +#define CCF_IDL3_SYNTAX_TREE_FWD_HPP + +#include "MSVC_Pragmas.hpp" + +#include "CCF/IDL2/IDL2_SyntaxTreeFwd.hpp" + +namespace IDL3 +{ + namespace SyntaxTree + { + // Import all nodes of IDL2 + using namespace IDL2::SyntaxTree; + + class ComponentDecl; + typedef + StrictPtr<ComponentDecl> + ComponentDeclPtr; + + class ComponentDef; + typedef + StrictPtr<ComponentDef> + ComponentDefPtr; + + class ProvidesDecl; + typedef + StrictPtr<ProvidesDecl> + ProvidesDeclPtr; + + class UsesDecl; + typedef + StrictPtr<UsesDecl> + UsesDeclPtr; + + class PublishesDecl; + typedef + StrictPtr<PublishesDecl> + PublishesDeclPtr; + + class EmitsDecl; + typedef + StrictPtr<EmitsDecl> + EmitsDeclPtr; + + class ConsumesDecl; + typedef + StrictPtr<ConsumesDecl> + ConsumesDeclPtr; + + class HomeDef; + typedef + StrictPtr<HomeDef> + HomeDefPtr; + + class HomeFactoryDecl; + typedef + StrictPtr<HomeFactoryDecl> + HomeFactoryDeclPtr; + + //@@ should it be here or in separate file? + class ConcreteEventTypeDef; + typedef + StrictPtr<ConcreteEventTypeDef> + ConcreteEventTypeDefPtr; + } +} + +#endif // CCF_IDL3_SYNTAX_TREE_FWD_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTree_EventType.cpp b/TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTree_EventType.cpp new file mode 100644 index 00000000000..bd8ad6e7186 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTree_EventType.cpp @@ -0,0 +1,22 @@ +// $Id$ +#include "IDL3_Traversal.hpp" +#include "IDL3_SyntaxTree_EventType.hpp" + +namespace IDL3 +{ + namespace SyntaxTree + { + using CCF::Traversal::try_visit; + + void ConcreteEventTypeDef:: + accept (CCF::Traversal::Visitor* v) + { + ConcreteEventTypeDefPtr self (ReferenceCounting::add_ref (this)); + + try_visit<Traversal::ConcreteEventTypeDef> ( + &Traversal::ConcreteEventTypeDef::visit_concrete_event_type_def, + v, + self); + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTree_EventType.hpp b/TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTree_EventType.hpp new file mode 100644 index 00000000000..ff8004c7829 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/IDL3_SyntaxTree_EventType.hpp @@ -0,0 +1,215 @@ +// $Id$ +#ifndef CCF_IDL3_SYNTAX_TREE_VALUE_HPP +#define CCF_IDL3_SYNTAX_TREE_VALUE_HPP + +#include "MSVC_Pragmas.hpp" + +#include "CCF/IDL2/IDL2_SyntaxTree_Value.hpp" + +namespace IDL3 +{ + namespace SyntaxTree + { + // Import nodes from IDL2 + using namespace IDL2::SyntaxTree; + + // + // + // + class EventTypeDecl : public virtual ValueDecl + { + public: + virtual + ~EventTypeDecl () throw () {} + + EventTypeDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + ValueDecl (name, scope) + { + } + + // Runtime declaration type information + public: + virtual std::string + declaration_type () + { + return "event type"; + } + + // Traversal + public: + virtual void + accept (CCF::Traversal::Visitor* v) + { + } + + }; + + typedef + StrictPtr<EventTypeDecl> + EventTypeDeclPtr; + + + // + // + // + class EventTypeForwardDecl : public virtual ValueForwardDecl, + public virtual EventTypeDecl + { + public: + virtual + ~EventTypeForwardDecl () throw () {} + + EventTypeForwardDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + ValueDecl (name, scope), + TypeForwardDecl (name, scope), + ValueForwardDecl (name, scope), + EventTypeDecl (name, scope) + { + } + + // Runtime declaration type information + public: + virtual std::string + declaration_type () + { + return "event type"; + } + }; + + // + // + // + class EventTypeDef : public virtual EventTypeDecl, + public virtual ValueDef + { + public: + virtual + ~EventTypeDef () throw () {} + + EventTypeDef (SimpleName const& name, + ScopePtr const& scope, + ScopedNameSet const& inherits) + : Declaration (name, scope), + TypeDecl (name, scope), + ValueDecl (name, scope), + EventTypeDecl (name, scope), + TypeDef (name, scope), + Scope (name, scope), + ValueDef (name, scope, inherits) + { + } + + // Runtime declaration type information + public: + virtual std::string + declaration_type () + { + return "event type"; + } + + // Traversal + public: + virtual void + accept (CCF::Traversal::Visitor* v) + { + } + + }; + + + // + // + // + class ConcreteEventTypeDecl : public virtual EventTypeDecl + { + public: + virtual + ~ConcreteEventTypeDecl () throw () {} + + ConcreteEventTypeDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + ValueDecl (name, scope), + EventTypeDecl (name, scope) + { + } + + // Runtime declaration type information + public: + virtual std::string + declaration_type () + { + return "concrete event type"; + } + + // Traversal + public: + virtual void + accept (CCF::Traversal::Visitor* v) + { + } + + }; + + + // + // + // + class ConcreteEventTypeDef : public virtual ConcreteEventTypeDecl, + public virtual EventTypeDef + { + public: + virtual + ~ConcreteEventTypeDef () throw () {} + + ConcreteEventTypeDef (SimpleName const& name, + ScopePtr const& scope, + ScopedNameSet const& inherits) + : Declaration (name, scope), + TypeDecl (name, scope), + ValueDecl (name, scope), + EventTypeDecl (name, scope), + ConcreteEventTypeDecl (name, scope), + TypeDef (name, scope), + Scope (name, scope), + ValueDef (name, scope, inherits), + EventTypeDef (name, scope, inherits) + { + } + + // Runtime declaration type information + public: + virtual std::string + declaration_type () + { + return "concrete event type"; + } + + // Traversal + public: + virtual void + accept (CCF::Traversal::Visitor* v); + }; + + typedef + StrictPtr<ConcreteEventTypeDef> + ConcreteEventTypeDefPtr; + + typedef + DeclarationOrderComparator<ConcreteEventTypeDefPtr> + ConcreteEventTypeDefOrderComparator; + + typedef + std::set<ConcreteEventTypeDefPtr, ConcreteEventTypeDefOrderComparator> + ConcreteEventTypeDefSet; + } +} + +#endif // CCF_IDL3_SYNTAX_TREE_VALUE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/IDL3_Traversal.cpp b/TAO/CIAO/CCF/CCF/IDL3/IDL3_Traversal.cpp new file mode 100644 index 00000000000..a69e74b54ff --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/IDL3_Traversal.cpp @@ -0,0 +1,184 @@ +// $Id$ +#include "IDL3_Traversal.hpp" + +#include "IDL3_SyntaxTree.hpp" +#include "IDL3_SyntaxTree_EventType.hpp" + +namespace IDL3 +{ + namespace Traversal + { + namespace + { + //@@ code duplication + void + iterate_scope (SyntaxTree::ScopePtr const& s, + CCF::Traversal::Visitor* v) + { + for (SyntaxTree::Scope::Iterator i = s->begin (); i != s->end (); i++) + { + (*i)->accept (v); + } + } + } + + // + // ComponentDecl + // + + void ComponentDecl:: + visit_component_decl (NodePtr const& c) + { + visit_component_decl_pre (c); + visit_component_decl_post (c); + } + + + void ComponentDecl:: + visit_component_decl_pre (NodePtr const&) + { + } + + void ComponentDecl:: + visit_component_decl_post (NodePtr const&) + { + } + + // + // ComponentDef + // + + void ComponentDef:: + visit_component_def (NodePtr const& c) + { + visit_component_def_pre (c); + visit_component_def_scope (c); + visit_component_def_post (c); + } + + + void ComponentDef:: + visit_component_def_pre (NodePtr const&) + { + } + + void ComponentDef:: + visit_component_def_scope (NodePtr const& c) + { + iterate_scope (c, this); + } + + void ComponentDef:: + visit_component_def_post (NodePtr const&) + { + } + + // + // HomeDef + // + + void HomeDef:: + visit_home_def (NodePtr const& h) + { + visit_home_def_pre (h); + visit_home_def_scope (h); + visit_home_def_post (h); + } + + void HomeDef:: + visit_home_def_pre (NodePtr const&) + { + } + + void HomeDef:: + visit_home_def_scope (NodePtr const& h) + { + iterate_scope (h, this); + } + + void HomeDef:: + visit_home_def_post (NodePtr const&) + { + } + + // + // HomeFactoryDecl + // + void HomeFactoryDecl:: + visit_home_factory_decl (NodePtr const& n) + { + visit_home_factory_decl_pre (n); + visit_home_factory_decl_type (n); + visit_home_factory_decl_name (n); + visit_home_factory_decl_parameters (n); + visit_home_factory_decl_post (n); + } + + void HomeFactoryDecl:: + visit_home_factory_decl_pre (NodePtr const& n) + { + } + + void HomeFactoryDecl:: + visit_home_factory_decl_type (NodePtr const& n) + { + if (type_) n->type ()->accept (type_); + else n->type ()->accept (this); + } + + void HomeFactoryDecl:: + visit_home_factory_decl_name (NodePtr const& n) + { + } + + void HomeFactoryDecl:: + visit_home_factory_decl_parameters (NodePtr const& n) + { + for (SyntaxTree::HomeFactoryDecl::Iterator i = n->begin (); + i != n->end (); + i++) + { + (*i)->accept (this); + + if (i + 1 != n->end ()) + { + //@@ could be HomeFactoryParameterComma + SyntaxTree::CommaPtr c (new SyntaxTree::Comma); + c->accept (this); + } + } + } + + void HomeFactoryDecl:: + visit_home_factory_decl_post (NodePtr const& n) + { + } + + // ConcreteEventTypeDef + // + // + void ConcreteEventTypeDef:: + visit_concrete_event_type_def (NodePtr const& et) + { + visit_concrete_event_type_def_pre (et); + visit_concrete_event_type_def_scope (et); + visit_concrete_event_type_def_post (et); + } + + void ConcreteEventTypeDef:: + visit_concrete_event_type_def_pre (NodePtr const&) + { + } + + void ConcreteEventTypeDef:: + visit_concrete_event_type_def_scope (NodePtr const& et) + { + iterate_scope (et, this); + } + + void ConcreteEventTypeDef:: + visit_concrete_event_type_def_post (NodePtr const&) + { + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/IDL3_Traversal.hpp b/TAO/CIAO/CCF/CCF/IDL3/IDL3_Traversal.hpp new file mode 100644 index 00000000000..0b4b53c5ed1 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/IDL3_Traversal.hpp @@ -0,0 +1,175 @@ +// $Id$ +#ifndef CCF_IDL3_TRAVERSAL_HPP +#define CCF_IDL3_TRAVERSAL_HPP + +#include "MSVC_Pragmas.hpp" + +#include "CCF/IDL2/IDL2_Traversal.hpp" +#include "CCF/IDL3/IDL3_SyntaxTreeFwd.hpp" + +namespace IDL3 +{ + namespace Traversal + { + // Import visitors from IDL2 + using namespace IDL2::Traversal; + + // + // + // + struct ComponentDecl : virtual CCF::Traversal::Visitor + { + typedef + SyntaxTree::ComponentDeclPtr + NodePtr; + + virtual void visit_component_decl (NodePtr const& c); + virtual void visit_component_decl_pre (NodePtr const& c); + virtual void visit_component_decl_post (NodePtr const& c); + }; + + // + // + // + struct ComponentDef : virtual CCF::Traversal::Visitor + { + typedef + SyntaxTree::ComponentDefPtr + NodePtr; + + virtual void visit_component_def (NodePtr const& c); + virtual void visit_component_def_pre (NodePtr const& c); + virtual void visit_component_def_scope (NodePtr const& c); + virtual void visit_component_def_post (NodePtr const& c); + }; + + // + // + // + struct ProvidesDecl : virtual CCF::Traversal::Visitor + { + typedef + SyntaxTree::ProvidesDeclPtr + NodePtr; + + virtual void visit_provides_decl (NodePtr const& c) + { + } + }; + + // + // + // + struct UsesDecl : virtual CCF::Traversal::Visitor + { + typedef + SyntaxTree::UsesDeclPtr + NodePtr; + + virtual void visit_uses_decl (NodePtr const& c) + { + } + }; + + // + // + // + struct PublishesDecl : virtual CCF::Traversal::Visitor + { + typedef + SyntaxTree::PublishesDeclPtr + NodePtr; + + virtual void visit_publishes_decl (NodePtr const& c) + { + } + }; + + // + // + // + struct EmitsDecl : virtual CCF::Traversal::Visitor + { + typedef + SyntaxTree::EmitsDeclPtr + NodePtr; + + virtual void visit_emits_decl (NodePtr const& c) + { + } + }; + + // + // + // + struct ConsumesDecl : virtual CCF::Traversal::Visitor + { + typedef + SyntaxTree::ConsumesDeclPtr + NodePtr; + + virtual void visit_consumes_decl (NodePtr const& c) + { + } + }; + + // + // + // + struct HomeDef : virtual CCF::Traversal::Visitor + { + typedef + SyntaxTree::HomeDefPtr + NodePtr; + + virtual void visit_home_def (NodePtr const& h); + virtual void visit_home_def_pre (NodePtr const& h); + virtual void visit_home_def_scope (NodePtr const& h); + virtual void visit_home_def_post (NodePtr const& h); + + }; + + // + // + // + struct HomeFactoryDecl : virtual CCF::Traversal::Visitor + { + typedef + SyntaxTree::HomeFactoryDeclPtr + NodePtr; + + HomeFactoryDecl (CCF::Traversal::Visitor* type = 0) + : type_ (type) + { + } + + virtual void visit_home_factory_decl (NodePtr const& n); + + virtual void visit_home_factory_decl_pre (NodePtr const& n); + virtual void visit_home_factory_decl_type (NodePtr const& n); + virtual void visit_home_factory_decl_name (NodePtr const& n); + virtual void visit_home_factory_decl_parameters (NodePtr const& n); + virtual void visit_home_factory_decl_post (NodePtr const& n); + + private: + CCF::Traversal::Visitor* type_; + }; + + // + // + // + struct ConcreteEventTypeDef : virtual CCF::Traversal::Visitor + { + typedef + SyntaxTree::ConcreteEventTypeDefPtr + NodePtr; + + virtual void visit_concrete_event_type_def (NodePtr const& et); + virtual void visit_concrete_event_type_def_pre (NodePtr const& et); + virtual void visit_concrete_event_type_def_scope (NodePtr const& et); + virtual void visit_concrete_event_type_def_post (NodePtr const& et); + }; + } +} + +#endif // CCF_IDL3_TRAVERSAL_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/MSVC_Pragmas.hpp b/TAO/CIAO/CCF/CCF/IDL3/MSVC_Pragmas.hpp new file mode 100644 index 00000000000..724b5b52646 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/MSVC_Pragmas.hpp @@ -0,0 +1,16 @@ +// $Id$ +#ifndef MSVC_PRAGMAS_HPP +#define MSVC_PRAGMAS_HPP + + +// Various warnings that have to be disabled for MSVC. + +// 'this' : used in base member initializer list +#pragma warning(disable:4355) +// 'class1' : inherits 'class2::member' via dominance +#pragma warning(disable:4250) +// C++ Exception Specification ignored +#pragma warning(disable:4290) + + +#endif /* MSVC_PRAGMAS_HPP */
\ No newline at end of file diff --git a/TAO/CIAO/CCF/CCF/IDL3/Makefile b/TAO/CIAO/CCF/CCF/IDL3/Makefile new file mode 100644 index 00000000000..6222a052c9a --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Makefile @@ -0,0 +1,22 @@ +# File : Makefile +# Author : Boris Kolpackov <boris@kolpackov.net> +# $Id$ + +root = ../../External/Utility + +include $(root)/Config/Archive.pre.rules + +cxx_translation_units := IDL3.cpp \ + IDL3_SyntaxTree.cpp \ + IDL3_SyntaxTree_EventType.cpp \ + IDL3_Traversal.cpp + +module_base := IDL3 +module_prefix := +module_suffix := + +CXX_PREPROCESS_FLAGS += -I../.. \ + -I../../External/Utility \ + -I../../External/boost \ + +include $(root)/Config/Archive.post.rules |