mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-23 02:14:13 +00:00
lrec_evaluator -> rval_evaluator
This commit is contained in:
parent
5b564c695f
commit
58bf2f0ee2
17 changed files with 784 additions and 784 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -7,7 +7,7 @@ test-byte-readers
|
|||
test-join-bucket-keeper
|
||||
test-json-parser
|
||||
test-lrec
|
||||
test-lrec-evaluators
|
||||
test-rval-evaluators
|
||||
test-mlhmmv
|
||||
test-mlrregex
|
||||
test-mlrutil
|
||||
|
|
@ -15,7 +15,7 @@ test-multiple-containers
|
|||
test-parse-trie
|
||||
test-peek-file-reader
|
||||
test-string-builder
|
||||
test_lrec_evaluators
|
||||
test_rval_evaluators
|
||||
test_argparse
|
||||
test_byte_readers
|
||||
test_join_bucket_keeper
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ TEST_PARSE_TRIE_SRCS = \
|
|||
containers/parse_trie.c \
|
||||
unit_test/test_parse_trie.c
|
||||
|
||||
TEST_LREC_EVALUATORS_SRCS = \
|
||||
TEST_RVAL_EVALUATORS_SRCS = \
|
||||
lib/mlr_globals.c \
|
||||
lib/mlrutil.c \
|
||||
lib/mlrregex.c \
|
||||
|
|
@ -204,8 +204,8 @@ TEST_LREC_EVALUATORS_SRCS = \
|
|||
containers/lrec.c \
|
||||
containers/lhmsv.c \
|
||||
containers/mlhmmv.c \
|
||||
mapping/lrec_evaluators.c \
|
||||
unit_test/test_lrec_evaluators.c
|
||||
mapping/rval_evaluators.c \
|
||||
unit_test/test_rval_evaluators.c
|
||||
|
||||
TEST_JOIN_BUCKET_KEEPER_SRCS = \
|
||||
lib/mlrutil.c \
|
||||
|
|
@ -303,7 +303,7 @@ mlrp: .always dsls
|
|||
# ================================================================
|
||||
tests: unit-test reg-test
|
||||
|
||||
unit-test: test-mlrutil test-mlrregex test-argparse test-byte-readers test-peek-file-reader test-parse-trie test-lrec test-multiple-containers test-mlhmmv test-string-builder test-lrec-evaluators test-join-bucket-keeper
|
||||
unit-test: test-mlrutil test-mlrregex test-argparse test-byte-readers test-peek-file-reader test-parse-trie test-lrec test-multiple-containers test-mlhmmv test-string-builder test-rval-evaluators test-join-bucket-keeper
|
||||
./test-mlrutil
|
||||
./test-mlrregex
|
||||
./test-argparse
|
||||
|
|
@ -314,7 +314,7 @@ unit-test: test-mlrutil test-mlrregex test-argparse test-byte-readers test-peek-
|
|||
./test-multiple-containers
|
||||
./test-mlhmmv
|
||||
./test-string-builder
|
||||
./test-lrec-evaluators
|
||||
./test-rval-evaluators
|
||||
./test-join-bucket-keeper
|
||||
@echo
|
||||
@echo DONE
|
||||
|
|
@ -361,8 +361,8 @@ test-string-builder: .always
|
|||
test-parse-trie: .always
|
||||
$(CCDEBUG) $(TEST_PARSE_TRIE_SRCS) -o test-parse-trie
|
||||
|
||||
test-lrec-evaluators: .always
|
||||
$(CCDEBUG) $(TEST_LREC_EVALUATORS_SRCS) -o test-lrec-evaluators -lm
|
||||
test-rval-evaluators: .always
|
||||
$(CCDEBUG) $(TEST_RVAL_EVALUATORS_SRCS) -o test-rval-evaluators -lm
|
||||
|
||||
test-join-bucket-keeper: .always
|
||||
$(CCDEBUG) $(TEST_JOIN_BUCKET_KEEPER_SRCS) -o test-join-bucket-keeper -lm
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include "containers/lhmsi.h"
|
||||
#include "input/lrec_readers.h"
|
||||
#include "mapping/mappers.h"
|
||||
#include "mapping/lrec_evaluators.h"
|
||||
#include "mapping/rval_evaluators.h"
|
||||
#include "output/lrec_writers.h"
|
||||
#include "cli/mlrcli.h"
|
||||
#include "cli/quoting.h"
|
||||
|
|
@ -260,7 +260,7 @@ static void main_usage_help_options(FILE* o, char* argv0) {
|
|||
}
|
||||
|
||||
static void main_usage_functions(FILE* o, char* argv0, char* leader) {
|
||||
lrec_evaluator_list_functions(o, leader);
|
||||
rval_evaluator_list_functions(o, leader);
|
||||
fprintf(o, "Please use \"%s --help-function {function name}\" for function-specific help.\n", argv0);
|
||||
fprintf(o, "Please use \"%s --help-all-functions\" or \"%s -f\" for help on all functions.\n", argv0, argv0);
|
||||
}
|
||||
|
|
@ -637,15 +637,15 @@ cli_opts_t* parse_command_line(int argc, char** argv) {
|
|||
list_all_verbs_raw(stdout);
|
||||
exit(0);
|
||||
} else if (streq(argv[argi], "--list-all-functions-raw")) {
|
||||
lrec_evaluator_list_all_functions_raw(stdout);
|
||||
rval_evaluator_list_all_functions_raw(stdout);
|
||||
exit(0);
|
||||
} else if (streq(argv[argi], "--help-all-functions") || streq(argv[argi], "-f")) {
|
||||
lrec_evaluator_function_usage(stdout, NULL);
|
||||
rval_evaluator_function_usage(stdout, NULL);
|
||||
exit(0);
|
||||
|
||||
} else if (streq(argv[argi], "--help-function") || streq(argv[argi], "--hf")) {
|
||||
check_arg_count(argv, argi, argc, 2);
|
||||
lrec_evaluator_function_usage(stdout, argv[argi+1]);
|
||||
rval_evaluator_function_usage(stdout, argv[argi+1]);
|
||||
exit(0);
|
||||
|
||||
// main-usage subsections, individually accessible for the benefit of
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@
|
|||
// functions and I chose not to write out so many prototypes: they would have
|
||||
// made things less clear by their very volume.
|
||||
//
|
||||
// * Comparison to lrec_evaluators.c: this file is functions from mlrval(s) to
|
||||
// mlrval; in lrec_evaluators.c we have the higher-level notion of
|
||||
// * Comparison to rval_evaluators.c: this file is functions from mlrval(s) to
|
||||
// mlrval; in rval_evaluators.c we have the higher-level notion of
|
||||
// evaluating lrec objects, using mlrval.c to do so.
|
||||
//
|
||||
// * There are two kinds of functions here: those with _x_ in their names
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
// ================================================================
|
||||
// MT for Miller type -- highly abbreviated here since these are
|
||||
// spelled out a lot in lrec_evaluators.c.
|
||||
// spelled out a lot in rval_evaluators.c.
|
||||
//
|
||||
// ================================================================
|
||||
// NOTE: mlrval functions invalidate their arguments. In particular, dynamically
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
noinst_LTLIBRARIES= libmapping.la
|
||||
libmapping_la_SOURCES= \
|
||||
lrec_evaluator.h \
|
||||
lrec_evaluators.c \
|
||||
lrec_evaluators.h \
|
||||
rval_evaluator.h \
|
||||
rval_evaluators.c \
|
||||
rval_evaluators.h \
|
||||
mapper.h \
|
||||
mapper_bar.c \
|
||||
mapper_bootstrap.c \
|
||||
|
|
@ -46,7 +46,7 @@ libmapping_la_LIBADD= ../lib/libmlr.la ../cli/libcli.la ../input/libinput.la
|
|||
# TODO: replace the interesting content with unit tests; jettison the rest
|
||||
# TODO: Does not build
|
||||
#noinst_PROGRAMS= evl
|
||||
#evl_SOURCES= lrec_evaluators.c
|
||||
#evl_SOURCES= rval_evaluators.c
|
||||
#evl_LDADD= libmapping.la ../containers/libcontainers.la ../lib/libmlr.la
|
||||
#evl_CPPFLAGS= -D__LREC_EVALUATORS_MAIN__ ${AM_CPPFLAGS}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
#ifndef LREC_EVALUATORS_H
|
||||
#define LREC_EVALUATORS_H
|
||||
#include <stdio.h>
|
||||
#include "containers/mlr_dsl_ast.h"
|
||||
#include "mapping/lrec_evaluator.h"
|
||||
|
||||
#define TYPE_INFER_STRING_FLOAT_INT 0xce08
|
||||
#define TYPE_INFER_STRING_FLOAT 0xce09
|
||||
#define TYPE_INFER_STRING_ONLY 0xce0a
|
||||
|
||||
lrec_evaluator_t* lrec_evaluator_alloc_from_ast(mlr_dsl_ast_node_t* past, int type_inferencing);
|
||||
lrec_evaluator_t* lrec_evaluator_alloc_from_string(char* string);
|
||||
|
||||
void lrec_evaluator_list_functions(FILE* output_stream, char* leader);
|
||||
// Pass function_name == NULL to get usage for all functions:
|
||||
void lrec_evaluator_function_usage(FILE* output_stream, char* function_name);
|
||||
void lrec_evaluator_list_all_functions_raw(FILE* output_stream);
|
||||
|
||||
int test_lrec_evaluators_main(int argc, char **argv);
|
||||
|
||||
#endif // LREC_FEVALUATORS_H
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#include "lib/mlrutil.h"
|
||||
#include "containers/lrec.h"
|
||||
#include "containers/sllv.h"
|
||||
#include "mapping/lrec_evaluators.h"
|
||||
#include "mapping/rval_evaluators.h"
|
||||
#include "mapping/mappers.h"
|
||||
#include "dsls/mlr_dsl_wrapper.h"
|
||||
#include "cli/argparse.h"
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
typedef struct _mapper_filter_state_t {
|
||||
ap_state_t* pargp;
|
||||
mlr_dsl_ast_node_t* past;
|
||||
lrec_evaluator_t* pevaluator;
|
||||
rval_evaluator_t* pevaluator;
|
||||
int do_exclude;
|
||||
} mapper_filter_state_t;
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ static mapper_t* mapper_filter_alloc(ap_state_t* pargp, mlr_dsl_ast_node_t* past
|
|||
|
||||
pstate->pargp = pargp;
|
||||
pstate->past = past;
|
||||
pstate->pevaluator = lrec_evaluator_alloc_from_ast(past, type_inferencing);
|
||||
pstate->pevaluator = rval_evaluator_alloc_from_ast(past, type_inferencing);
|
||||
pstate->do_exclude = do_exclude;
|
||||
|
||||
mapper_t* pmapper = mlr_malloc_or_die(sizeof(mapper_t));
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include "containers/lhmsv.h"
|
||||
#include "containers/mlhmmv.h"
|
||||
#include "mapping/mappers.h"
|
||||
#include "mapping/lrec_evaluators.h"
|
||||
#include "mapping/rval_evaluators.h"
|
||||
#include "dsls/mlr_dsl_wrapper.h"
|
||||
#include "mlr_dsl_cst.h"
|
||||
|
||||
|
|
@ -280,14 +280,14 @@ static void evaluate_statements(
|
|||
if (node_type == MD_AST_NODE_TYPE_SREC_ASSIGNMENT) {
|
||||
mlr_dsl_cst_statement_item_t* pitem = pstatement->pitems->phead->pvvalue;
|
||||
char* output_field_name = pitem->output_field_name;
|
||||
lrec_evaluator_t* prhs_evaluator = pitem->prhs_evaluator;
|
||||
rval_evaluator_t* prhs_evaluator = pitem->prhs_evaluator;
|
||||
|
||||
mv_t val = prhs_evaluator->pprocess_func(pinrec, ptyped_overlay, pstate->poosvars,
|
||||
ppregex_captures, pctx, prhs_evaluator->pvstate);
|
||||
mv_t* pval = mlr_malloc_or_die(sizeof(mv_t));
|
||||
*pval = val;
|
||||
|
||||
// The lrec_evaluator reads the overlay in preference to the lrec. E.g. if the input had
|
||||
// The rval_evaluator reads the overlay in preference to the lrec. E.g. if the input had
|
||||
// "x"=>"abc","y"=>"def" but the previous pass through this loop set "y"=>7.4 and "z"=>"ghi" then an
|
||||
// expression right-hand side referring to $y would get the floating-point value 7.4. So we don't need
|
||||
// to do lrec_put here, and moreover should not for two reasons: (1) there is a performance hit of doing
|
||||
|
|
@ -301,14 +301,14 @@ static void evaluate_statements(
|
|||
} else if (node_type == MD_AST_NODE_TYPE_OOSVAR_ASSIGNMENT) {
|
||||
mlr_dsl_cst_statement_item_t* pitem = pstatement->pitems->phead->pvvalue;
|
||||
|
||||
lrec_evaluator_t* prhs_evaluator = pitem->prhs_evaluator;
|
||||
rval_evaluator_t* prhs_evaluator = pitem->prhs_evaluator;
|
||||
mv_t rhs_value = prhs_evaluator->pprocess_func(pinrec, ptyped_overlay,
|
||||
pstate->poosvars, ppregex_captures, pctx, prhs_evaluator->pvstate);
|
||||
|
||||
sllmv_t* pmvkeys = sllmv_alloc();
|
||||
int keys_ok = TRUE;
|
||||
for (sllve_t* pe = pitem->poosvar_lhs_keylist_evaluators->phead; pe != NULL; pe = pe->pnext) {
|
||||
lrec_evaluator_t* pmvkey_evaluator = pe->pvvalue;
|
||||
rval_evaluator_t* pmvkey_evaluator = pe->pvvalue;
|
||||
mv_t mvkey = pmvkey_evaluator->pprocess_func(pinrec, ptyped_overlay,
|
||||
pstate->poosvars, ppregex_captures, pctx, pmvkey_evaluator->pvstate);
|
||||
if (mv_is_null(&mvkey)) {
|
||||
|
|
@ -329,7 +329,7 @@ static void evaluate_statements(
|
|||
for (sllve_t* pf = pstatement->pitems->phead; pf != NULL; pf = pf->pnext) {
|
||||
mlr_dsl_cst_statement_item_t* pitem = pf->pvvalue;
|
||||
char* output_field_name = pitem->output_field_name;
|
||||
lrec_evaluator_t* prhs_evaluator = pitem->prhs_evaluator;
|
||||
rval_evaluator_t* prhs_evaluator = pitem->prhs_evaluator;
|
||||
|
||||
// This is overkill ... the grammar allows only for oosvar names as args to emit. So we could bypass
|
||||
// that and just hashmap-get keyed by output_field_name here.
|
||||
|
|
@ -352,7 +352,7 @@ static void evaluate_statements(
|
|||
|
||||
} else if (node_type == MD_AST_NODE_TYPE_FILTER) {
|
||||
mlr_dsl_cst_statement_item_t* pitem = pstatement->pitems->phead->pvvalue;
|
||||
lrec_evaluator_t* prhs_evaluator = pitem->prhs_evaluator;
|
||||
rval_evaluator_t* prhs_evaluator = pitem->prhs_evaluator;
|
||||
|
||||
mv_t val = prhs_evaluator->pprocess_func(pinrec, ptyped_overlay, pstate->poosvars,
|
||||
ppregex_captures, pctx, prhs_evaluator->pvstate);
|
||||
|
|
@ -366,7 +366,7 @@ static void evaluate_statements(
|
|||
|
||||
} else if (node_type == MD_AST_NODE_TYPE_GATE) {
|
||||
mlr_dsl_cst_statement_item_t* pitem = pstatement->pitems->phead->pvvalue;
|
||||
lrec_evaluator_t* prhs_evaluator = pitem->prhs_evaluator;
|
||||
rval_evaluator_t* prhs_evaluator = pitem->prhs_evaluator;
|
||||
|
||||
mv_t val = prhs_evaluator->pprocess_func(pinrec, ptyped_overlay, pstate->poosvars,
|
||||
ppregex_captures, pctx, prhs_evaluator->pvstate);
|
||||
|
|
@ -382,7 +382,7 @@ static void evaluate_statements(
|
|||
|
||||
} else { // Bare-boolean statement, or error.
|
||||
mlr_dsl_cst_statement_item_t* pitem = pstatement->pitems->phead->pvvalue;
|
||||
lrec_evaluator_t* prhs_evaluator = pitem->prhs_evaluator;
|
||||
rval_evaluator_t* prhs_evaluator = pitem->prhs_evaluator;
|
||||
|
||||
mv_t val = prhs_evaluator->pprocess_func(pinrec, ptyped_overlay, pstate->poosvars,
|
||||
ppregex_captures, pctx, prhs_evaluator->pvstate);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ static mlr_dsl_cst_statement_item_t* mlr_dsl_cst_statement_item_alloc(
|
|||
mlr_dsl_cst_lhs_type_t lhs_type,
|
||||
char* output_field_name,
|
||||
sllv_t* poosvar_lhs_keylist_evaluators,
|
||||
lrec_evaluator_t* prhs_evaluator);
|
||||
rval_evaluator_t* prhs_evaluator);
|
||||
static void cst_statement_item_free(mlr_dsl_cst_statement_item_t* pitem);
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -114,7 +114,7 @@ static mlr_dsl_cst_statement_t* cst_statement_alloc(mlr_dsl_ast_node_t* past, in
|
|||
MLR_DSL_CST_LHS_TYPE_SREC,
|
||||
pleft->text,
|
||||
NULL,
|
||||
lrec_evaluator_alloc_from_ast(pright, type_inferencing)));
|
||||
rval_evaluator_alloc_from_ast(pright, type_inferencing)));
|
||||
|
||||
} else if (past->type == MD_AST_NODE_TYPE_OOSVAR_ASSIGNMENT) {
|
||||
sllv_t* poosvar_lhs_keylist_evaluators = sllv_alloc();
|
||||
|
|
@ -130,7 +130,7 @@ static mlr_dsl_cst_statement_t* cst_statement_alloc(mlr_dsl_ast_node_t* past, in
|
|||
|
||||
if (pleft->type == MD_AST_NODE_TYPE_OOSVAR_NAME) {
|
||||
sllv_append(poosvar_lhs_keylist_evaluators,
|
||||
lrec_evaluator_alloc_from_string(mlr_strdup_or_die(pleft->text)));
|
||||
rval_evaluator_alloc_from_string(mlr_strdup_or_die(pleft->text)));
|
||||
} else {
|
||||
|
||||
mlr_dsl_ast_node_t* pnode = pleft;
|
||||
|
|
@ -157,14 +157,14 @@ static mlr_dsl_cst_statement_t* cst_statement_alloc(mlr_dsl_ast_node_t* past, in
|
|||
if (pnode->type == MD_AST_NODE_TYPE_OOSVAR_LEVEL_KEY) {
|
||||
mlr_dsl_ast_node_t* pkeynode = pnode->pchildren->phead->pnext->pvvalue;
|
||||
sllv_prepend(poosvar_lhs_keylist_evaluators,
|
||||
lrec_evaluator_alloc_from_ast(pkeynode, type_inferencing));
|
||||
rval_evaluator_alloc_from_ast(pkeynode, type_inferencing));
|
||||
} else {
|
||||
// Oosvar expressions are of the form '@name[$index1][@index2+3][4]["five"]. The first one
|
||||
// (name) is special: syntactically, it's outside the brackets, although that issue is for the
|
||||
// parser to handle. Here, it's special since it's always a string, never an expression that
|
||||
// evaluates to string.
|
||||
sllv_prepend(poosvar_lhs_keylist_evaluators,
|
||||
lrec_evaluator_alloc_from_string(mlr_strdup_or_die(pnode->text)));
|
||||
rval_evaluator_alloc_from_string(mlr_strdup_or_die(pnode->text)));
|
||||
}
|
||||
if (pnode->pchildren == NULL)
|
||||
break;
|
||||
|
|
@ -176,7 +176,7 @@ static mlr_dsl_cst_statement_t* cst_statement_alloc(mlr_dsl_ast_node_t* past, in
|
|||
MLR_DSL_CST_LHS_TYPE_OOSVAR,
|
||||
NULL,
|
||||
poosvar_lhs_keylist_evaluators,
|
||||
lrec_evaluator_alloc_from_ast(pright, type_inferencing)));
|
||||
rval_evaluator_alloc_from_ast(pright, type_inferencing)));
|
||||
|
||||
} else if (past->type == MD_AST_NODE_TYPE_FILTER) {
|
||||
mlr_dsl_ast_node_t* pnode = past->pchildren->phead->pvvalue;
|
||||
|
|
@ -184,7 +184,7 @@ static mlr_dsl_cst_statement_t* cst_statement_alloc(mlr_dsl_ast_node_t* past, in
|
|||
MLR_DSL_CST_LHS_TYPE_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
lrec_evaluator_alloc_from_ast(pnode, type_inferencing)));
|
||||
rval_evaluator_alloc_from_ast(pnode, type_inferencing)));
|
||||
|
||||
} else if (past->type == MD_AST_NODE_TYPE_GATE) {
|
||||
mlr_dsl_ast_node_t* pnode = past->pchildren->phead->pvvalue;
|
||||
|
|
@ -192,7 +192,7 @@ static mlr_dsl_cst_statement_t* cst_statement_alloc(mlr_dsl_ast_node_t* past, in
|
|||
MLR_DSL_CST_LHS_TYPE_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
lrec_evaluator_alloc_from_ast(pnode, type_inferencing)));
|
||||
rval_evaluator_alloc_from_ast(pnode, type_inferencing)));
|
||||
|
||||
} else if (past->type == MD_AST_NODE_TYPE_EMIT) {
|
||||
// Loop over oosvar names to emit in e.g. 'emit @a, @b, @c'.
|
||||
|
|
@ -202,7 +202,7 @@ static mlr_dsl_cst_statement_t* cst_statement_alloc(mlr_dsl_ast_node_t* past, in
|
|||
MLR_DSL_CST_LHS_TYPE_OOSVAR,
|
||||
pnode->text,
|
||||
NULL,
|
||||
lrec_evaluator_alloc_from_ast(pnode, type_inferencing)));
|
||||
rval_evaluator_alloc_from_ast(pnode, type_inferencing)));
|
||||
}
|
||||
|
||||
} else if (past->type == MD_AST_NODE_TYPE_DUMP) {
|
||||
|
|
@ -213,7 +213,7 @@ static mlr_dsl_cst_statement_t* cst_statement_alloc(mlr_dsl_ast_node_t* past, in
|
|||
MLR_DSL_CST_LHS_TYPE_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
lrec_evaluator_alloc_from_ast(past, type_inferencing)));
|
||||
rval_evaluator_alloc_from_ast(past, type_inferencing)));
|
||||
}
|
||||
|
||||
return pstatement;
|
||||
|
|
@ -231,7 +231,7 @@ static mlr_dsl_cst_statement_item_t* mlr_dsl_cst_statement_item_alloc(
|
|||
mlr_dsl_cst_lhs_type_t lhs_type,
|
||||
char* output_field_name,
|
||||
sllv_t* poosvar_lhs_keylist_evaluators,
|
||||
lrec_evaluator_t* prhs_evaluator)
|
||||
rval_evaluator_t* prhs_evaluator)
|
||||
{
|
||||
mlr_dsl_cst_statement_item_t* pitem = mlr_malloc_or_die(sizeof(mlr_dsl_cst_statement_item_t));
|
||||
pitem->lhs_type = lhs_type;
|
||||
|
|
@ -248,7 +248,7 @@ static void cst_statement_item_free(mlr_dsl_cst_statement_item_t* pitem) {
|
|||
pitem->prhs_evaluator->pfree_func(pitem->prhs_evaluator);
|
||||
if (pitem->poosvar_lhs_keylist_evaluators != NULL) {
|
||||
for (sllve_t* pe = pitem->poosvar_lhs_keylist_evaluators->phead; pe != NULL; pe = pe->pnext) {
|
||||
lrec_evaluator_t* pevaluator = pe->pvvalue;
|
||||
rval_evaluator_t* pevaluator = pe->pvvalue;
|
||||
pevaluator->pfree_func(pevaluator);
|
||||
}
|
||||
sllv_free(pitem->poosvar_lhs_keylist_evaluators);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define MLR_DSL_CST_H
|
||||
|
||||
#include "containers/mlr_dsl_ast.h"
|
||||
#include "lrec_evaluators.h"
|
||||
#include "rval_evaluators.h"
|
||||
|
||||
// ================================================================
|
||||
// Concrete syntax tree (CST) derived from an abstract syntax tree (AST).
|
||||
|
|
@ -51,7 +51,7 @@ typedef struct _mlr_dsl_cst_statement_item_t {
|
|||
sllv_t* poosvar_lhs_keylist_evaluators;
|
||||
|
||||
// RHS:
|
||||
lrec_evaluator_t* prhs_evaluator;
|
||||
rval_evaluator_t* prhs_evaluator;
|
||||
} mlr_dsl_cst_statement_item_t;
|
||||
|
||||
typedef struct _mlr_dsl_cst_statement_t {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef LREC_EVALUATOR_H
|
||||
#define LREC_EVALUATOR_H
|
||||
#ifndef RVAL_EVALUATOR_H
|
||||
#define RVAL_EVALUATOR_H
|
||||
|
||||
#include "lib/context.h"
|
||||
#include "containers/lrec.h"
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
#include "containers/mlrval.h"
|
||||
#include "lib/string_array.h"
|
||||
|
||||
struct _lrec_evaluator_t; // forward reference for method declarations
|
||||
struct _rval_evaluator_t; // forward reference for method declarations
|
||||
|
||||
// Record state is in three parts here:
|
||||
//
|
||||
|
|
@ -33,16 +33,16 @@ struct _lrec_evaluator_t; // forward reference for method declarations
|
|||
//
|
||||
// See also the comments above mapper_put.c for more information.
|
||||
|
||||
typedef mv_t lrec_evaluator_process_func_t(
|
||||
typedef mv_t rval_evaluator_process_func_t(
|
||||
lrec_t* prec, lhmsv_t* ptyped_overlay, mlhmmv_t* poosvars,
|
||||
string_array_t** ppregex_captures, context_t* pctx, void* pvstate);
|
||||
|
||||
typedef void lrec_evaluator_free_func_t(struct _lrec_evaluator_t*);
|
||||
typedef void rval_evaluator_free_func_t(struct _rval_evaluator_t*);
|
||||
|
||||
typedef struct _lrec_evaluator_t {
|
||||
typedef struct _rval_evaluator_t {
|
||||
void* pvstate;
|
||||
lrec_evaluator_process_func_t* pprocess_func;
|
||||
lrec_evaluator_free_func_t* pfree_func;
|
||||
} lrec_evaluator_t;
|
||||
rval_evaluator_process_func_t* pprocess_func;
|
||||
rval_evaluator_free_func_t* pfree_func;
|
||||
} rval_evaluator_t;
|
||||
|
||||
#endif // LREC_EVALUATOR_H
|
||||
#endif // RVAL_EVALUATOR_H
|
||||
File diff suppressed because it is too large
Load diff
21
c/mapping/rval_evaluators.h
Normal file
21
c/mapping/rval_evaluators.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef RVAL_EVALUATORS_H
|
||||
#define RVAL_EVALUATORS_H
|
||||
#include <stdio.h>
|
||||
#include "containers/mlr_dsl_ast.h"
|
||||
#include "mapping/rval_evaluator.h"
|
||||
|
||||
#define TYPE_INFER_STRING_FLOAT_INT 0xce08
|
||||
#define TYPE_INFER_STRING_FLOAT 0xce09
|
||||
#define TYPE_INFER_STRING_ONLY 0xce0a
|
||||
|
||||
rval_evaluator_t* rval_evaluator_alloc_from_ast(mlr_dsl_ast_node_t* past, int type_inferencing);
|
||||
rval_evaluator_t* rval_evaluator_alloc_from_string(char* string);
|
||||
|
||||
void rval_evaluator_list_functions(FILE* output_stream, char* leader);
|
||||
// Pass function_name == NULL to get usage for all functions:
|
||||
void rval_evaluator_function_usage(FILE* output_stream, char* function_name);
|
||||
void rval_evaluator_list_all_functions_raw(FILE* output_stream);
|
||||
|
||||
int test_rval_evaluators_main(int argc, char **argv);
|
||||
|
||||
#endif // LREC_FEVALUATORS_H
|
||||
|
|
@ -10,7 +10,7 @@ check_PROGRAMS = test_mlrutil \
|
|||
test_mlhmmv \
|
||||
test_multiple_containers \
|
||||
test_string_builder \
|
||||
test_lrec_evaluators \
|
||||
test_rval_evaluators \
|
||||
test_join_bucket_keeper
|
||||
|
||||
AM_CPPFLAGS= -I${srcdir}/..
|
||||
|
|
@ -58,8 +58,8 @@ test_multiple_containers_LDADD= ${all_ldadd}
|
|||
test_string_builder_CFLAGS= -std=gnu99 -g ${AM_CFLAGS}
|
||||
test_string_builder_LDADD= ${all_ldadd}
|
||||
|
||||
test_lrec_evaluators_CFLAGS= -std=gnu99 -g ${AM_CFLAGS}
|
||||
test_lrec_evaluators_LDADD= ${all_ldadd}
|
||||
test_rval_evaluators_CFLAGS= -std=gnu99 -g ${AM_CFLAGS}
|
||||
test_rval_evaluators_LDADD= ${all_ldadd}
|
||||
|
||||
test_join_bucket_keeper_CFLAGS= -std=gnu99 -g ${AM_CFLAGS}
|
||||
test_join_bucket_keeper_LDADD= ${all_ldadd}
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
#include "mapping/lrec_evaluators.h"
|
||||
|
||||
// test_lrec_evaluators has the MinUnit inside lrec_evaluators, as it tests
|
||||
// many private methods. (The other option is to make them all public.)
|
||||
int main(int argc, char **argv) {
|
||||
return test_lrec_evaluators_main(argc, argv);
|
||||
}
|
||||
7
c/unit_test/test_rval_evaluators.c
Normal file
7
c/unit_test/test_rval_evaluators.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include "mapping/rval_evaluators.h"
|
||||
|
||||
// test_rval_evaluators has the MinUnit inside rval_evaluators, as it tests
|
||||
// many private methods. (The other option is to make them all public.)
|
||||
int main(int argc, char **argv) {
|
||||
return test_rval_evaluators_main(argc, argv);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue