X-Git-Url: http://g0dil.de/git?p=senf.git;a=blobdiff_plain;f=senf%2FUtils%2FConsole%2FParse.ih;fp=senf%2FUtils%2FConsole%2FParse.ih;h=a2dc6b3167f8c90d50a0f8c555141768e4ee32e5;hp=5fc5c5c849fc805578ae5d11dc75788219ed8d33;hb=74febc7a9abc84c4939269b3443d15fc27f4e960;hpb=9de1568365b7ac411b84da000e18516d9c3b3293 diff --git a/senf/Utils/Console/Parse.ih b/senf/Utils/Console/Parse.ih index 5fc5c5c..a2dc6b3 100644 --- a/senf/Utils/Console/Parse.ih +++ b/senf/Utils/Console/Parse.ih @@ -126,12 +126,30 @@ namespace detail { //-///////////////////////////////////////////////////////////////////////////////////////// // charachter sets - static boost_spirit::chset<> special_p; - static boost_spirit::chset<> punctuation_p; - static boost_spirit::chset<> space_p; - static boost_spirit::chset<> invalid_p; - static boost_spirit::chset<> word_p; - static boost_spirit::distinct_parser<> keyword_p; + static boost_spirit::chset<> & special_p() { + static boost_spirit::chset<> p ("/(){};\""); + return p; + } + static boost_spirit::chset<> & punctuation_p() { + static boost_spirit::chset<> p (",="); + return p; + } + static boost_spirit::chset<> & space_p() { + static boost_spirit::chset<> p (" \t\n\r"); + return p; + } + static boost_spirit::chset<> & invalid_p() { + static boost_spirit::chset<> p ((boost_spirit::chset<>('\0') | boost_spirit::chset<>("\x01-\x20")) - space_p() ); + return p; + } + static boost_spirit::chset<> & word_p() { + static boost_spirit::chset<> p (boost_spirit::anychar_p - special_p() - punctuation_p() - space_p() - invalid_p()); + return p; + } + static boost_spirit::distinct_parser<> & keyword_p() { + static boost_spirit::distinct_parser<> p (word_p() | boost_spirit::ch_p('/')); + return p; + } //-///////////////////////////////////////////////////////////////////////////////////////// // Errors @@ -234,20 +252,20 @@ namespace detail { ; builtin - = self.keyword_p("cd") + = self.keyword_p()("cd") >> path_expected(path) >> eps_p [ bind(&PD::builtin_cd)(d_, path_) ] - | self.keyword_p("ls") + | self.keyword_p()("ls") >> ! path >> eps_p [ bind(&PD::builtin_ls)(d_, path_) ] - | self.keyword_p("ll") + | self.keyword_p()("ll") >> ! path >> eps_p [ bind(&PD::builtin_ll)(d_, path_) ] - | self.keyword_p("lr") + | self.keyword_p()("lr") >> ! path >> eps_p [ bind(&PD::builtin_lr)(d_, path_) ] - | self.keyword_p("exit") [ bind(&PD::builtin_exit)(d_) ] - | self.keyword_p("help") + | self.keyword_p()("exit") [ bind(&PD::builtin_exit)(d_) ] + | self.keyword_p()("help") >> ! path >> eps_p [ bind(&PD::builtin_help)(d_, path_) ] ; @@ -361,7 +379,7 @@ namespace detail { | ch_p(';') [ token_ = construct_( Token::CommandTerminator, ";") ] - | self.punctuation_p [ token_ = construct_( + | self.punctuation_p() [ token_ = construct_( Token::OtherPunctuation, construct_(1u, arg1), pos_) ] @@ -372,7 +390,7 @@ namespace detail { = eps_p [ pos_ = positionOf(arg1) ] >> lexeme_d [ - (+ self.word_p) [ str_ = construct_(arg1, arg2) ] + (+ self.word_p()) [ str_ = construct_(arg1, arg2) ] ] >> eps_p [ token_ = construct_( Token::Word, @@ -401,12 +419,12 @@ namespace detail { ; skip - = self.space_p | comment_p('#') + = self.space_p() | comment_p('#') ; //-///////////////////////////////////////////////////////////////////////////////// - start_parsers( + this->start_parsers( command, // CommandParser skip, // SkipParser arguments, // ArgumentsParser @@ -435,19 +453,6 @@ namespace detail { }; }; - template boost_spirit::chset<> CommandGrammar::special_p ( - "/(){};\""); - template boost_spirit::chset<> CommandGrammar::punctuation_p ( - ",="); - template boost_spirit::chset<> CommandGrammar::space_p ( - " \t\n\r"); - template boost_spirit::chset<> CommandGrammar::invalid_p ( - (boost_spirit::chset<>('\0') | boost_spirit::chset<>("\x01-\x20")) - space_p ); - template boost_spirit::chset<> CommandGrammar::word_p ( - boost_spirit::anychar_p - special_p - punctuation_p - space_p - invalid_p); - template boost_spirit::distinct_parser<> CommandGrammar::keyword_p ( - word_p | boost_spirit::ch_p('/')); - #endif }}}