xo-interpreter2: refactor to setup vsm utest + repl
This commit is contained in:
parent
a10c7dcab2
commit
a71060bb75
4 changed files with 86 additions and 1 deletions
|
|
@ -14,6 +14,23 @@
|
|||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** similar to @ref xo::scm::ReaderResult **/
|
||||
struct VsmResult {
|
||||
using AGCObject = xo::mm::AGCObject;
|
||||
using span_type = xo::mm::span<const char>;
|
||||
|
||||
bool is_tk_error() const { return tk_error_.is_error(); }
|
||||
|
||||
/** result of evaluating first expression encountered in input **/
|
||||
obj<AGCObject> value_;
|
||||
|
||||
/** unconsumed portion of input span **/
|
||||
span_type remaining_input_;
|
||||
|
||||
/** {src_function, error_description, input_state, error_pos} **/
|
||||
TokenizerError tk_error_;
|
||||
};
|
||||
|
||||
/** @class VirtualSchematikaMachine
|
||||
* @brief virtual machine for schematika
|
||||
**/
|
||||
|
|
@ -23,10 +40,17 @@ namespace xo {
|
|||
using Stack = void *;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using AGCObject = xo::mm::AGCObject;
|
||||
using span_type = xo::mm::span<const char>;
|
||||
|
||||
public:
|
||||
VirtualSchematikaMachine(const VsmConfig & config);
|
||||
|
||||
/** consume input @p input_cstr **/
|
||||
VsmResult read_eval_print(span_type input_span, bool eof);
|
||||
|
||||
/** evaluate expression @p expr **/
|
||||
std::pair<obj<AGCObject>, TokenizerError> eval(obj<AExpression> expr);
|
||||
|
||||
/** borrow calling thread to run indefinitely,
|
||||
* until halt instruction
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@
|
|||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** Configuration for virtual schematika machine
|
||||
/** Configuration for virtual schematika machine
|
||||
**/
|
||||
struct VsmConfig {
|
||||
using X1CollectorConfig = xo::mm::X1CollectorConfig;
|
||||
|
||||
VsmConfig() = default;
|
||||
|
||||
/** reader configuration **/
|
||||
ReaderConfig rdr_config_;
|
||||
/** Configuration for allocator/collector.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue