Add a new implementation struct with only one function.
This commit is contained in:
16
include/impl.h
Normal file
16
include/impl.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef LIBABACUS_IMPL_H
|
||||
#define LIBABACUS_IMPL_H
|
||||
|
||||
/**
|
||||
* Implementation functions for things like numbers.
|
||||
*/
|
||||
struct libab_impl_s {
|
||||
/**
|
||||
* Function to parse a number from a string.
|
||||
*/
|
||||
void* (*parse_num)(const char*);
|
||||
};
|
||||
|
||||
typedef struct libab_impl_s libab_impl;
|
||||
|
||||
#endif
|
||||
@@ -3,15 +3,18 @@
|
||||
|
||||
#include "table.h"
|
||||
#include "tree.h"
|
||||
#include "impl.h"
|
||||
|
||||
struct libab_interpreter_s {
|
||||
libab_ref base_table;
|
||||
libab_impl* impl;
|
||||
};
|
||||
|
||||
typedef struct libab_interpreter_s libab_interpreter;
|
||||
|
||||
void libab_interpreter_init(libab_interpreter* intr,
|
||||
libab_ref* table);
|
||||
libab_ref* table,
|
||||
libab_impl* impl);
|
||||
libab_result libab_interpreter_run(libab_interpreter* intr,
|
||||
libab_tree* tree, libab_ref* into);
|
||||
void libab_interpreter_free(libab_interpreter* intr);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "interpreter.h"
|
||||
#include "result.h"
|
||||
#include "table.h"
|
||||
#include "impl.h"
|
||||
|
||||
/**
|
||||
* The main struct of libabacus,
|
||||
@@ -35,6 +36,11 @@ struct libab_s {
|
||||
* things like functions and operators.
|
||||
*/
|
||||
libab_ref table;
|
||||
|
||||
/**
|
||||
* The allocator used to construct number instances.
|
||||
*/
|
||||
libab_impl impl;
|
||||
};
|
||||
|
||||
typedef struct libab_s libab;
|
||||
|
||||
Reference in New Issue
Block a user