#include "operators.hpp" #include #include DEF_TERMINAL( MyTerminal , "asdfasdf" ) int main() { //compile time parsing constexpr const_string< char > cstr = "2 + 54 * 2 + 83"; constexpr addition a( cstr ); static_assert( a.eval() == 193 , ""); constexpr const_string< char > cstr2 = "asd fasdf"; constexpr MyTerminal t( cstr2 ); static_assert( !t.valid() , "" ); //run time parsing, but I guess this is very inefficient std::string str; std::cin >> str; const_string< char > cstr3( &*str.begin() , &*str.end() ); addition a_run_time( cstr3 ); if( a_run_time.end() == str.size() ) std::cout << a_run_time.eval() << std::endl; else std::cout << "parse error" << std::endl; }