cli.hpp
上传用户:egreat
上传日期:2007-07-13
资源大小:29k
文件大小:1k
- #ifndef _CLI_HPP_
- #define _CLI_HPP_
- #include <boost/spirit/core.hpp>
- #include <iostream>
- #include <string>
- #include "stock.h"
- ///////////////////////////////////////////////////////////////////////////////
- using namespace std;
- using namespace boost::spirit;
- #if 0
- struct cli_action
- {
- template <typename IteratorT>
- void
- operator()( IteratorT first, IteratorT last ) const
- {
- string s( first, last );
- cout << "tMy Action got: " << s << endl;
- }
- };
- #endif
- ///////////////////////////////////////////////////////////////////////////////
- //
- // My grammar
- //
- ///////////////////////////////////////////////////////////////////////////////
- struct cli_grammar : public grammar<cli_grammar>
- {
- template <typename ScannerT>
- struct definition
- {
- definition( cli_grammar const & self )
- {
- node1 = str_p("show");
- node2 = space_p >> str_p("request");
- node3 = str_p("test");
- root = node1 >> node2[&show_curr_bid];
- }
- rule<ScannerT> root;
- rule<ScannerT> node1;
- rule<ScannerT> node2;
- rule<ScannerT> node3;
- rule<ScannerT> node4;
- rule<ScannerT> const &
- start() const
- {
- return root;
- }
- };
- };
- #endif