A Tcl like command language made for the Clinl kernel testing
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

48 lignes
1.2 KiB

/*#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"
*/
#include "crank.h"
#include <iostream>
#include <string>
kstd::string_view put(kstd::string_view args, crank_context& ctx)
{
args = skip_whitespace(args);
auto key = extract_token(args);
auto value = skip_linearspace(kstd::string_view(args.begin()+key.size(),args.end()));
for(auto c : args)
std::cout<<c;
return ctx.store(key,value);
}
int main()
{
const char* putstext = "puts";
std::string get="";
crank_context ctx;
ctx.add_native(kstd::string_view((char*)putstext,4), put);
std::cout<<"> ";
while((std::getline(std::cin,get)).good())
{
auto ret = ctx.eval(kstd::string_view(get.data(), get.size()));
std::cout<<"&> ";
for(auto c : ret)
std::cout<<c;
std::cout<<std::endl<<"> ";
ctx.collect();
}
}
/*
TEST_CASE("crank")
{
crank_context ctx;
static const char* setter_code = "set sample \"Hello world\"";
kstd::string_view setter_c{(char*)setter_code, 24};
ctx.eval_no_copy(setter_c);
static const char* getter_code = "$sample";
kstd::string_view getter_c{(char*)getter_code, 7};
ctx.eval_no_copy(getter_c);
}*/