|
@ -6,29 +6,30 @@ |
|
|
#include <iostream>
|
|
|
#include <iostream>
|
|
|
#include <string>
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
kstd::string_view set2(kstd::string_view args, crank_context& ctx) |
|
|
|
|
|
|
|
|
kstd::string_view put(kstd::string_view args, crank_context& ctx) |
|
|
{ |
|
|
{ |
|
|
args = skip_whitespace(args); |
|
|
args = skip_whitespace(args); |
|
|
auto key = extract_token(args); |
|
|
auto key = extract_token(args); |
|
|
auto value = skip_linearspace(kstd::string_view(args.begin()+key.size(),args.end())); |
|
|
auto value = skip_linearspace(kstd::string_view(args.begin()+key.size(),args.end())); |
|
|
for(auto c : value) |
|
|
|
|
|
|
|
|
for(auto c : args) |
|
|
std::cout<<c; |
|
|
std::cout<<c; |
|
|
std::cout<<" out:"<<value.size()<<std::endl; |
|
|
|
|
|
return ctx.store(key,value); |
|
|
return ctx.store(key,value); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int main() |
|
|
int main() |
|
|
{ |
|
|
{ |
|
|
const char* set2text = "set2"; |
|
|
|
|
|
|
|
|
const char* putstext = "puts"; |
|
|
std::string get=""; |
|
|
std::string get=""; |
|
|
crank_context ctx; |
|
|
crank_context ctx; |
|
|
ctx.add_native(kstd::string_view((char*)set2text,4), set2); |
|
|
|
|
|
|
|
|
ctx.add_native(kstd::string_view((char*)putstext,4), put); |
|
|
|
|
|
std::cout<<"> "; |
|
|
while((std::getline(std::cin,get)).good()) |
|
|
while((std::getline(std::cin,get)).good()) |
|
|
{ |
|
|
{ |
|
|
auto ret = ctx.eval(kstd::string_view(get.data(), get.size())); |
|
|
auto ret = ctx.eval(kstd::string_view(get.data(), get.size())); |
|
|
|
|
|
std::cout<<"&> "; |
|
|
for(auto c : ret) |
|
|
for(auto c : ret) |
|
|
std::cout<<c; |
|
|
std::cout<<c; |
|
|
std::cout<<sa">" out:"<<ret.size()<<std::endl; |
|
|
|
|
|
|
|
|
std::cout<<n">std::endl<<"> "; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|