A default user interface to be used in Cuttle System
A set of language configurations to be used as default in Cuttle System
A call tree translator to be used in Cuttle System
Set dictionary_t
rules as in the following code example.
translator_t translator = {{ "mylang1", 1 },{ "mylang2", 1 }, {}};
initialize(translator.dictionary);
add(translator.dictionary,
call_tree_t{{{1u, 2u}, {}, {}, {0}}},
tokens_t{{token_type::atom, "plus"}, {token_type::macro_p, "_a"}, {token_type::macro_p, "_b"}},
[](translate_state_t &state) {
auto func_i = dictionary_funcs::function_name(state, "+");
auto a_i = dictionary_funcs::parameter(state, "_a");
auto b_i = dictionary_funcs::parameter(state, "_b");
return dictionary_funcs::function(state, func_i, {a_i, b_i});
});
add(translator.dictionary, call_tree_t{{{1u, 2u}, {}, {}, {0}}},
tokens_t{{token_type::atom, "-"}, {token_type::macro_p, "_a"}, {token_type::macro_p, "_b"}},
[](translate_state_t &state) {
auto func_i = dictionary_funcs::function_name(state, "minus");
auto a_i = dictionary_funcs::parameter(state, "_b");
auto b_i = dictionary_funcs::parameter(state, "_a");
return dictionary_funcs::function(state, func_i, {a_i, b_i});
});
values_t values;
call_tree_t new_tree;
translate(translator, tokens, tree, values, new_tree);
./scripts/get-deps.sh
cd build
cmake ..
make
A code generator to be used in Cuttle System
A code parser to be used in Cuttle System
Set tokenizer_config_t
and context_t
rules as in the following code example.
tokenizer_config_t config = {
{{"'", {"'"}}}, // formatted string
{{{"\"", {"\""}}}}, // normal string (without formatted characters)
{{"+", "+=", "-"}}, // separated symbols
{{"#", {"\n"}}}, // comments
{{{"\\s", "\n"}}}, // formatted characters
{{{"\n", "\\s"}}}, // formatted characters flipped
{{"0if"}}, // if macros symbols
{{"0ps", {"0"}}}, // function arguments
{{"0pf", {"0pf"}}}, // function call as an argument
{{"0p", {"0"}}, // function argument
false // separate digits and alpha characters
};
tokens_t tokens;
tokenize(config, input, tokens);
context_t context;
initialize(context);
add(context, "!", function_t{ function_type::postfix, 1 }, FUNCTION_ID_UNKNOWN);
add(context, "-", function_t{ function_type::infix, 2 }, 3 /* executes after what function (id) */);
add(context, "+", function_t{ function_type::infix, 2 }, 4);
add(context, "*", function_t{ function_type::infix, 2 }, 5);
call_tree_t tree;
parse(tokens, tree, context); // Output stored in tree
./scripts/get-deps.sh
cd build
cmake ..
make
A virtual machine to be used with Cuttle System as a caching engine.
C++ deque is being used as a data container. Every operation ends with \n
. Cuttle VM supports the next types of operations:
b
— push back to data deque, accepts type and value, e.g. b i 123
;f
— push from to data deque, accepts type and value, e.g. f i 123
;c
— call a function, accepts total number of arguments, number of arguments to deduce type from and function name, e.g. c 2 0 array
;l
— name the position in the code, e.g. l foo
;r
— name the position in data container, e.g. r bar
;g
— go to the position of the code if the last entry in data container is boolean true
, accepts direction(<
- backward, >
- forward) and label name, e.g. g < while_start_label
;a
— call a function with arguments from data container up to the first position with the given name, accepts position name and function name, e.g. a array_start array
.The following data types are supported:
i
— integral number data type;s
— string data type, ends with \n
, to escape it use \\n
;r
— real number data type;b
— boolean data type, true
stands for true and everything else stands false.This is an example of VM’s code:
b s foo
b i 1
c 2 2 setvar
l start
b s foo
b s foo
c 1 1 getvar
b i 1
c 2 2 +
c 2 2 setvar
b s foo
c 1 1 getvar
b i 2
c 1 1 >
g < start
b s This is a test string
#include "interpreter.hpp"
// ...
std::stringstream input("b r 100.0\nb r 101.0\nb r 19.012383");
std::deque<value_t> arg_stack;
context_t context;
interpret(input, context, arg_stack);
For the previous code the next code works:
value_t val1 = value_t{ { type_id::real },{ context.gc.add(new real_t(100.0)) } };
value_t val2 = value_t{ { type_id::real },{ context.gc.add(new real_t(101.0)) } };
value_t val3 = value_t{ { type_id::real },{ context.gc.add(new real_t(19.012383)) } };
std::deque<value_t> expected = { val1, val2, val3 };
assert(arg_stack == expected);
./scripts/get-deps.sh
if you don’t have ssh authorization./scripts/get-deps.sh dev
if you have ssh authorizationcd build
cmake ..
make