diff options
Diffstat (limited to 'CIAO/CCF/CCF/IDL2/Parsing')
-rw-r--r-- | CIAO/CCF/CCF/IDL2/Parsing/Action.hpp | 142 | ||||
-rw-r--r-- | CIAO/CCF/CCF/IDL2/Parsing/Elements.hpp | 168 | ||||
-rw-r--r-- | CIAO/CCF/CCF/IDL2/Parsing/Recovery.hpp | 325 |
3 files changed, 0 insertions, 635 deletions
diff --git a/CIAO/CCF/CCF/IDL2/Parsing/Action.hpp b/CIAO/CCF/CCF/IDL2/Parsing/Action.hpp deleted file mode 100644 index 2737abafb58..00000000000 --- a/CIAO/CCF/CCF/IDL2/Parsing/Action.hpp +++ /dev/null @@ -1,142 +0,0 @@ -// file : CCF/IDL2/Parsing/Action.hpp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -#ifndef CCF_IDL2_PARSING_ACTION_HPP -#define CCF_IDL2_PARSING_ACTION_HPP - -#include "CCF/IDL2/Parsing/Elements.hpp" - -namespace CCF -{ - namespace IDL2 - { - namespace Parsing - { - // - // - // - template <typename Obj> - class ActionExecutor - { - public: - - typedef - void (Obj::*SemanticAction)(Iterator, Iterator) const; - - ActionExecutor (Obj const* obj, SemanticAction action) - : obj_ (obj), action_ (action) - { - } - - void operator () (Iterator begin, Iterator end) const - { - (obj_->*action_) (begin, end); - } - - private: - Obj const* obj_; - SemanticAction action_; - }; - - - // - // - // - template <typename Obj> - class NoArgAction - { - public: - - typedef - void (Obj::*Action)(); - - NoArgAction (Obj& obj, Action action) - : obj_ (obj), action_ (action) - { - } - - void operator () (Iterator, Iterator) const - { - (obj_.*action_) (); - } - - private: - Obj& obj_; - Action action_; - }; - - - //@@ Should prbably use Type instead of TypePtr - // - // - // - template <typename TypePtr, typename Obj> - class OneArgAction - { - public: - - typedef - void (Obj::*Action)(TypePtr const&); - - OneArgAction (Obj& obj, Action action) - : obj_ (obj), action_ (action) - { - } - - void operator () (Iterator begin, Iterator end) const - { - if (end - begin != 1 ) - { - //@@ throw - } - - //@@ error handling if the strict_cast fails - (obj_.*action_) ( - ReferenceCounting::strict_cast<typename TypePtr::Type> (*begin)); - } - - private: - Obj& obj_; - Action action_; - }; - - - // - // - // - template <typename Arg1, typename Arg2, typename Obj> - class TwoArgAction - { - public: - - typedef - void (Obj::*Action)(Arg1 const&, Arg2 const&); - - TwoArgAction (Obj& obj, Action action) - : obj_ (obj), action_ (action) - { - } - - void operator () (Iterator begin, Iterator end) const - { - if (end - begin != 2 ) - { - //@@ throw - } - - //@@ error handling if strict_cast fails - (obj_.*action_) ( - ReferenceCounting::strict_cast<typename Arg1::Type> (*begin), - ReferenceCounting::strict_cast<typename Arg2::Type> (*(begin + 1))); - } - - private: - Obj& obj_; - Action action_; - }; - } - } -} - -#endif // CCF_IDL2_PARSING_ACTION_HPP diff --git a/CIAO/CCF/CCF/IDL2/Parsing/Elements.hpp b/CIAO/CCF/CCF/IDL2/Parsing/Elements.hpp deleted file mode 100644 index 88e091d8845..00000000000 --- a/CIAO/CCF/CCF/IDL2/Parsing/Elements.hpp +++ /dev/null @@ -1,168 +0,0 @@ -// file : CCF/IDL2/Parsing/Elements.hpp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -#ifndef CCF_IDL2_PARSING_ELEMENTS_HPP -#define CCF_IDL2_PARSING_ELEMENTS_HPP - -#include <string> - -#include <boost/spirit.hpp> - -#include "CCF/IDL2/Token.hpp" - -namespace CCF -{ - namespace IDL2 - { - namespace Parsing - { - using namespace boost::spirit; - - typedef - TokenList::iterator - Iterator; - - typedef - scanner<Iterator, scanner_policies<> > - Scanner; - - typedef - rule<Scanner> - Rule; - - - // - // - // - template <typename Type> - struct IdentityParser : public parser <IdentityParser<Type> > - { - typedef - IdentityParser - self_t; - - IdentityParser (std::string lexeme) - : lexeme_ (lexeme) - { - } - - typename parser_result<self_t, Scanner>::type - parse(Scanner const& scan) const - { - if (!scan.at_end()) - { - TokenPtr t = *scan; - - if(ReferenceCounting::strict_cast<Type> (t) != 0 && - lexeme_ == t->lexeme ()) - { - Iterator save(scan.first); - ++scan; - return scan.create_match(1, t, save, scan.first); - } - } - return scan.no_match(); - } - - private: - std::string lexeme_; - }; - - typedef - IdentityParser<Keyword> - KeywordParser; - - typedef - IdentityParser<Punctuation> - PunctuationParser; - - typedef - IdentityParser<Operator> - OperatorParser; - - // - // - // - template <typename Type> - struct TypeParser : public parser <TypeParser<Type> > - { - typedef - TypeParser - self_t; - - typename parser_result<self_t, Scanner>::type - parse(Scanner const& scan) const - { - if (!scan.at_end()) - { - TokenPtr t = *scan; - - if(ReferenceCounting::strict_cast<Type> (t) != 0) - { - Iterator save(scan.first); - ++scan; - return scan.create_match(1, t, save, scan.first); - } - } - return scan.no_match(); - } - }; - - typedef - TypeParser<EndOfStream> - EndOfStreamParser; - - typedef - TypeParser<Identifier> - IdentifierParser; - - typedef - TypeParser<SimpleIdentifier> - SimpleIdentifierParser; - - typedef - TypeParser<ScopedIdentifier> - ScopedIdentifierParser; - - // Literal parsers. - // - - typedef - TypeParser<BooleanLiteral> - BooleanLiteralParser; - - typedef - TypeParser<CharacterLiteral> - CharacterLiteralParser; - - typedef - TypeParser<IntegerLiteral> - IntegerLiteralParser; - - typedef - TypeParser<StringLiteral> - StringLiteralParser; - - // - // - // - inline bool - parse (Iterator const& first_, - Iterator const& last, - Rule const& rule) - { - Iterator first = first_; - Scanner scan(first, last); - match<nil_t> hit = rule.parse(scan); - - bool result = parse_info<Iterator>( - first, hit, hit && (first == last), hit.length()).full; - - return result; - } - } - } -} - -#endif // CCF_IDL2_PARSING_ELEMENTS_HPP diff --git a/CIAO/CCF/CCF/IDL2/Parsing/Recovery.hpp b/CIAO/CCF/CCF/IDL2/Parsing/Recovery.hpp deleted file mode 100644 index d8b3739b335..00000000000 --- a/CIAO/CCF/CCF/IDL2/Parsing/Recovery.hpp +++ /dev/null @@ -1,325 +0,0 @@ -// file : CCF/IDL2/Parsing/Recovery.hpp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -#ifndef CCF_IDL2_PARSING_RECOVERY_HPP -#define CCF_IDL2_PARSING_RECOVERY_HPP - -#include <memory> - -#include "CCF/CompilerElements/ReferenceCounting.hpp" -#include "CCF/IDL2/Parsing/Elements.hpp" - -namespace CCF -{ - namespace IDL2 - { - namespace Parsing - { - - // - // - // - struct RecoveryMethod - { - enum Value - { - NONE, - STANDARD, - BAIL_OUT - }; - }; - - - // - // - // - struct DiagnosticType - { - enum Value - { - BEFORE, - AFTER, - NONE - }; - }; - - - // - // - // - class Thunk - { - public: - virtual - ~Thunk () {} - - virtual void - execute () = 0; - - virtual Thunk* - clone () const = 0; - }; - - - // - // - // - template<typename Object> - class ThunkImpl : public Thunk - { - public: - typedef void (Object::*Func)(); - - ThunkImpl (Object& obj, Func func) - : obj_(obj), - func_ (func) - { - } - - virtual void - execute () - { - (obj_.*func_)(); - } - - virtual Thunk* - clone () const - { - return new ThunkImpl<Object> (obj_, func_); - } - - private: - Object& obj_; - Func func_; - }; - - // - // - // - template<typename Object> - Thunk* - call_thunk (Object& obj, void (Object::*func)()) - { - return new ThunkImpl<Object> (obj, func); - } - - - // - // - // - struct RecoveryDescriptor : - public virtual ReferenceCounting::DefaultImpl <> - { - virtual ~RecoveryDescriptor () throw () {} - - RecoveryDescriptor (std::string d, - RecoveryMethod::Value recovery, - DiagnosticType::Value diagnostic) - : action_one_ (0), - action_two_ (0), - description_ (d), - recovery_ (recovery), - diagnostic_ (diagnostic) - { - } - - template<typename Object> - RecoveryDescriptor (std::string d, - RecoveryMethod::Value recovery, - DiagnosticType::Value diagnostic, - Object& obj, - void (Object::*action_one)()) - : action_one_ (call_thunk (obj, action_one)), - action_two_ (0), - description_ (d), - recovery_ (recovery), - diagnostic_ (diagnostic) - { - } - - template<typename Object> - RecoveryDescriptor (std::string d, - RecoveryMethod::Value recovery, - DiagnosticType::Value diagnostic, - Object& obj, - void (Object::*action_one)(), - void (Object::*action_two)()) - : action_one_ (call_thunk (obj, action_one)), - action_two_ (call_thunk (obj, action_two)), - description_ (d), - recovery_ (recovery), - diagnostic_ (diagnostic) - { - } - - RecoveryDescriptor (RecoveryDescriptor const& rd) - : action_one_ (rd.action_one_.get () ? rd.action_one_->clone () : 0), - action_two_ (rd.action_two_.get () ? rd.action_two_->clone () : 0), - description_ (rd.description_), - recovery_ (rd.recovery_), - diagnostic_ (rd.diagnostic_) - { - } - - - std::auto_ptr<Thunk> action_one_; - std::auto_ptr<Thunk> action_two_; - std::string description_; - RecoveryMethod::Value recovery_; - DiagnosticType::Value diagnostic_; - }; - - typedef - ReferenceCounting::StrictPtr<RecoveryDescriptor> - RecoveryDescriptorPtr; - - - // I have to use a pointer to RecoveryDescriptor instead of - // just RecoveryDescriptor to subvert constness of descriptor - // member in spirit::parser_error. - // - // - - typedef - parser_error<RecoveryDescriptorPtr, Iterator> - Error; - - - // - // - // - struct Assertion - { - typedef - assertion<RecoveryDescriptorPtr> - AssertionImpl; - - AssertionImpl - operator () (RecoveryMethod::Value recovery = RecoveryMethod::NONE) - { - return AssertionImpl ( - RecoveryDescriptorPtr ( - new RecoveryDescriptor ("", recovery, DiagnosticType::NONE))); - } - - AssertionImpl - operator () (std::string d, - RecoveryMethod::Value recovery = RecoveryMethod::STANDARD, - DiagnosticType::Value diagnostic = DiagnosticType::AFTER) - { - return AssertionImpl ( - RecoveryDescriptorPtr ( - new RecoveryDescriptor (d, recovery, diagnostic))); - } - - AssertionImpl - operator () (std::string d, - DiagnosticType::Value diagnostic) - { - return AssertionImpl ( - RecoveryDescriptorPtr ( - new RecoveryDescriptor ( - d, RecoveryMethod::STANDARD, diagnostic))); - } - - template<typename Object> - AssertionImpl - operator () (std::string d, - Object& obj, - void (Object::*action_one)(), - RecoveryMethod::Value recovery = RecoveryMethod::STANDARD, - DiagnosticType::Value diagnostic = DiagnosticType::AFTER) - { - return AssertionImpl ( - RecoveryDescriptorPtr ( - new RecoveryDescriptor ( - d, recovery, diagnostic, obj, action_one))); - } - - template<typename Object> - AssertionImpl - operator () (std::string d, - Object& obj, - void (Object::*action_one)(), - DiagnosticType::Value diagnostic) - { - return AssertionImpl ( - RecoveryDescriptorPtr ( - new RecoveryDescriptor ( - d, RecoveryMethod::STANDARD, diagnostic, obj, action_one))); - } - - template<typename Object> - AssertionImpl - operator () (Object& obj, - void (Object::*action_one)(), - RecoveryMethod::Value recovery = RecoveryMethod::BAIL_OUT) - { - return AssertionImpl ( - RecoveryDescriptorPtr ( - new RecoveryDescriptor ( - "", recovery, DiagnosticType::NONE, obj, action_one))); - } - - template<typename Object> - AssertionImpl - operator () (std::string d, - Object& obj, - void (Object::*action_one)(), - void (Object::*action_two)(), - RecoveryMethod::Value recovery = RecoveryMethod::STANDARD, - DiagnosticType::Value diagnostic = DiagnosticType::AFTER) - { - return AssertionImpl ( - RecoveryDescriptorPtr ( - new RecoveryDescriptor ( - d, recovery, diagnostic, obj, action_one, action_two))); - } - - template<typename Object> - AssertionImpl - operator () (std::string d, - Object& obj, - void (Object::*action_one)(), - void (Object::*action_two)(), - DiagnosticType::Value diagnostic) - { - return AssertionImpl ( - RecoveryDescriptorPtr ( - new RecoveryDescriptor ( - d, RecoveryMethod::STANDARD, diagnostic, obj, action_one, action_two))); - } - - - template<typename Object> - AssertionImpl - operator () (Object& obj, - void (Object::*action_one)(), - void (Object::*action_two)(), - RecoveryMethod::Value recovery = RecoveryMethod::BAIL_OUT) - { - return AssertionImpl ( - RecoveryDescriptorPtr ( - new RecoveryDescriptor ("", - recovery, - DiagnosticType::NONE, - obj, - action_one, - action_two))); - } - - }; - - typedef - error_status<> - RecoveryStatus; - - typedef - guard<RecoveryDescriptorPtr> - Guard; - } - } -} - -#endif // CCF_IDL2_PARSING_RECOVERY_HPP |