diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-04-09 04:16:31 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-04-09 04:16:31 +0000 |
commit | 048d7a48856abad74e03274aca6e58340c194be5 (patch) | |
tree | 7c3046e373150ddafc2eaa1adaca8c06fbb5d3aa | |
parent | a21e48fceea003c95065386089ae4d6143271c64 (diff) | |
download | ATCD-048d7a48856abad74e03274aca6e58340c194be5.tar.gz |
ChangeLogTag: Tue Apr 8 23:10:43 2003 Jeff Parsons <j.parsons@vanderbilt.edu>
18 files changed, 2742 insertions, 0 deletions
diff --git a/TAO/CIAO/CIDLC/parser_examples/README b/TAO/CIAO/CIDLC/parser_examples/README new file mode 100644 index 00000000000..cc00d62d27c --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/README @@ -0,0 +1,52 @@ +// $Id$ + + Parser Examples + +This directory contains examples of a (C)IDL parser hierarchy using Spirit. Each +example (IDL2, IDL3 and CIDL) is in its own directory and has its own test file. +The Spirit files (these examples were compiled using Spirit 1.6.0) should be +unpacked so the directory spirit-1.6.0 is in the CIDLC directory. The builds +include too many files from Spirit to check them into the respository individually, +at least right now, but it is easy enough to download Spirit and unpack it. It +can be obtained at + +http://spirit.sourceforge.net/ + +Spirit 1.6.0 can be downloaded along with the necessary parts of Boost 1.30.0. + +All I have at the moment are MSVC 7.1 solution and project files. Makefiles will +be forthcoming, or interested parties can contribute them ;-). Uncommenting + +#define SPIRIT_DEBUG + +at the top of any driver file and recompiling will cause debug info to be +generated as the test file is parsed. + +Each grammar file embeds the one it is a superset of. Some rules are overridden +in the superset grammar as necessary. As Boris suggests, we could create members +in superset grammars that are assigned references to rules from subset grammars, +thus enabling us to eliminate constructs like + +idl3.idl2.* + +and so forth, although I think it may be informative sometimes to see at a +glance which grammar a rule originates from. It will also be possible to +compile each grammar into a DLL, but so much of the code is template-based that +I'm not sure it will be worth it. I welcome suggestions and opinions about these +issues. + +The CIDL grammar is incomplete, including only the rules underneath +'composition'. We are using at present a much smaller subset than that, but it +was convenient to implement composition's subrules down to the terminals. + +The IDL2 grammar header file contains a simple utility parse() method derived +from the Spirit C grammar example. There is also a simple grammar for skipping +whitespace and comments, as well as #line and #pragma directives. All of these +features will need to be made more industrial-strength, and of course there +are many additional features that will need to be added - #includes, +error processing, etc. etc. + + +Jeff Parsons + +4/8/03
\ No newline at end of file diff --git a/TAO/CIAO/CIDLC/parser_examples/cidl/cidl.cpp b/TAO/CIAO/CIDLC/parser_examples/cidl/cidl.cpp new file mode 100644 index 00000000000..128ce40bd23 --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/cidl/cidl.cpp @@ -0,0 +1,29 @@ +// $Id$ + +#if defined(_DEBUG) +//#define SPIRIT_DEBUG +#endif // defined(_DEBUG) + +#include "cidl_grammar.h" + +int +main (int argc, char* argv[]) +{ +// Start grammar definition + cerr << "CIDL Grammar checker implemented with Spirit ..." << endl; + +// main driver code +cidl_grammar g; + + if (2 == argc) + { + parse (g, + argv[1]); + } + else + { + cerr << "No filename given" << endl; + } + + return 0; +} diff --git a/TAO/CIAO/CIDLC/parser_examples/cidl/cidl.vcproj b/TAO/CIAO/CIDLC/parser_examples/cidl/cidl.vcproj new file mode 100644 index 00000000000..ecaac64811f --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/cidl/cidl.vcproj @@ -0,0 +1,145 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="cidl" + ProjectGUID="{8059742C-5DA9-4318-8D04-7938CBB0D538}" + Keyword="Win32Proj"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="Debug" + IntermediateDirectory="Debug" + ConfigurationType="1" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..,..\..\spirit-1.6.0,..\..\spirit-1.6.0\miniboost" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="TRUE" + BasicRuntimeChecks="0" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="FALSE" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/cidl.exe" + LinkIncremental="2" + GenerateDebugInformation="TRUE" + ProgramDatabaseFile="$(OutDir)/cidl.pdb" + SubSystem="1" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="1" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="4" + UsePrecompiledHeader="3" + WarningLevel="3" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/cidl.exe" + LinkIncremental="1" + GenerateDebugInformation="TRUE" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <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=".\cidl.cpp"> + </File> + <File + RelativePath=".\cidl_grammar.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> + <File + RelativePath=".\cidl_grammar.h"> + </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> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/TAO/CIAO/CIDLC/parser_examples/cidl/cidl_grammar.cpp b/TAO/CIAO/CIDLC/parser_examples/cidl/cidl_grammar.cpp new file mode 100644 index 00000000000..67577d5d1c6 --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/cidl/cidl_grammar.cpp @@ -0,0 +1,309 @@ +// $Id$ + +#include "../idl3/idl3_grammar.cpp" + +#ifndef CIDL_GRAMMAR_C +#define CIDL_GRAMMAR_C + +template<typename ScannerT> +rule<ScannerT> const & +cidl_grammar::definition<ScannerT>::start (void) const +{ + return specification; +} + +template<typename ScannerT> +cidl_grammar::definition<ScannerT>::definition ( + cidl_grammar const & self + ) + : idl3 (self.idl3_g), + DOT ('.') +{ + keywords = + "composition", "entity", "process", "service", "session", + "catalog", "executor", "implements", "bindsTo", "storedOn", + "segment", "facet", "delegatesTo", "storage", "storagehome", + "proxy"; + + CIDL_COMPOSITION = strlit<>("composition"); + CIDL_ENTITY = strlit<>("entity"); + CIDL_PROCESS = strlit<>("process"); + CIDL_SERVICE = strlit<>("service"); + CIDL_SESSION = strlit<>("session"); + CIDL_CATALOG = strlit<>("catalog"); + CIDL_EXECUTOR = strlit<>("executor"); + CIDL_IMPLEMENTS = strlit<>("implements"); + CIDL_BINDS_TO = strlit<>("bindsTo"); + CIDL_STORED_ON = strlit<>("storedOn"); + CIDL_SEGMENT = strlit<>("segment"); + CIDL_FACET = strlit<>("facet"); + CIDL_DELEGATES_TO = strlit<>("delegatesTo"); + CIDL_STORAGE = strlit<>("storage"); + CIDL_STORAGEHOME = strlit<>("storagehome"); + CIDL_PROXY = strlit<>("proxy"); + + idl3.idl2.IDENTIFIER = + lexeme_d + [ + ((alpha_p | '_') >> *(alnum_p | '_')) + - (idl3.idl2.keywords >> anychar_p - (alnum_p | '_')) + - (idl3.keywords >> anychar_p - (alnum_p | '_')) + - (this->keywords >> anychar_p - (alnum_p | '_')) + ] + ; + + BOOST_SPIRIT_DEBUG_RULE (CIDL_COMPOSITION); + BOOST_SPIRIT_DEBUG_RULE (CIDL_ENTITY); + BOOST_SPIRIT_DEBUG_RULE (CIDL_PROCESS); + BOOST_SPIRIT_DEBUG_RULE (CIDL_SERVICE); + BOOST_SPIRIT_DEBUG_RULE (CIDL_SESSION); + BOOST_SPIRIT_DEBUG_RULE (CIDL_CATALOG); + BOOST_SPIRIT_DEBUG_RULE (CIDL_EXECUTOR); + BOOST_SPIRIT_DEBUG_RULE (CIDL_IMPLEMENTS); + BOOST_SPIRIT_DEBUG_RULE (CIDL_BINDS_TO); + BOOST_SPIRIT_DEBUG_RULE (CIDL_STORED_ON); + BOOST_SPIRIT_DEBUG_RULE (CIDL_SEGMENT); + BOOST_SPIRIT_DEBUG_RULE (CIDL_FACET); + BOOST_SPIRIT_DEBUG_RULE (CIDL_DELEGATES_TO); + BOOST_SPIRIT_DEBUG_RULE (CIDL_STORAGE); + BOOST_SPIRIT_DEBUG_RULE (CIDL_STORAGEHOME); + BOOST_SPIRIT_DEBUG_RULE (CIDL_PROXY); + + BOOST_SPIRIT_DEBUG_RULE (specification); + BOOST_SPIRIT_DEBUG_RULE (composition); + BOOST_SPIRIT_DEBUG_RULE (category); + BOOST_SPIRIT_DEBUG_RULE (composition_body); + BOOST_SPIRIT_DEBUG_RULE (catalog_use_dcl); + BOOST_SPIRIT_DEBUG_RULE (home_executor_def); + BOOST_SPIRIT_DEBUG_RULE (proxy_home_def); + BOOST_SPIRIT_DEBUG_RULE (catalog_dcl); + BOOST_SPIRIT_DEBUG_RULE (catalog_type_spec); + BOOST_SPIRIT_DEBUG_RULE (catalog_label); + BOOST_SPIRIT_DEBUG_RULE (home_executor_body); + BOOST_SPIRIT_DEBUG_RULE (home_impl_dcl); + BOOST_SPIRIT_DEBUG_RULE (abstract_storage_home_binding); + BOOST_SPIRIT_DEBUG_RULE (stored_on_dcl); + BOOST_SPIRIT_DEBUG_RULE (executor_def); + BOOST_SPIRIT_DEBUG_RULE (abstract_storage_home_delegation_spec); + BOOST_SPIRIT_DEBUG_RULE (executor_delegation_spec); + BOOST_SPIRIT_DEBUG_RULE (absract_spec); + BOOST_SPIRIT_DEBUG_RULE (home_type_name); + BOOST_SPIRIT_DEBUG_RULE (abstract_storage_home_name); + BOOST_SPIRIT_DEBUG_RULE (abstract_storage_hom_label); + BOOST_SPIRIT_DEBUG_RULE (executor_body); + BOOST_SPIRIT_DEBUG_RULE (executor_member); + BOOST_SPIRIT_DEBUG_RULE (segment_def); + BOOST_SPIRIT_DEBUG_RULE (feature_delegation_spec); + BOOST_SPIRIT_DEBUG_RULE (segment_member); + BOOST_SPIRIT_DEBUG_RULE (segment_persistence_dcl); + BOOST_SPIRIT_DEBUG_RULE (facet_dcl); + BOOST_SPIRIT_DEBUG_RULE (feature_delegation_list); + BOOST_SPIRIT_DEBUG_RULE (feature_delegation); + BOOST_SPIRIT_DEBUG_RULE (feature_name); + BOOST_SPIRIT_DEBUG_RULE (storage_member_name); + BOOST_SPIRIT_DEBUG_RULE (delegation_list); + BOOST_SPIRIT_DEBUG_RULE (delegation); + BOOST_SPIRIT_DEBUG_RULE (operation_name); + BOOST_SPIRIT_DEBUG_RULE (operation_list); + BOOST_SPIRIT_DEBUG_RULE (proxy_home_member); + BOOST_SPIRIT_DEBUG_RULE (home_delegation_spec); + + specification + = *idl3.import >> +idl3.idl2.declaration + ; + + idl3.idl2.declaration + = idl3.idl2.type_dcl >> idl3.idl2.SEMI + | idl3.idl2.const_dcl >> idl3.idl2.SEMI + | idl3.idl2.except_dcl >> idl3.idl2.SEMI + | idl3.idl2.interface >> idl3.idl2.SEMI + | idl3.idl2.module >> idl3.idl2.SEMI + | idl3.idl2.value >> idl3.idl2.SEMI + | idl3.type_id_dcl >> idl3.idl2.SEMI + | idl3.type_prefix_dcl >> idl3.idl2.SEMI + | idl3.event >> idl3.idl2.SEMI + | idl3.component >> idl3.idl2.SEMI + | idl3.home_dcl >> idl3.idl2.SEMI + | composition >> idl3.idl2.SEMI + ; + + composition + = CIDL_COMPOSITION >> category >> idl3.idl2.IDENTIFIER + >> idl3.idl2.LBRACE >> composition_body >> idl3.idl2.RBRACE + ; + + category + = CIDL_ENTITY + | CIDL_PROCESS + | CIDL_SERVICE + | CIDL_SESSION + ; + + composition_body + = !catalog_use_dcl >> home_executor_def >> !proxy_home_def + ; + + catalog_use_dcl + = idl3.IDL_USES >> CIDL_CATALOG >> idl3.idl2.LBRACE + >> +catalog_dcl >> idl3.idl2.RBRACE >> idl3.idl2.SEMI + ; + + catalog_dcl + = catalog_type_spec >> catalog_label + ; + + catalog_type_spec + = idl3.idl2.scoped_name + ; + + catalog_label + = idl3.idl2.IDENTIFIER + ; + + home_executor_def + = idl3.IDL_HOME >> CIDL_EXECUTOR >> idl3.idl2.IDENTIFIER + >> idl3.idl2.LBRACE >> home_executor_body + >> idl3.idl2.RBRACE >> idl3.idl2.SEMI + ; + + home_executor_body + = home_impl_dcl >> !abstract_storage_home_binding + >> !stored_on_dcl >> executor_def + >> !abstract_storage_home_delegation_spec + >> !executor_delegation_spec >> !abstract_spec + ; + + home_impl_dcl + = CIDL_IMPLEMENTS >> home_type_name >> idl3.idl2.SEMI + ; + + home_type_name + = idl3.idl2.scoped_name + ; + + abstract_storage_home_binding + = CIDL_BINDS_TO >> abstract_storage_home_name + >> idl3.idl2.SEMI + ; + + abstract_storage_home_name + = catalog_label >> DOT >> abstract_storage_home_label + ; + + abstract_storage_home_label + = idl3.idl2.IDENTIFIER + ; + + home_persistence_dcl + = CIDL_STORED_ON >> abstract_storage_home_name + >> idl3.idl2.SEMI + ; + + executor_def + = idl3.IDL_MANAGES >> idl3.idl2.IDENTIFIER + >> !executor_body >> idl3.idl2.SEMI + ; + + executor_body + = idl3.idl2.LBRACE >> +executor_member >> idl3.idl2.RBRACE + ; + + executor_member + = segment_def + | feature_delegation_spec + ; + + segment_def + = CIDL_SEGMENT >> idl3.idl2.IDENTIFIER >> idl3.idl2.LBRACE + >> +segment_member >> idl3.idl2.RBRACE + ; + + segment_member + = segment_persistence_dcl >> idl3.idl2.SEMI + | facet_dcl >> idl3.idl2.SEMI + ; + + segment_persistence_dcl + = CIDL_STORED_ON >> abstract_storage_home_name + >> idl3.idl2.SEMI + ; + + facet_dcl + = idl3.IDL_PROVIDES >> CIDL_FACET >> idl3.idl2.IDENTIFIER + >> *(idl3.idl2.COMMA >> idl3.idl2.IDENTIFIER) + ; + + feature_delegation_spec + = CIDL_DELEGATES_TO >> CIDL_STORAGE + >> feature_delegation_list + ; + + feature_delegation_list + = idl3.idl2.LPAREN >> feature_delegation + >> *(idl3.idl2.COMMA >> feature_delegation) + >> idl3.idl2.RPAREN + ; + + feature_delegation + = feature_name >> idl3.idl2.COLON >> storage_member_name + ; + + feature_name + = idl3.idl2.IDENTIFIER + ; + + storage_member_name + = idl3.idl2.IDENTIFIER + ; + + abstract_storage_home_delegation_spec + = CIDL_DELEGATES_TO >> idl3.idl2.IDL_ABSTRACT + >> CIDL_STORAGEHOME >> delegation_list >> idl3.idl2.SEMI + ; + + executor_delegation_spec + = CIDL_DELEGATES_TO >> CIDL_EXECUTOR >> delegation_list + >> idl3.idl2.SEMI + ; + + delegation_list + = idl3.idl2.LPAREN >> delegation + >> *(idl3.idl2.COMMA >> delegation) >> idl3.idl2.RPAREN + ; + + delegation + = operation_name >> !(idl3.idl2.COLON >> operation_name) + ; + + operation_name + = idl3.idl2.IDENTIFIER + ; + + abstract_spec + = idl3.idl2.IDL_ABSTRACT >> operation_list + >> idl3.idl2.SEMI + ; + + operation_list + = idl3.idl2.LPAREN >> operation_name + >> *(idl3.idl2.COMMA >> operation_name) + >> idl3.idl2.RPAREN + ; + + proxy_home_def + = CIDL_PROXY >> idl3.IDL_HOME >> idl3.idl2.IDENTIFIER + >> idl3.idl2.LBRACE >> +proxy_home_member + >> idl3.idl2.RBRACE >> idl3.idl2.SEMI + ; + + proxy_home_member + = home_delegation_spec >> idl3.idl2.SEMI + | abstract_spec + ; + + home_delegation_spec + = CIDL_DELEGATES_TO >> idl3.IDL_HOME >> delegation_list + ; +} + +#endif /* CIDL_GRAMMAR_C */ diff --git a/TAO/CIAO/CIDLC/parser_examples/cidl/cidl_grammar.h b/TAO/CIAO/CIDLC/parser_examples/cidl/cidl_grammar.h new file mode 100644 index 00000000000..7f7ba05d63c --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/cidl/cidl_grammar.h @@ -0,0 +1,54 @@ +// $Id$ +// +// IDL3 Grammar checker implemented with Spirit (http://spirit.sourceforge.net/) +// +#ifndef CIDL_GRAMMAR_H +#define CIDL_GRAMMAR_H + +#include "idl3/idl3_grammar.h" + +struct cidl_grammar : public grammar<cidl_grammar> +{ + idl3_grammar idl3_g; + + template <typename ScannerT> + struct definition + { + definition (cidl_grammar const & self); + rule<ScannerT> const & start (void) const; + + idl3_grammar::definition<ScannerT> idl3; + + symbols<> keywords; + + chlit<> + DOT; + + rule<ScannerT> + CIDL_COMPOSITION, CIDL_ENTITY, CIDL_PROCESS, CIDL_SERVICE, + CIDL_SESSION, CIDL_CATALOG, CIDL_EXECUTOR, CIDL_IMPLEMENTS, + CIDL_BINDS_TO, CIDL_STORED_ON, CIDL_SEGMENT, CIDL_FACET, + CIDL_DELEGATES_TO, CIDL_STORAGE, CIDL_STORAGEHOME, CIDL_PROXY; + + rule<ScannerT> + specification, composition, category, composition_body, + catalog_use_dcl, home_executor_def, proxy_home_def, + catalog_dcl, catalog_type_spec, catalog_label, + home_executor_body, home_impl_dcl, abstract_storage_home_binding, + stored_on_dcl, executor_def, home_persistence_dcl, + abstract_storage_home_delegation_spec, executor_delegation_spec, + abstract_spec, home_type_name, abstract_storage_home_name, + abstract_storage_home_label, executor_body, executor_member, + segment_def, feature_delegation_spec, segment_member, + segment_persistence_dcl, facet_dcl, feature_delegation_list, + feature_delegation, feature_name, storage_member_name, + delegation_list, delegation, operation_name, operation_list, + proxy_home_member, home_delegation_spec; + }; +}; + +#include "cidl_grammar.cpp" + +#endif /* CIDL_GRAMMAR_H */ + + diff --git a/TAO/CIAO/CIDLC/parser_examples/cidl/hello.cidl b/TAO/CIAO/CIDLC/parser_examples/cidl/hello.cidl new file mode 100644 index 00000000000..6366067f450 --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/cidl/hello.cidl @@ -0,0 +1,17 @@ +// $Id$ -*- IDL -*- + +// Component implementation definition of hello.idl. +// Since we currently don't have a CCIDL (CIAO CIDL) compiler available, +// we need to generate the servant implementation manually. + +import HelloWorld; // Do we need this? +import HelloHome; // This should import all related defitions. + +composition session hello_example +{ + home executor HelloHome_Exec + { + implements HelloHome; // This implies that HelloWorld_Exec + manages HelloWorld_Exec; // implements HellowWorld. + }; +}; diff --git a/TAO/CIAO/CIDLC/parser_examples/idl2/idl2.cpp b/TAO/CIAO/CIDLC/parser_examples/idl2/idl2.cpp new file mode 100644 index 00000000000..43471c7358b --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/idl2/idl2.cpp @@ -0,0 +1,27 @@ +// $Id$ + +#if defined(_DEBUG) +//#define SPIRIT_DEBUG +#endif // defined(_DEBUG) + +#include "idl2_grammar.h" + +int +main (int argc, char* argv[]) +{ + cerr << "IDL2 Grammar checker implemented with Spirit ..." << endl; + +idl2_grammar g; + + if (2 == argc) + { + parse (g, + argv[1]); + } + else + { + cerr << "No filename given" << endl; + } + + return 0; +} diff --git a/TAO/CIAO/CIDLC/parser_examples/idl2/idl2.vcproj b/TAO/CIAO/CIDLC/parser_examples/idl2/idl2.vcproj new file mode 100644 index 00000000000..f94bce20f2e --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/idl2/idl2.vcproj @@ -0,0 +1,152 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="idl2" + ProjectGUID="{81B2195C-C013-4A95-BA25-65C50E4D584A}" + Keyword="Win32Proj"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="Debug" + ConfigurationType="1" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\,..\..\spirit-1.6.0,..\..\spirit-1.6.0\miniboost" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="TRUE" + BasicRuntimeChecks="0" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="FALSE" + DebugInformationFormat="4"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/idl2.exe" + LinkIncremental="2" + GenerateDebugInformation="TRUE" + ProgramDatabaseFile="$(OutDir)/idl2.pdb" + SubSystem="1" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="1" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="4" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/c.exe" + LinkIncremental="1" + GenerateDebugInformation="TRUE" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <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=".\idl2.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + RuntimeLibrary="5"/> + </FileConfiguration> + </File> + <File + RelativePath=".\idl2_grammar.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool" + RuntimeLibrary="5"/> + </FileConfiguration> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> + <File + RelativePath=".\idl2_grammar.h"> + </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> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/TAO/CIAO/CIDLC/parser_examples/idl2/idl2_grammar.cpp b/TAO/CIAO/CIDLC/parser_examples/idl2/idl2_grammar.cpp new file mode 100644 index 00000000000..e7a81cbecbc --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/idl2/idl2_grammar.cpp @@ -0,0 +1,973 @@ +// $Id$ + +#ifndef IDL2_GRAMMAR_C +#define IDL2_GRAMMAR_C + +#include "idl2_grammar.h" + +template<typename ScannerT> +rule<ScannerT> const & +skip_grammar::definition<ScannerT>::start (void) const +{ + return this->skip; +} + +template<typename ScannerT> +skip_grammar::definition<ScannerT>::definition ( + skip_grammar const & /* self */ + ) +{ + this->skip = + space_p // Skip whitespace + | "//" >> *(anychar_p - eol_p) >> eol_p +// | "//" >> *(anychar_p - '\n') >> !eol_p // C++ comment +// | comment_p("//") >> !end_p // Not on MSVC 7.1 + | comment_p("/*", "*/") // C comment + | comment_p("#line") // TODO + | comment_p("#pragma") + ; +} + +// ============================================================ + +template<typename ScannerT> +rule<ScannerT> const & +idl2_grammar::definition<ScannerT>::start (void) const +{ + return specification; +} + +template<typename ScannerT> +idl2_grammar::definition<ScannerT>::definition ( + idl2_grammar const & /* self */ + ) + : LSHIFT("<<"), RSHIFT(">>"), SCOPE("::"), + SEMI(';'), COMMA(','), COLON(':'), ASSIGN('='), + MINUS('-'), PLUS('+'), MULT('*'), DIV('/'), MOD('%'), + AND('&'), NOT('~'), OR('|'), XOR('^'), + LPAREN('('), RPAREN(')'), LANGLE('<'), RANGLE('>'), + LBRACK('['), RBRACK(']'), LBRACE('{'), RBRACE('}') +{ + // IDL2 keywords. + keywords = + "abstract", "any", "attribute", "boolean", "case", + "char", "const", "context", "custom", "default", + "double", "enum", "exception", "factory", "FALSE", + "fixed", "float", "in", "inout", "interface", + "local", "long", "module", "native", "Object", + "octet", "oneway", "out", "private", "public", + "raises", "readonly", "short", "sequence", "string", + "struct", "supports", "switch", "TRUE", "truncatable", + "typedef", "union", "unsigned", "ValueBase", + "valuetype", "void", "wchar", "wstring"; + + // IDL2 tokens. + IDL_ABSTRACT = strlit<>("abstract"); + IDL_ANY = strlit<>("any"); + IDL_ATTRIBUTE = strlit<>("attribute"); + IDL_BOOLEAN = strlit<>("boolean"); + IDL_CASE = strlit<>("case"); + IDL_CHAR = strlit<>("char"); + IDL_CONST = strlit<>("const"); + IDL_CONTEXT = strlit<>("context"); + IDL_CUSTOM = strlit<>("custom"); + IDL_DEFAULT = strlit<>("default"); + IDL_DOUBLE = strlit<>("double"); + IDL_ENUM = strlit<>("enum"); + IDL_EXCEPTION = strlit<>("exception"); + IDL_FACTORY = strlit<>("factory"); + IDL_FALSE = strlit<>("FALSE"); + IDL_FIXED = strlit<>("fixed"); + IDL_FLOAT = strlit<>("float"); + IDL_IN = strlit<>("in"); + IDL_INOUT = strlit<>("inout"); + IDL_INTERFACE = strlit<>("interface"); + IDL_LOCAL = strlit<>("local"); + IDL_LONG = strlit<>("long"); + IDL_MODULE = strlit<>("module"); + IDL_NATIVE = strlit<>("native"); + IDL_OBJECT = strlit<>("Object"); + IDL_OCTET = strlit<>("octet"); + IDL_ONEWAY = strlit<>("oneway"); + IDL_OUT = strlit<>("out"); + IDL_PRIVATE = strlit<>("private"); + IDL_PUBLIC = strlit<>("public"); + IDL_RAISES = strlit<>("raises"); + IDL_READONLY = strlit<>("readonly"); + IDL_SHORT = strlit<>("short"); + IDL_SEQUENCE = strlit<>("sequence"); + IDL_STRING = strlit<>("string"); + IDL_STRUCT = strlit<>("struct"); + IDL_SUPPORTS = strlit<>("supports"); + IDL_SWITCH = strlit<>("switch"); + IDL_TRUE = strlit<>("TRUE"); + IDL_TRUNCATABLE = strlit<>("truncatable"); + IDL_TYPEDEF = strlit<>("typedef"); + IDL_UNION = strlit<>("union"); + IDL_UNSIGNED = strlit<>("unsigned"); + IDL_VALUEBASE = strlit<>("ValueBase"); + IDL_VALUETYPE = strlit<>("valuetype"); + IDL_VOID = strlit<>("void"); + IDL_WCHAR = strlit<>("wchar"); + IDL_WSTRING = strlit<>("wstring"); + + // IDL2 identifiers. + IDENTIFIER = + lexeme_d + [ + ((alpha_p | '_') >> *(alnum_p | '_')) + - (keywords >> anychar_p - (alnum_p | '_')) + ] + ; + + // Character literals. + CHARACTER_LITERAL = + anychar_p + ; + + // Wide character literals. + WIDE_CHARACTER_LITERAL = + lexeme_d + [ + chlit<>('L') >> anychar_p + ] + ; + + // String literals. + STRING_LITERAL_PART = + lexeme_d + [ + chlit<>('\"') >> + *(strlit<>("\"\"") | anychar_p - chlit<>('\"')) >> + chlit<>('\"') + ] + ; + + STRING_LITERAL = +STRING_LITERAL_PART; + + // Wide string literals. + WIDE_STRING_LITERAL_PART = + chlit<>('L') >> STRING_LITERAL_PART + ; + + WIDE_STRING_LITERAL = +WIDE_STRING_LITERAL_PART; + + // Integer literals. + INTEGER_LITERAL_HEX = + lexeme_d + [ + chlit<>('0') + >> nocase_d[chlit<>('x')] + >> +xdigit_p + >> !nocase_d[chlit<>('l') | chlit<>('u')] + ] + ; + + INTEGER_LITERAL_OCT = + lexeme_d + [ + chlit<>('0') + >> +range<>('0', '7') + >> !nocase_d[chlit<>('l') | chlit<>('u')] + ] + ; + + INTEGER_LITERAL_DEC = + lexeme_d + [ + +digit_p + >> !nocase_d[chlit<>('l') | chlit<>('u')] + ] + ; + + INTEGER_LITERAL = + INTEGER_LITERAL_HEX + | INTEGER_LITERAL_OCT + | INTEGER_LITERAL_DEC + ; + + // Floating point literals. + // 12345[eE][+-]?123[lLfF]? + FLOATING_PT_LITERAL_1 = + lexeme_d + [ + +digit_p + >> (chlit<>('e') | chlit<>('E')) + >> !(chlit<>('+') | chlit<>('-')) + >> +digit_p + >> !nocase_d[chlit<>('l') | chlit<>('f')] + ] + ; + + // .123([eE][+-]?123)?[lLfF]? + FLOATING_PT_LITERAL_2 = + lexeme_d + [ + chlit<>('.') + >> +digit_p + >> !( + (chlit<>('e') | chlit<>('E')) + >> !(chlit<>('+') | chlit<>('-')) + >> +digit_p + ) + >> !nocase_d[chlit<>('l') | chlit<>('f')] + ] + ; + + // 12345.(123)?([eE][+-]?123)?[lLfF]? + FLOATING_PT_LITERAL_3 = + lexeme_d + [ + +digit_p + >> chlit<>('.') + >> *digit_p + >> !( + (chlit<>('e') | chlit<>('E')) + >> !(chlit<>('+') | chlit<>('-')) + >> +digit_p + ) + >> !nocase_d[chlit<>('l') | chlit<>('f')] + ] + ; + + FLOATING_PT_LITERAL = + FLOATING_PT_LITERAL_1 + | FLOATING_PT_LITERAL_2 + | FLOATING_PT_LITERAL_3 + ; + + // Boolean literals. + BOOLEAN_LITERAL = + IDL_TRUE + | IDL_FALSE + ; + + // Debug support for terminals. + BOOST_SPIRIT_DEBUG_RULE (IDL_ABSTRACT); + BOOST_SPIRIT_DEBUG_RULE (IDL_ANY); + BOOST_SPIRIT_DEBUG_RULE (IDL_ATTRIBUTE); + BOOST_SPIRIT_DEBUG_RULE (IDL_BOOLEAN); + BOOST_SPIRIT_DEBUG_RULE (IDL_CASE); + BOOST_SPIRIT_DEBUG_RULE (IDL_CHAR); + BOOST_SPIRIT_DEBUG_RULE (IDL_CONST); + BOOST_SPIRIT_DEBUG_RULE (IDL_CONTEXT); + BOOST_SPIRIT_DEBUG_RULE (IDL_CUSTOM); + BOOST_SPIRIT_DEBUG_RULE (IDL_DEFAULT); + BOOST_SPIRIT_DEBUG_RULE (IDL_DOUBLE); + BOOST_SPIRIT_DEBUG_RULE (IDL_ENUM); + BOOST_SPIRIT_DEBUG_RULE (IDL_EXCEPTION); + BOOST_SPIRIT_DEBUG_RULE (IDL_FACTORY); + BOOST_SPIRIT_DEBUG_RULE (IDL_FALSE); + BOOST_SPIRIT_DEBUG_RULE (IDL_FIXED); + BOOST_SPIRIT_DEBUG_RULE (IDL_FLOAT); + BOOST_SPIRIT_DEBUG_RULE (IDL_IN); + BOOST_SPIRIT_DEBUG_RULE (IDL_INOUT); + BOOST_SPIRIT_DEBUG_RULE (IDL_INTERFACE); + BOOST_SPIRIT_DEBUG_RULE (IDL_LOCAL); + BOOST_SPIRIT_DEBUG_RULE (IDL_LONG); + BOOST_SPIRIT_DEBUG_RULE (IDL_MODULE); + BOOST_SPIRIT_DEBUG_RULE (IDL_NATIVE); + BOOST_SPIRIT_DEBUG_RULE (IDL_OBJECT); + BOOST_SPIRIT_DEBUG_RULE (IDL_OCTET); + BOOST_SPIRIT_DEBUG_RULE (IDL_ONEWAY); + BOOST_SPIRIT_DEBUG_RULE (IDL_OUT); + BOOST_SPIRIT_DEBUG_RULE (IDL_PRIVATE); + BOOST_SPIRIT_DEBUG_RULE (IDL_PUBLIC); + BOOST_SPIRIT_DEBUG_RULE (IDL_RAISES); + BOOST_SPIRIT_DEBUG_RULE (IDL_READONLY); + BOOST_SPIRIT_DEBUG_RULE (IDL_SHORT); + BOOST_SPIRIT_DEBUG_RULE (IDL_SEQUENCE); + BOOST_SPIRIT_DEBUG_RULE (IDL_STRING); + BOOST_SPIRIT_DEBUG_RULE (IDL_STRUCT); + BOOST_SPIRIT_DEBUG_RULE (IDL_SWITCH); + BOOST_SPIRIT_DEBUG_RULE (IDL_TRUE); + BOOST_SPIRIT_DEBUG_RULE (IDL_TRUNCATABLE); + BOOST_SPIRIT_DEBUG_RULE (IDL_TYPEDEF); + BOOST_SPIRIT_DEBUG_RULE (IDL_UNION); + BOOST_SPIRIT_DEBUG_RULE (IDL_UNSIGNED); + BOOST_SPIRIT_DEBUG_RULE (IDL_VALUEBASE); + BOOST_SPIRIT_DEBUG_RULE (IDL_VALUETYPE); + BOOST_SPIRIT_DEBUG_RULE (IDL_VOID); + BOOST_SPIRIT_DEBUG_RULE (IDL_WCHAR); + BOOST_SPIRIT_DEBUG_RULE (IDL_WSTRING); + BOOST_SPIRIT_DEBUG_RULE (IDENTIFIER); + BOOST_SPIRIT_DEBUG_RULE (STRING_LITERAL); + BOOST_SPIRIT_DEBUG_RULE (WIDE_STRING_LITERAL); + BOOST_SPIRIT_DEBUG_RULE (CHARACTER_LITERAL); + BOOST_SPIRIT_DEBUG_RULE (WIDE_CHARACTER_LITERAL); + BOOST_SPIRIT_DEBUG_RULE (INTEGER_LITERAL_HEX); + BOOST_SPIRIT_DEBUG_RULE (INTEGER_LITERAL_OCT); + BOOST_SPIRIT_DEBUG_RULE (INTEGER_LITERAL_DEC); + BOOST_SPIRIT_DEBUG_RULE (INTEGER_LITERAL); + BOOST_SPIRIT_DEBUG_RULE (FLOATING_PT_LITERAL_1); + BOOST_SPIRIT_DEBUG_RULE (FLOATING_PT_LITERAL_2); + BOOST_SPIRIT_DEBUG_RULE (FLOATING_PT_LITERAL_3); + BOOST_SPIRIT_DEBUG_RULE (FLOATING_PT_LITERAL); + BOOST_SPIRIT_DEBUG_RULE (BOOLEAN_LITERAL); + + // Debug support for non-terminals. + BOOST_SPIRIT_DEBUG_RULE (specification); + BOOST_SPIRIT_DEBUG_RULE (declaration); + BOOST_SPIRIT_DEBUG_RULE (type_dcl); + BOOST_SPIRIT_DEBUG_RULE (module); + BOOST_SPIRIT_DEBUG_RULE (const_type); + BOOST_SPIRIT_DEBUG_RULE (integer_type); + BOOST_SPIRIT_DEBUG_RULE (signed_int); + BOOST_SPIRIT_DEBUG_RULE (unsigned_int); + BOOST_SPIRIT_DEBUG_RULE (signed_short_int); + BOOST_SPIRIT_DEBUG_RULE (signed_long_int); + BOOST_SPIRIT_DEBUG_RULE (signed_longlong_int); + BOOST_SPIRIT_DEBUG_RULE (unsigned_short_int); + BOOST_SPIRIT_DEBUG_RULE (unsigned_long_int); + BOOST_SPIRIT_DEBUG_RULE (unsigned_longlong_int); + BOOST_SPIRIT_DEBUG_RULE (char_type); + BOOST_SPIRIT_DEBUG_RULE (wide_char_type); + BOOST_SPIRIT_DEBUG_RULE (boolean_type); + BOOST_SPIRIT_DEBUG_RULE (floating_pt_type); + BOOST_SPIRIT_DEBUG_RULE (string_type); + BOOST_SPIRIT_DEBUG_RULE (wide_string_type); + BOOST_SPIRIT_DEBUG_RULE (fixed_pt_const_type); + BOOST_SPIRIT_DEBUG_RULE (scoped_name); + BOOST_SPIRIT_DEBUG_RULE (scoped_name_helper); + BOOST_SPIRIT_DEBUG_RULE (octet_type); + BOOST_SPIRIT_DEBUG_RULE (const_exp); + BOOST_SPIRIT_DEBUG_RULE (or_expr); + BOOST_SPIRIT_DEBUG_RULE (xor_expr); + BOOST_SPIRIT_DEBUG_RULE (and_expr); + BOOST_SPIRIT_DEBUG_RULE (shift_expr); + BOOST_SPIRIT_DEBUG_RULE (add_expr); + BOOST_SPIRIT_DEBUG_RULE (mult_expr); + BOOST_SPIRIT_DEBUG_RULE (unary_expr); + BOOST_SPIRIT_DEBUG_RULE (unary_operator); + BOOST_SPIRIT_DEBUG_RULE (primary_expr); + BOOST_SPIRIT_DEBUG_RULE (literal); + BOOST_SPIRIT_DEBUG_RULE (positive_int_const); + BOOST_SPIRIT_DEBUG_RULE (type_declarator); + BOOST_SPIRIT_DEBUG_RULE (struct_type); + BOOST_SPIRIT_DEBUG_RULE (union_type); + BOOST_SPIRIT_DEBUG_RULE (enum_type); + BOOST_SPIRIT_DEBUG_RULE (simple_declarator); + BOOST_SPIRIT_DEBUG_RULE (constr_forward_decl); + BOOST_SPIRIT_DEBUG_RULE (type_spec); + BOOST_SPIRIT_DEBUG_RULE (declarators); + BOOST_SPIRIT_DEBUG_RULE (simple_type_spec); + BOOST_SPIRIT_DEBUG_RULE (constr_type_spec); + BOOST_SPIRIT_DEBUG_RULE (base_type_spec); + BOOST_SPIRIT_DEBUG_RULE (template_type_spec); + BOOST_SPIRIT_DEBUG_RULE (any_type); + BOOST_SPIRIT_DEBUG_RULE (object_type); + BOOST_SPIRIT_DEBUG_RULE (value_base_type); + BOOST_SPIRIT_DEBUG_RULE (fixed_pt_type); + BOOST_SPIRIT_DEBUG_RULE (sequence_type); + BOOST_SPIRIT_DEBUG_RULE (declarator); + BOOST_SPIRIT_DEBUG_RULE (complex_declarator); + BOOST_SPIRIT_DEBUG_RULE (array_declarator); + BOOST_SPIRIT_DEBUG_RULE (member_list); + BOOST_SPIRIT_DEBUG_RULE (member); + BOOST_SPIRIT_DEBUG_RULE (switch_type_spec); + BOOST_SPIRIT_DEBUG_RULE (switch_body); + BOOST_SPIRIT_DEBUG_RULE (case_decl); + BOOST_SPIRIT_DEBUG_RULE (case_label); + BOOST_SPIRIT_DEBUG_RULE (element_spec); + BOOST_SPIRIT_DEBUG_RULE (enumerator); + BOOST_SPIRIT_DEBUG_RULE (fixed_array_size); + BOOST_SPIRIT_DEBUG_RULE (const_exp_helper); + BOOST_SPIRIT_DEBUG_RULE (or_expr_helper); + BOOST_SPIRIT_DEBUG_RULE (xor_expr_helper); + BOOST_SPIRIT_DEBUG_RULE (and_expr_helper); + BOOST_SPIRIT_DEBUG_RULE (shift_expr_helper); + BOOST_SPIRIT_DEBUG_RULE (add_expr_helper); + BOOST_SPIRIT_DEBUG_RULE (mult_expr_helper); + BOOST_SPIRIT_DEBUG_RULE (except_dcl); + BOOST_SPIRIT_DEBUG_RULE (interface); + BOOST_SPIRIT_DEBUG_RULE (interface_dcl); + BOOST_SPIRIT_DEBUG_RULE (forward_dcl); + BOOST_SPIRIT_DEBUG_RULE (interface_header); + BOOST_SPIRIT_DEBUG_RULE (interface_body); + BOOST_SPIRIT_DEBUG_RULE (interface_name); + BOOST_SPIRIT_DEBUG_RULE (interface_inheritance_spec); + BOOST_SPIRIT_DEBUG_RULE (export); + BOOST_SPIRIT_DEBUG_RULE (attr_dcl); + BOOST_SPIRIT_DEBUG_RULE (op_dcl); + BOOST_SPIRIT_DEBUG_RULE (param_type_spec); + BOOST_SPIRIT_DEBUG_RULE (op_attribute); + BOOST_SPIRIT_DEBUG_RULE (op_type_spec); + BOOST_SPIRIT_DEBUG_RULE (parameter_dcls); + BOOST_SPIRIT_DEBUG_RULE (raises_expr); + BOOST_SPIRIT_DEBUG_RULE (context_expr); + BOOST_SPIRIT_DEBUG_RULE (param_dcl); + BOOST_SPIRIT_DEBUG_RULE (param_attribute); + BOOST_SPIRIT_DEBUG_RULE (value); + BOOST_SPIRIT_DEBUG_RULE (value_dcl); + BOOST_SPIRIT_DEBUG_RULE (value_abs_dcl); + BOOST_SPIRIT_DEBUG_RULE (value_box_dcl); + BOOST_SPIRIT_DEBUG_RULE (value_forward_dcl); + BOOST_SPIRIT_DEBUG_RULE (value_inheritance_spec); + BOOST_SPIRIT_DEBUG_RULE (value_name); + BOOST_SPIRIT_DEBUG_RULE (value_header); + BOOST_SPIRIT_DEBUG_RULE (value_element); + BOOST_SPIRIT_DEBUG_RULE (state_member); + BOOST_SPIRIT_DEBUG_RULE (init_dcl); + BOOST_SPIRIT_DEBUG_RULE (init_param_decls); + BOOST_SPIRIT_DEBUG_RULE (init_param_decl); + BOOST_SPIRIT_DEBUG_RULE (init_param_attribute); + + // Rules. + + // Parser start symbol. + specification + = +declaration + ; + + declaration + = type_dcl >> SEMI + | const_dcl >> SEMI + | except_dcl >> SEMI + | interface >> SEMI + | module >> SEMI + | value >> SEMI + ; + + module + = IDL_MODULE >> IDENTIFIER + >> LBRACE >> +declaration >> RBRACE + ; + + interface + = longest_d + [ + interface_dcl + | forward_dcl + ] + ; + + interface_dcl + = interface_header >> LBRACE >> interface_body >> RBRACE + ; + + forward_dcl + = !(IDL_ABSTRACT | IDL_LOCAL) >> IDL_INTERFACE >> IDENTIFIER + ; + + interface_header + = !(IDL_ABSTRACT | IDL_LOCAL) + >> IDL_INTERFACE >> IDENTIFIER + >> !interface_inheritance_spec + ; + + interface_body + = *export + ; + + export + = type_dcl >> SEMI + | const_dcl >> SEMI + | except_dcl >> SEMI + | attr_dcl >> SEMI + | op_dcl >> SEMI + ; + + interface_inheritance_spec + = COLON >> interface_name >> *(COMMA >> interface_name) + ; + + interface_name + = scoped_name + ; + + scoped_name + = !SCOPE >> IDENTIFIER >> scoped_name_helper + ; + + scoped_name_helper + = SCOPE >> IDENTIFIER >> scoped_name_helper + | epsilon_p + ; + + value + = longest_d + [ + value_dcl + | value_abs_dcl + | value_box_dcl + | value_forward_dcl + ] + ; + + value_forward_dcl + = !IDL_ABSTRACT >> IDL_VALUETYPE >> IDENTIFIER + ; + + value_box_dcl + = IDL_VALUETYPE >> IDENTIFIER >> type_spec + ; + + value_abs_dcl + = IDL_ABSTRACT >> IDL_VALUETYPE >> IDENTIFIER + >> !value_inheritance_spec >> LBRACE + >> *export >> RBRACE + ; + + value_dcl + = value_header >> LBRACE >> *value_element >> RBRACE + ; + + value_header + = !IDL_CUSTOM >> IDL_VALUETYPE >> IDENTIFIER + >> !value_inheritance_spec + ; + + value_inheritance_spec + = !(COLON >> !IDL_TRUNCATABLE >> value_name + >> *(COMMA >> value_name)) + >> !(IDL_SUPPORTS >> interface_name + >> *(COMMA >> interface_name )) + ; + + value_name + = scoped_name + ; + + value_element + = export + | state_member + | init_dcl + ; + + state_member + = (IDL_PUBLIC | IDL_PRIVATE) + >> type_spec >> declarators >> SEMI + ; + + init_dcl + = IDL_FACTORY >> IDENTIFIER >> LPAREN + >> !init_param_decls >> RPAREN >> SEMI + ; + + init_param_decls + = init_param_decl >> *(COMMA >> init_param_decl) + ; + + init_param_decl + = init_param_attribute >> param_type_spec >> simple_declarator + ; + + init_param_attribute + = IDL_IN + ; + + const_dcl + = IDL_CONST >> const_type + >> IDENTIFIER >> ASSIGN >> const_exp + ; + + const_type + = integer_type + | char_type + | wide_char_type + | boolean_type + | floating_pt_type + | string_type + | wide_string_type + | fixed_pt_const_type + | scoped_name + | octet_type + ; + + const_exp + = or_expr + ; + + or_expr + = xor_expr >> or_expr_helper + ; + + or_expr_helper + = OR >> xor_expr + | epsilon_p + ; + + xor_expr + = and_expr >> xor_expr_helper + ; + + xor_expr_helper + = XOR >> xor_expr + | epsilon_p + ; + + and_expr + = shift_expr >> and_expr_helper + ; + + and_expr_helper + = AND >> and_expr + | epsilon_p + ; + + shift_expr + = add_expr >> shift_expr_helper + ; + + shift_expr_helper + = LSHIFT >> shift_expr + | RSHIFT >> shift_expr + | epsilon_p + ; + + add_expr + = mult_expr >> add_expr_helper + ; + + add_expr_helper + = PLUS >> add_expr + | MINUS >> add_expr + | epsilon_p + ; + + mult_expr + = unary_expr >> mult_expr_helper + ; + + mult_expr_helper + = MULT >> mult_expr + | DIV >> mult_expr + | MOD >> mult_expr + | epsilon_p + ; + + unary_expr + = !unary_operator >> primary_expr + ; + + unary_operator + = PLUS + | MINUS + | NOT + ; + + primary_expr + = longest_d + [ + scoped_name + | literal + | LPAREN >> const_exp >> RPAREN + ] + ; + + literal + = longest_d + [ + INTEGER_LITERAL + | STRING_LITERAL + | WIDE_STRING_LITERAL + | CHARACTER_LITERAL + | WIDE_CHARACTER_LITERAL +// | FIXED_PT_LITERAL + | FLOATING_PT_LITERAL + | BOOLEAN_LITERAL + ] + ; + + positive_int_const + = const_exp + ; + + type_dcl + = IDL_TYPEDEF >> type_declarator + | struct_type + | union_type + | enum_type + | IDL_NATIVE >> simple_declarator + | constr_forward_decl + ; + + type_declarator + = type_spec >> declarators + ; + + type_spec + = simple_type_spec + | constr_type_spec + ; + + simple_type_spec + = base_type_spec + | template_type_spec + | scoped_name + ; + + base_type_spec + = floating_pt_type + | integer_type + | char_type + | wide_char_type + | boolean_type + | octet_type + | any_type + | object_type + | value_base_type + ; + + template_type_spec + = sequence_type + | string_type + | wide_string_type + | fixed_pt_type + ; + + constr_type_spec + = struct_type + | union_type + | enum_type + ; + + declarators + = declarator >> *(COMMA >> declarator) + ; + + declarator + = longest_d + [ + simple_declarator + | complex_declarator + ] + ; + + complex_declarator + = array_declarator + ; + + simple_declarator + = IDENTIFIER + ; + + + floating_pt_type + = IDL_FLOAT + | IDL_DOUBLE + | IDL_LONG >> IDL_DOUBLE + ; + + integer_type + = signed_int + | unsigned_int + ; + + signed_int + = longest_d + [ + signed_short_int + | signed_long_int + | signed_longlong_int + ] + ; + + unsigned_int + = longest_d + [ + unsigned_short_int + | unsigned_long_int + | unsigned_longlong_int + ] + ; + + signed_short_int + = IDL_SHORT + ; + + signed_long_int + = IDL_LONG + ; + + signed_longlong_int + = IDL_LONG >> IDL_LONG + ; + + unsigned_short_int + = IDL_UNSIGNED >> IDL_SHORT + ; + + unsigned_long_int + = IDL_UNSIGNED >> IDL_LONG + ; + + unsigned_longlong_int + = IDL_UNSIGNED >> IDL_LONG >> IDL_LONG + ; + + char_type + = IDL_CHAR + ; + + wide_char_type + = IDL_WCHAR + ; + + boolean_type + = IDL_BOOLEAN + ; + + octet_type + = IDL_OCTET + ; + + any_type + = IDL_ANY + ; + + object_type + = IDL_OBJECT + ; + + struct_type + = IDL_STRUCT >> IDENTIFIER + >> LBRACE >> member_list >> RBRACE + ; + + member_list + = +member + ; + + member + = type_spec >> declarators >> SEMI + ; + + union_type + = IDL_UNION >> IDENTIFIER >> IDL_SWITCH + >> LPAREN >> switch_type_spec >> RPAREN + >> LBRACE >> switch_body >> RBRACE + ; + + switch_type_spec + = integer_type + | char_type + | boolean_type + | enum_type + | scoped_name + ; + + switch_body + = +case_decl + ; + + case_decl + = +case_label >> element_spec >> SEMI + ; + + case_label + = IDL_CASE >> const_exp >> COLON + | IDL_DEFAULT >> COLON + ; + + element_spec + = type_spec >> declarator + ; + + enum_type + = IDL_ENUM >> IDENTIFIER + >> LBRACE >> enumerator + >> *(COMMA >> enumerator) >> RBRACE + ; + + enumerator + = IDENTIFIER + ; + + sequence_type + = IDL_SEQUENCE >> LANGLE >> simple_type_spec + >> !(COMMA >> positive_int_const) >> RANGLE + ; + + string_type + = IDL_STRING >> !(LANGLE >> positive_int_const >> RANGLE) + ; + + wide_string_type + = IDL_WSTRING + ; + + array_declarator + = IDENTIFIER >> +fixed_array_size + ; + + fixed_array_size + = LBRACK >> positive_int_const >> RBRACK + ; + + attr_dcl + = !IDL_READONLY >> IDL_ATTRIBUTE >> param_type_spec + >> simple_declarator >> *(COMMA >> simple_declarator) + ; + + except_dcl + = IDL_EXCEPTION >> IDENTIFIER + >> LBRACE >> *member >> RBRACE + ; + + op_dcl + = !op_attribute >> op_type_spec >> IDENTIFIER + >> parameter_dcls >> !raises_expr >> !context_expr + ; + + op_attribute + = IDL_ONEWAY + ; + + op_type_spec + = param_type_spec + | IDL_VOID + ; + + parameter_dcls + = LPAREN >> !(param_dcl >> *(COMMA >> param_dcl)) >> RPAREN + ; + + param_dcl + = param_attribute >> param_type_spec >> simple_declarator + ; + + param_attribute + = longest_d + [ + IDL_IN + | IDL_INOUT + ] + | IDL_OUT + ; + + raises_expr + = IDL_RAISES >> LPAREN >> scoped_name + >> *(COMMA >> scoped_name) + >> RPAREN + ; + + context_expr + = IDL_CONTEXT >> LPAREN >> STRING_LITERAL + >> *(COMMA >> STRING_LITERAL) + >> RPAREN + ; + + param_type_spec + = base_type_spec + | string_type + | wide_string_type + | scoped_name + ; + + fixed_pt_type + = IDL_FIXED >> LANGLE + >> positive_int_const >> COMMA >> positive_int_const + >> RANGLE + ; + + fixed_pt_const_type + = IDL_FIXED + ; + + value_base_type + = IDL_VALUEBASE + ; +} + +#endif /* IDL2_GRAMMAR_C */ diff --git a/TAO/CIAO/CIDLC/parser_examples/idl2/idl2_grammar.h b/TAO/CIAO/CIDLC/parser_examples/idl2/idl2_grammar.h new file mode 100644 index 00000000000..d7d7832f10d --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/idl2/idl2_grammar.h @@ -0,0 +1,166 @@ +// $Id$ +// +// IDL2 Grammar checker implemented with Spirit (http://spirit.sourceforge.net/) +// +#ifndef IDL2_GRAMMAR_H +#define IDL2_GRAMMAR_H + +#include <iostream> +#include <fstream> +#include <vector> + +// This is caused by using 'this' in a base member initialization. +#pragma warning (disable: 4355) + +#include <boost/spirit/core.hpp> +#include <boost/spirit/utility.hpp> +#include <boost/spirit/symbols.hpp> + +using namespace boost::spirit; +using namespace std; + +// Global parsing utility function. +template<typename GrammarT> +void +parse (GrammarT const & g, + char const * filename) +{ + ifstream in (filename); + + if (!in) + { + cerr << "Could not open input file: " << filename << endl; + return; + } + + // Turn off white space skipping on the stream. + in.unsetf (ios::skipws); + + vector<char> vec; + std::copy (istream_iterator<char> (in), + istream_iterator<char> (), + std::back_inserter(vec)); + + vector<char>::const_iterator start = vec.begin (); + vector<char>::const_iterator end = vec.end (); + + skip_grammar skip; + + parse_info<vector<char>::const_iterator> result = parse (start, + end, + g, + skip); + + if (result.full) + { + cerr << filename << " Parses OK" << endl; + } + else + { + cerr << filename << " Fails Parsing" << endl; + + for (int i = 0; i < 50; i++) + { + if (result.stop == end) + { + break; + } + + cerr << *result.stop++; + } + + cerr << endl; + } +} + +// We use this to skip whitespace, comments, and whatever else. +struct skip_grammar : public grammar<skip_grammar> +{ + template <typename ScannerT> + struct definition + { + definition (skip_grammar const & self); + rule<ScannerT> const & start (void) const; + + rule<ScannerT> skip; + }; +}; + +struct idl2_grammar : public grammar<idl2_grammar> +{ + template <typename ScannerT> + struct definition + { + definition (idl2_grammar const & /* self */); + rule<ScannerT> const & start (void) const; + + // Keyword table. + symbols<> keywords; + + // Non-alphanumeric terminals. + strlit<> + LSHIFT, RSHIFT, SCOPE; + chlit<> + SEMI, COMMA, COLON, ASSIGN, MINUS, PLUS, MULT, DIV, MOD, + AND, NOT, OR, XOR, LPAREN, RPAREN, LANGLE, RANGLE, + LBRACK, RBRACK, LBRACE, RBRACE; + + // IDL2 keywords. + rule<ScannerT> + IDL_ABSTRACT, IDL_ANY, IDL_ATTRIBUTE, IDL_BOOLEAN, + IDL_CASE, IDL_CHAR, IDL_CONST, IDL_CONTEXT, IDL_CUSTOM, + IDL_DEFAULT, IDL_DOUBLE, IDL_ENUM, IDL_EXCEPTION, + IDL_FACTORY, IDL_FALSE, IDL_FIXED, IDL_FLOAT, + IDL_IN, IDL_INOUT, IDL_INTERFACE, IDL_LOCAL, IDL_LONG, + IDL_MODULE, IDL_NATIVE, IDL_OBJECT, IDL_OCTET, + IDL_ONEWAY, IDL_OUT, IDL_PRIVATE, IDL_PUBLIC, + IDL_RAISES, IDL_READONLY, IDL_SHORT, IDL_SEQUENCE, + IDL_STRING, IDL_STRUCT, IDL_SUPPORTS, IDL_SWITCH, + IDL_TRUE, IDL_TRUNCATABLE, IDL_TYPEDEF, IDL_UNION, + IDL_UNSIGNED, IDL_VALUEBASE, IDL_VALUETYPE, IDL_VOID, + IDL_WCHAR, IDL_WSTRING; + + // Identifier and literals. + rule<ScannerT> + IDENTIFIER, + CHARACTER_LITERAL, WIDE_CHARACTER_LITERAL, STRING_LITERAL_PART, + STRING_LITERAL, WIDE_STRING_LITERAL_PART, WIDE_STRING_LITERAL, + INTEGER_LITERAL_HEX, INTEGER_LITERAL_OCT, INTEGER_LITERAL_DEC, + INTEGER_LITERAL, FLOATING_PT_LITERAL_1, FLOATING_PT_LITERAL_2, + FLOATING_PT_LITERAL_3, FLOATING_PT_LITERAL, BOOLEAN_LITERAL; + + // IDL2 non-terminals. + rule<ScannerT> + specification, declaration, const_dcl, module, const_type, type_dcl, + integer_type, signed_int, unsigned_int, signed_short_int, + signed_long_int, signed_longlong_int, unsigned_short_int, + unsigned_long_int, unsigned_longlong_int, + char_type, wide_char_type, boolean_type, floating_pt_type, + string_type, wide_string_type, fixed_pt_const_type, scoped_name, + scoped_name_helper, octet_type, const_exp, or_expr, xor_expr, + and_expr, shift_expr, add_expr, mult_expr, unary_expr, + unary_operator, primary_expr, literal, fixed_pt_literal, + positive_int_const, type_declarator, struct_type, union_type, + enum_type, simple_declarator, constr_forward_decl, type_spec, + declarators, simple_type_spec, constr_type_spec, base_type_spec, + template_type_spec, any_type, object_type, value_base_type, + fixed_pt_type, sequence_type, declarator, complex_declarator, + array_declarator, member_list, member, switch_type_spec, + switch_body, case_decl, case_label, element_spec, enumerator, + fixed_array_size, const_exp_helper, or_expr_helper, + xor_expr_helper, and_expr_helper, shift_expr_helper, add_expr_helper, + mult_expr_helper, except_dcl, interface, interface_dcl, + forward_dcl, interface_header, interface_body, interface_name, + interface_inheritance_spec, export, attr_dcl, op_dcl, + param_type_spec, op_attribute, op_type_spec, parameter_dcls, + raises_expr, context_expr, param_dcl, param_attribute, value, + value_dcl, value_abs_dcl, value_box_dcl, value_forward_dcl, + value_inheritance_spec, value_name, value_header, value_element, + state_member, init_dcl, init_param_decls, init_param_decl, + init_param_attribute; + }; +}; + +#include "idl2_grammar.cpp" + +#endif /* IDL2_GRAMMAR_H */ diff --git a/TAO/CIAO/CIDLC/parser_examples/idl2/test_idl2.idl b/TAO/CIAO/CIDLC/parser_examples/idl2/test_idl2.idl new file mode 100644 index 00000000000..6d49f808cb4 --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/idl2/test_idl2.idl @@ -0,0 +1,103 @@ +// $Id$ -*- IDL -*- + +module outer +{ + const string<34> hello = "Goodbye"; + const long foolong = -321; + + module inner + { + typedef unsigned long long fooulonglong; + typedef fooulonglong tdef2; + typedef sequence<tdef2> tdef2seq; + typedef long foolongarray[(3 * (-3 + 9 - 1) / 3 % 2) << 1]; + + struct foostruct + { + short shmem; + any anymem; + Object objmem; + sequence<string<12>, 25> seqmem; + inner::tdef2 tdef2mem[6][5][3]; + }; + + enum fooenum + { + ONE, + TWO + }; + + union foounion switch (fooenum) + { + case TWO: + case ONE: long lmem; + default: string strmem; + }; + + native foonative; + const double foodouble = 321.1416E-12f; + + exception fooemptyexcept {}; + exception fooexcept + { + string message; + }; + + abstract interface foofwd; + abstract interface foofwd {}; + local interface foofulliface : fooemptyiface, foofwd + { + const short shconst = 5; + typedef foofwd footdef; + struct ifacestruct {string str;}; + exception ifaceexcept {}; + attribute long attr; + readonly attribute foounion foounionattr; + void emptyop (); + fooenum fullop (in string strinarg, + in foofwd inobjarg, + inout foounion inoutarg, + out foostruct outarg) + raises (::outer::inner::fooexcept, + fooemptyexcept) + context ("fee", "fi", "fo", "fum"); + oneway void onewayop (in inner::foonative inarg); + }; + + abstract valuetype absval {}; + valuetype vfwd; + valuetype vfwd + { + const short vshconst = 5; + typedef foofwd vfootdef; + struct valstruct {string str;}; + exception valexcept {}; + attribute long vattr; + readonly attribute foounion vfoounionattr; + void vemptyop (); + fooenum fullop (in string strinarg, + in foofwd inobjarg, + inout foounion inoutarg, + out foostruct outarg) + raises (::outer::inner::fooexcept, + fooemptyexcept) + context ("fee", "fi", "fo", "fum"); + }; + + valuetype child : vfwd, absval + { + }; + + valuetype supporter supports fooemptyiface, foofwd + { + }; + + custom valuetype child_supporter : vfwd, absval supports foofwd + { + private foostruct foostructmember; + public long longmember; + public outer::inner::vfwd valmember; + factory cs_factory (in long longarg, in string stringarg); + }; + }; +}; diff --git a/TAO/CIAO/CIDLC/parser_examples/idl3/idl3.cpp b/TAO/CIAO/CIDLC/parser_examples/idl3/idl3.cpp new file mode 100644 index 00000000000..fb9f58de958 --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/idl3/idl3.cpp @@ -0,0 +1,29 @@ +// $Id$ + +#if defined(_DEBUG) +//#define SPIRIT_DEBUG +#endif // defined(_DEBUG) + +#include "idl3_grammar.h" + +int +main (int argc, char* argv[]) +{ +// Start grammar definition + cerr << "IDL3 Grammar checker implemented with Spirit ..." << endl; + +// main driver code +idl3_grammar g; + + if (2 == argc) + { + parse (g, + argv[1]); + } + else + { + cerr << "No filename given" << endl; + } + + return 0; +} diff --git a/TAO/CIAO/CIDLC/parser_examples/idl3/idl3.vcproj b/TAO/CIAO/CIDLC/parser_examples/idl3/idl3.vcproj new file mode 100644 index 00000000000..0361857a73f --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/idl3/idl3.vcproj @@ -0,0 +1,153 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="idl3" + ProjectGUID="{5F3379E4-2944-4FEE-A04A-CD04C3B66401}" + RootNamespace="idl3" + Keyword="ManagedCProj"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="2" + ManagedExtensions="TRUE"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..,..\..\spirit-1.6.0,..\..\spirit-1.6.0\miniboost" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="FALSE" + BasicRuntimeChecks="0" + RuntimeLibrary="1" + UsePrecompiledHeader="0" + WarningLevel="3" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)\idl3.exe" + LinkIncremental="2" + GenerateDebugInformation="TRUE" + AssemblyDebug="1" + ProgramDatabaseFile="$(OutDir)/idl3.pdb" + SubSystem="1"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="2" + ManagedExtensions="TRUE"> + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="WIN32;NDEBUG" + MinimalRebuild="FALSE" + RuntimeLibrary="0" + UsePrecompiledHeader="3" + WarningLevel="3" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)\$(ProjectName).exe" + LinkIncremental="1" + GenerateDebugInformation="TRUE"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <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.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + MinimalRebuild="TRUE" + BasicRuntimeChecks="3" + RuntimeLibrary="5" + DebugInformationFormat="4" + CompileAsManaged="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\idl3_grammar.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> + <File + RelativePath=".\idl3_grammar.h"> + </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> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/TAO/CIAO/CIDLC/parser_examples/idl3/idl3_grammar.cpp b/TAO/CIAO/CIDLC/parser_examples/idl3/idl3_grammar.cpp new file mode 100644 index 00000000000..2aafc491ce4 --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/idl3/idl3_grammar.cpp @@ -0,0 +1,349 @@ +// $Id$ + +#include "idl3_grammar.h" + +#ifndef IDL3_GRAMMAR_C +#define IDL3_GRAMMAR_C + +template<typename ScannerT> +rule<ScannerT> const & +idl3_grammar::definition<ScannerT>::start (void) const +{ + return specification; +} + +template<typename ScannerT> +idl3_grammar::definition<ScannerT>::definition ( + idl3_grammar const & self + ) + : idl2 (self.idl2_g) +{ + keywords = + "import", "typeid", "typeprefix", "getraises", "setraises", + "component", "provides", "uses", "multiple", "emits", + "publishes", "consumes", "home", "manages", "primarykey", + "finder", "eventtype"; + + IDL_IMPORT = strlit<>("import"); + IDL_TYPEID = strlit<>("typeid"); + IDL_TYPEPREFIX = strlit<>("typeprefix"); + IDL_GETRAISES = strlit<>("getraises"); + IDL_SETRAISES = strlit<>("setraises"); + IDL_COMPONENT = strlit<>("component"); + IDL_PROVIDES = strlit<>("provides"); + IDL_USES = strlit<>("uses"); + IDL_MULTIPLE = strlit<>("multiple"); + IDL_EMITS = strlit<>("emits"); + IDL_PUBLISHES = strlit<>("publishes"); + IDL_CONSUMES = strlit<>("consumes"); + IDL_HOME = strlit<>("home"); + IDL_MANAGES = strlit<>("manages"); + IDL_PRIMARYKEY = strlit<>("primarykey"); + IDL_FINDER = strlit<>("finder"); + IDL_EVENTTYPE = strlit<>("eventtype"); + + idl2.IDENTIFIER = + lexeme_d + [ + ((alpha_p | '_') >> *(alnum_p | '_')) + - (idl2.keywords >> anychar_p - (alnum_p | '_')) + - (this->keywords >> anychar_p - (alnum_p | '_')) + ] + ; + + BOOST_SPIRIT_DEBUG_RULE (IDL_IMPORT); + BOOST_SPIRIT_DEBUG_RULE (IDL_TYPEID); + BOOST_SPIRIT_DEBUG_RULE (IDL_TYPEPREFIX); + BOOST_SPIRIT_DEBUG_RULE (IDL_GETRAISES); + BOOST_SPIRIT_DEBUG_RULE (IDL_SETRAISES); + BOOST_SPIRIT_DEBUG_RULE (IDL_COMPONENT); + BOOST_SPIRIT_DEBUG_RULE (IDL_PROVIDES); + BOOST_SPIRIT_DEBUG_RULE (IDL_USES); + BOOST_SPIRIT_DEBUG_RULE (IDL_MULTIPLE); + BOOST_SPIRIT_DEBUG_RULE (IDL_EMITS); + BOOST_SPIRIT_DEBUG_RULE (IDL_PUBLISHES); + BOOST_SPIRIT_DEBUG_RULE (IDL_CONSUMES); + BOOST_SPIRIT_DEBUG_RULE (IDL_HOME); + BOOST_SPIRIT_DEBUG_RULE (IDL_MANAGES); + BOOST_SPIRIT_DEBUG_RULE (IDL_PRIMARYKEY); + BOOST_SPIRIT_DEBUG_RULE (IDL_FINDER); + BOOST_SPIRIT_DEBUG_RULE (IDL_EVENTTYPE); + + BOOST_SPIRIT_DEBUG_RULE (specification); + BOOST_SPIRIT_DEBUG_RULE (import); + BOOST_SPIRIT_DEBUG_RULE (imported_scope); + BOOST_SPIRIT_DEBUG_RULE (type_id_dcl); + BOOST_SPIRIT_DEBUG_RULE (type_prefix_dcl); + BOOST_SPIRIT_DEBUG_RULE (readonly_attr_spec); + BOOST_SPIRIT_DEBUG_RULE (attr_spec); + BOOST_SPIRIT_DEBUG_RULE (readonly_attr_declarator); + BOOST_SPIRIT_DEBUG_RULE (attr_declarator); + BOOST_SPIRIT_DEBUG_RULE (attr_raises_expr); + BOOST_SPIRIT_DEBUG_RULE (get_excep_expr); + BOOST_SPIRIT_DEBUG_RULE (set_excep_expr); + BOOST_SPIRIT_DEBUG_RULE (exception_list); + BOOST_SPIRIT_DEBUG_RULE (component); + BOOST_SPIRIT_DEBUG_RULE (component_dcl); + BOOST_SPIRIT_DEBUG_RULE (component_forward_dcl); + BOOST_SPIRIT_DEBUG_RULE (component_header); + BOOST_SPIRIT_DEBUG_RULE (component_body); + BOOST_SPIRIT_DEBUG_RULE (component_inheritance_spec); + BOOST_SPIRIT_DEBUG_RULE (component_export); + BOOST_SPIRIT_DEBUG_RULE (supported_interface_spec); + BOOST_SPIRIT_DEBUG_RULE (component_export); + BOOST_SPIRIT_DEBUG_RULE (provides_dcl); + BOOST_SPIRIT_DEBUG_RULE (uses_dcl); + BOOST_SPIRIT_DEBUG_RULE (emits_dcl); + BOOST_SPIRIT_DEBUG_RULE (publishes_dcl); + BOOST_SPIRIT_DEBUG_RULE (consumes_dcl); + BOOST_SPIRIT_DEBUG_RULE (interface_type); + BOOST_SPIRIT_DEBUG_RULE (home_dcl); + BOOST_SPIRIT_DEBUG_RULE (home_header); + BOOST_SPIRIT_DEBUG_RULE (home_body); + BOOST_SPIRIT_DEBUG_RULE (home_inheritance_spec); + BOOST_SPIRIT_DEBUG_RULE (home_export); + BOOST_SPIRIT_DEBUG_RULE (primary_key_spec); + BOOST_SPIRIT_DEBUG_RULE (factory_dcl); + BOOST_SPIRIT_DEBUG_RULE (finder_dcl); + BOOST_SPIRIT_DEBUG_RULE (event); + BOOST_SPIRIT_DEBUG_RULE (event_dcl); + BOOST_SPIRIT_DEBUG_RULE (event_abs_dcl); + BOOST_SPIRIT_DEBUG_RULE (event_forward_dcl); + BOOST_SPIRIT_DEBUG_RULE (event_header); + + specification + = *import >> +idl2.declaration + ; + + idl2.declaration + = idl2.type_dcl >> idl2.SEMI + | idl2.const_dcl >> idl2.SEMI + | idl2.except_dcl >> idl2.SEMI + | idl2.interface >> idl2.SEMI + | idl2.module >> idl2.SEMI + | idl2.value >> idl2.SEMI + | type_id_dcl >> idl2.SEMI + | type_prefix_dcl >> idl2.SEMI + | event >> idl2.SEMI + | component >> idl2.SEMI + | home_dcl >> idl2.SEMI + ; + + idl2.export + = idl2.type_dcl >> idl2.SEMI + | idl2.const_dcl >> idl2.SEMI + | idl2.except_dcl >> idl2.SEMI + | idl2.attr_dcl >> idl2.SEMI + | idl2.op_dcl >> idl2.SEMI + | type_id_dcl >> idl2.SEMI + | type_prefix_dcl >> idl2.SEMI + ; + + idl2.init_dcl + = idl2.IDL_FACTORY >> idl2.IDENTIFIER >> idl2.LPAREN + >> !idl2.init_param_decls >> idl2.RPAREN + >> !idl2.raises_expr >> idl2.SEMI + ; + + idl2.attr_dcl + = readonly_attr_spec + | attr_spec + ; + + import + = IDL_IMPORT >> imported_scope >> idl2.SEMI + ; + + imported_scope + = idl2.scoped_name + | idl2.STRING_LITERAL + ; + + type_id_dcl + = IDL_TYPEID >> idl2.scoped_name >> idl2.STRING_LITERAL + ; + + type_prefix_dcl + = IDL_TYPEPREFIX >> idl2.scoped_name >> idl2.STRING_LITERAL + ; + + readonly_attr_spec + = idl2.IDL_READONLY >> idl2.IDL_ATTRIBUTE + >> idl2.param_type_spec + >> readonly_attr_declarator + ; + + readonly_attr_declarator + = idl2.simple_declarator >> idl2.raises_expr + | idl2.simple_declarator + >> *(idl2.COMMA >> idl2.simple_declarator) + ; + + attr_spec + = idl2.IDL_ATTRIBUTE >> idl2.param_type_spec + >> attr_declarator + ; + + attr_declarator + = idl2.simple_declarator >> attr_raises_expr + | idl2.simple_declarator + >> *(idl2.COMMA >> idl2.simple_declarator) + ; + + attr_raises_expr + = get_excep_expr >> !set_excep_expr + | set_excep_expr + ; + + get_excep_expr + = IDL_GETRAISES >> exception_list + ; + + set_excep_expr + = IDL_SETRAISES >> exception_list + ; + + exception_list + = idl2.LPAREN >> idl2.scoped_name + >> *(idl2.COMMA >> idl2.scoped_name) >> idl2.RPAREN + ; + + component + = component_dcl + | component_forward_dcl + ; + + component_forward_dcl + = IDL_COMPONENT >> idl2.IDENTIFIER + ; + + component_dcl + = component_header >> idl2.LBRACE + >> component_body >> idl2.RBRACE + ; + + component_header + = IDL_COMPONENT >> idl2.IDENTIFIER + >> !component_inheritance_spec + >> !supported_interface_spec + ; + + supported_interface_spec + = idl2.IDL_SUPPORTS >> idl2.scoped_name + >> *(idl2.COMMA >> idl2.scoped_name) + ; + + component_inheritance_spec + = idl2.COLON >> idl2.scoped_name + ; + + component_body + = *component_export + ; + + component_export + = provides_dcl >> idl2.SEMI + | uses_dcl >> idl2.SEMI + | emits_dcl >> idl2.SEMI + | publishes_dcl >> idl2.SEMI + | consumes_dcl >> idl2.SEMI + | idl2.attr_dcl >> idl2.SEMI + ; + + provides_dcl + = IDL_PROVIDES >> interface_type >> idl2.IDENTIFIER + ; + + interface_type + = idl2.scoped_name + | idl2.IDL_OBJECT + ; + + uses_dcl + = IDL_USES >> !IDL_MULTIPLE + >> interface_type >> idl2.IDENTIFIER + ; + + emits_dcl + = IDL_EMITS >> idl2.scoped_name >> idl2.IDENTIFIER + ; + + publishes_dcl + = IDL_PUBLISHES >> idl2.scoped_name >> idl2.IDENTIFIER + ; + + consumes_dcl + = IDL_CONSUMES >> idl2.scoped_name >> idl2.IDENTIFIER + ; + + home_dcl + = home_header >> home_body + ; + + home_header + = IDL_HOME >> idl2.IDENTIFIER + >> !home_inheritance_spec + >> !supported_interface_spec + >> IDL_MANAGES >> idl2.scoped_name + >> !primary_key_spec + ; + + home_inheritance_spec + = idl2.COLON >> idl2.scoped_name + ; + + primary_key_spec + = IDL_PRIMARYKEY >> idl2.scoped_name + ; + + home_body + = idl2.LBRACE >> *home_export >> idl2.RBRACE + ; + + home_export + = idl2.export + | factory_dcl >> idl2.SEMI + | finder_dcl >> idl2.SEMI + ; + + factory_dcl + = idl2.IDL_FACTORY >> idl2.IDENTIFIER >> idl2.LPAREN + >> !idl2.init_param_decls >>idl2.RPAREN + >> !idl2.raises_expr + ; + + finder_dcl + = IDL_FINDER >> idl2.IDENTIFIER >> idl2.LPAREN + >> !idl2.init_param_decls >>idl2.RPAREN + >> !idl2.raises_expr + ; + + event + = event_dcl + | event_abs_dcl + | event_forward_dcl + ; + + event_forward_dcl + = !idl2.IDL_ABSTRACT >> IDL_EVENTTYPE >> idl2.IDENTIFIER + ; + + event_abs_dcl + = !idl2.IDL_ABSTRACT >> IDL_EVENTTYPE >> idl2.IDENTIFIER + >> !idl2.value_inheritance_spec >> idl2.LBRACE + >> *idl2.export >> idl2.RBRACE + ; + + event_dcl + = event_header >> idl2.LBRACE >> *idl2.value_element + >> idl2.RBRACE + ; + + event_header + = !idl2.IDL_CUSTOM >> IDL_EVENTTYPE >> idl2.IDENTIFIER + >> !idl2.value_inheritance_spec + ; +} + +#endif /* IDL3_GRAMMAR_C */ + diff --git a/TAO/CIAO/CIDLC/parser_examples/idl3/idl3_grammar.h b/TAO/CIAO/CIDLC/parser_examples/idl3/idl3_grammar.h new file mode 100644 index 00000000000..5473f470bc2 --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/idl3/idl3_grammar.h @@ -0,0 +1,51 @@ +// $Id$ +// +// IDL3 Grammar checker implemented with Spirit (http://spirit.sourceforge.net/) +// +#ifndef IDL3_GRAMMAR_H +#define IDL3_GRAMMAR_H + +#include "idl2/idl2_grammar.h" + +struct idl3_grammar : public grammar<idl3_grammar> +{ + idl2_grammar idl2_g; + + template <typename ScannerT> + struct definition + { + definition (idl3_grammar const & self); + rule<ScannerT> const & start (void) const; + + idl2_grammar::definition<ScannerT> idl2; + + symbols<> keywords; + + rule<ScannerT> + IDL_IMPORT, IDL_TYPEID, IDL_TYPEPREFIX, IDL_GETRAISES, + IDL_SETRAISES, IDL_COMPONENT, IDL_PROVIDES, IDL_USES, + IDL_MULTIPLE, IDL_EMITS, IDL_PUBLISHES, IDL_CONSUMES, + IDL_HOME, IDL_MANAGES, IDL_PRIMARYKEY, IDL_FINDER, + IDL_EVENTTYPE; + + rule<ScannerT> + specification, + import, imported_scope, type_id_dcl, type_prefix_dcl, + readonly_attr_spec, attr_spec, readonly_attr_declarator, + attr_declarator, attr_raises_expr, get_excep_expr, + set_excep_expr, exception_list, component, component_dcl, + component_forward_dcl, component_header, component_body, + component_inheritance_spec, component_export, + supported_interface_spec, provides_dcl, uses_dcl, emits_dcl, + publishes_dcl, consumes_dcl, interface_type, home_dcl, + home_header, home_body, home_inheritance_spec, home_export, + primary_key_spec, factory_dcl, finder_dcl, event, event_dcl, + event_abs_dcl, event_forward_dcl, event_header; + + }; +}; + +#include "idl3_grammar.cpp" + +#endif /* IDL3_GRAMMAR_H */ + diff --git a/TAO/CIAO/CIDLC/parser_examples/idl3/test_idl3.idl b/TAO/CIAO/CIDLC/parser_examples/idl3/test_idl3.idl new file mode 100644 index 00000000000..a2d3a3d4bd6 --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/idl3/test_idl3.idl @@ -0,0 +1,73 @@ +// $Id$ -*- IDL -*- + +import "groovy.idl"; +import skaboodliator::bingabay; + +module mod +{ + interface dummy {}; + + interface foo + { + exception dingdong {}; + exception ramalama {}; + readonly attribute long foo_attr, foo_attr2; + readonly attribute mod::foo self_attr raises (dingdong); + attribute string get_str getraises (ramalama, dingdong); + attribute string set_str setraises (ramalama, dingdong); + attribute long bb getraises (dingdong, ramalama) + setraises (ramalama); + typeid dingdong "THE:witch/is:dead"; + }; + + valuetype val + { + factory f () raises (dingdong, ramalama); + private string pstr; + }; + + abstract eventtype efwd; + abstract eventtype efwd supports foo + { + attribute string pstr; + }; + + custom eventtype cust + { + public string pstr; + factory f () raises (dingdong, ramalama); + }; + + eventtype empty_ev : cust, efwd supports foo, dummy + { + }; + + component bar; + component emptybar supports foo + { + }; + + component fullbar : emptybar + { + attribute val cc getraises (dingdong, ramalama) + setraises (ramalama, dingdong); + provides pfoo foo; + uses ufoo foo; + uses multiple umfoo foo; + emits emitter efwd; + publishes pcust cust; + consumes cempty empty_ev; + }; + + home fullhome manages fullbar + { + void op (); + factory finit (in string strarg, in wstring wstrarg) + raises (dingdong); + finder flookup () raises (ramalama, dingdong); + }; + + typeid foo "ABRA:cadabra/hocus/pocus:1.234"; +}; + +typeprefix mod "dre.vanderbilt.edu"; diff --git a/TAO/CIAO/CIDLC/parser_examples/parser_examples.sln b/TAO/CIAO/CIDLC/parser_examples/parser_examples.sln new file mode 100644 index 00000000000..51237fdef2e --- /dev/null +++ b/TAO/CIAO/CIDLC/parser_examples/parser_examples.sln @@ -0,0 +1,37 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "idl2", "idl2\idl2.vcproj", "{81B2195C-C013-4A95-BA25-65C50E4D584A}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "idl3", "idl3\idl3.vcproj", "{5F3379E4-2944-4FEE-A04A-CD04C3B66401}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cidl", "cidl\cidl.vcproj", "{8059742C-5DA9-4318-8D04-7938CBB0D538}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {81B2195C-C013-4A95-BA25-65C50E4D584A}.Debug.ActiveCfg = Debug|Win32 + {81B2195C-C013-4A95-BA25-65C50E4D584A}.Debug.Build.0 = Debug|Win32 + {81B2195C-C013-4A95-BA25-65C50E4D584A}.Release.ActiveCfg = Release|Win32 + {81B2195C-C013-4A95-BA25-65C50E4D584A}.Release.Build.0 = Release|Win32 + {5F3379E4-2944-4FEE-A04A-CD04C3B66401}.Debug.ActiveCfg = Debug|Win32 + {5F3379E4-2944-4FEE-A04A-CD04C3B66401}.Debug.Build.0 = Debug|Win32 + {5F3379E4-2944-4FEE-A04A-CD04C3B66401}.Release.ActiveCfg = Release|Win32 + {5F3379E4-2944-4FEE-A04A-CD04C3B66401}.Release.Build.0 = Release|Win32 + {8059742C-5DA9-4318-8D04-7938CBB0D538}.Debug.ActiveCfg = Debug|Win32 + {8059742C-5DA9-4318-8D04-7938CBB0D538}.Debug.Build.0 = Debug|Win32 + {8059742C-5DA9-4318-8D04-7938CBB0D538}.Release.ActiveCfg = Release|Win32 + {8059742C-5DA9-4318-8D04-7938CBB0D538}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/TAO/CIAO/ChangeLog b/TAO/CIAO/ChangeLog index d497cc31b8c..94f4e47cd1f 100644 --- a/TAO/CIAO/ChangeLog +++ b/TAO/CIAO/ChangeLog @@ -1,3 +1,26 @@ +Tue Apr 8 23:10:43 2003 Jeff Parsons <j.parsons@vanderbilt.edu> + + * CIDLC/parser_examples/README: + * CIDLC/parser_examples/parser_examples.sln: + * CIDLC/parser_examples/cidl/cidl.cpp: + * CIDLC/parser_examples/cidl/cidl.vcproj: + * CIDLC/parser_examples/cidl/cidl_grammar.cpp: + * CIDLC/parser_examples/cidl/cidl_grammar.h: + * CIDLC/parser_examples/cidl/hello.cidl: + * CIDLC/parser_examples/idl2/idl2.cpp: + * CIDLC/parser_examples/idl2/idl2.vcproj: + * CIDLC/parser_examples/idl2/idl2_grammar.cpp: + * CIDLC/parser_examples/idl2/idl2_grammar.h: + * CIDLC/parser_examples/idl2/test_idl2.idl: + * CIDLC/parser_examples/idl3/idl3.cpp: + * CIDLC/parser_examples/idl3/idl3.vcproj: + * CIDLC/parser_examples/idl3/idl3_grammar.cpp: + * CIDLC/parser_examples/idl3/idl3_grammar.h: + * CIDLC/parser_examples/idl3/test_idl3.idl: + + Added parser examples (IDL2, IDL3, and CIDL) using the Spirit + parser. + Tue Apr 08 19:42:16 2003 Nanbor Wang <nanbor@cs.wustl.edu> * examples/handcrafted/Display/GPS/GPS_tracing_exec.h: Fixed |