mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-23 16:08:43 +00:00
put/filter merge iterate
This commit is contained in:
parent
848110befe
commit
ba62d7aa45
3 changed files with 23 additions and 15 deletions
|
|
@ -33,7 +33,7 @@ typedef struct _mapper_put_state_t {
|
|||
int outer_filter;
|
||||
|
||||
int do_filter; // xxx temp merge
|
||||
int do_exclude; // xxx temp merge
|
||||
int negate_filter; // xxx temp merge
|
||||
} mapper_put_state_t;
|
||||
|
||||
static void mapper_put_usage(FILE* o, char* argv0, char* verb);
|
||||
|
|
@ -42,7 +42,7 @@ static mapper_t* mapper_put_parse_cli(int* pargi, int argc, char** argv,
|
|||
static mapper_t* mapper_put_alloc(char* mlr_dsl_expression, char* comment_stripped_mlr_dsl_expression,
|
||||
mlr_dsl_ast_t* past, int outer_filter,
|
||||
int do_filter, // xxx temp
|
||||
int do_exclude, // xxx temp
|
||||
int negate_filter, // xxx temp
|
||||
int type_inferencing, char* oosvar_flatten_separator,
|
||||
int flush_every_record, cli_writer_opts_t* pwriter_opts, cli_writer_opts_t* pmain_writer_opts);
|
||||
static void mapper_put_free(mapper_t* pmapper);
|
||||
|
|
@ -145,7 +145,7 @@ static mapper_t* mapper_put_parse_cli(int* pargi, int argc, char** argv,
|
|||
char* comment_stripped_mlr_dsl_expression = NULL;
|
||||
int outer_filter = TRUE;
|
||||
int do_filter = FALSE; // xxx temp
|
||||
int do_exclude = FALSE; // xxx temp
|
||||
int negate_filter = FALSE; // xxx temp
|
||||
int type_inferencing = TYPE_INFER_STRING_FLOAT_INT;
|
||||
int print_ast = FALSE;
|
||||
int trace_parse = FALSE;
|
||||
|
|
@ -201,7 +201,7 @@ static mapper_t* mapper_put_parse_cli(int* pargi, int argc, char** argv,
|
|||
argi += 1;
|
||||
} else if (streq(argv[argi], "-x")) {
|
||||
do_filter = TRUE;
|
||||
do_exclude = TRUE;
|
||||
negate_filter = TRUE;
|
||||
argi += 1;
|
||||
} else if (streq(argv[argi], "-S")) {
|
||||
type_inferencing = TYPE_INFER_STRING_ONLY;
|
||||
|
|
@ -270,7 +270,7 @@ static mapper_t* mapper_put_parse_cli(int* pargi, int argc, char** argv,
|
|||
|
||||
*pargi = argi;
|
||||
return mapper_put_alloc(mlr_dsl_expression, comment_stripped_mlr_dsl_expression,
|
||||
past, outer_filter, do_filter, do_exclude, type_inferencing, oosvar_flatten_separator, flush_every_record,
|
||||
past, outer_filter, do_filter, negate_filter, type_inferencing, oosvar_flatten_separator, flush_every_record,
|
||||
pwriter_opts, pmain_writer_opts);
|
||||
}
|
||||
|
||||
|
|
@ -278,7 +278,7 @@ static mapper_t* mapper_put_parse_cli(int* pargi, int argc, char** argv,
|
|||
static mapper_t* mapper_put_alloc(char* mlr_dsl_expression, char* comment_stripped_mlr_dsl_expression,
|
||||
mlr_dsl_ast_t* past, int outer_filter,
|
||||
int do_filter, // xxx temp
|
||||
int do_exclude, // xxx temp
|
||||
int negate_filter, // xxx temp
|
||||
int type_inferencing, char* oosvar_flatten_separator,
|
||||
int flush_every_record, cli_writer_opts_t* pwriter_opts, cli_writer_opts_t* pmain_writer_opts)
|
||||
{
|
||||
|
|
@ -287,7 +287,7 @@ static mapper_t* mapper_put_alloc(char* mlr_dsl_expression, char* comment_stripp
|
|||
pstate->mlr_dsl_expression = mlr_dsl_expression;
|
||||
pstate->comment_stripped_mlr_dsl_expression = comment_stripped_mlr_dsl_expression;
|
||||
pstate->past = past;
|
||||
pstate->pcst = mlr_dsl_cst_alloc(past, type_inferencing, do_filter);
|
||||
pstate->pcst = mlr_dsl_cst_alloc(past, type_inferencing, do_filter, negate_filter);
|
||||
pstate->at_begin = TRUE;
|
||||
pstate->outer_filter = outer_filter;
|
||||
pstate->poosvars = mlhmmv_alloc();
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ typedef void cst_statement_handler_t(
|
|||
// ----------------------------------------------------------------
|
||||
static mlr_dsl_ast_node_t* get_list_for_block(mlr_dsl_ast_node_t* pnode);
|
||||
static mlr_dsl_cst_statement_t* alloc_final_filter_statement(mlr_dsl_cst_t* pcst, mlr_dsl_ast_node_t* pnode,
|
||||
int type_inferencing, int context_flags);
|
||||
int negate_filter, int type_inferencing, int context_flags);
|
||||
|
||||
static mlr_dsl_cst_statement_t* alloc_blank();
|
||||
void mlr_dsl_cst_statement_free(mlr_dsl_cst_statement_t* pstatement);
|
||||
|
|
@ -64,7 +64,12 @@ static cst_statement_allocator_t alloc_continue;
|
|||
static cst_statement_allocator_t alloc_filter;
|
||||
|
||||
static cst_statement_allocator_t alloc_bare_boolean;
|
||||
static cst_statement_allocator_t alloc_final_filter;
|
||||
static mlr_dsl_cst_statement_t* alloc_final_filter(
|
||||
mlr_dsl_cst_t* pcst,
|
||||
mlr_dsl_ast_node_t* pnode,
|
||||
int negate_filter,
|
||||
int type_inferencing,
|
||||
int context_flags);
|
||||
|
||||
static cst_statement_allocator_t alloc_tee;
|
||||
static cst_statement_allocator_t alloc_emitf;
|
||||
|
|
@ -343,7 +348,9 @@ mlr_dsl_cst_t* mlr_dsl_cst_alloc_filterable(mlr_dsl_ast_t* ptop, int type_infere
|
|||
// text="z", type=string_literal.
|
||||
// text="6", type=strnum_literal.
|
||||
|
||||
mlr_dsl_cst_t* mlr_dsl_cst_alloc(mlr_dsl_ast_t* ptop, int type_inferencing, int do_filter/*xxx temp*/) {
|
||||
mlr_dsl_cst_t* mlr_dsl_cst_alloc(mlr_dsl_ast_t* ptop, int type_inferencing,
|
||||
int do_filter, int negate_filter/*xxx temp*/)
|
||||
{
|
||||
int context_flags = 0;
|
||||
// The root node is not populated on empty-string input to the parser.
|
||||
if (ptop->proot == NULL) {
|
||||
|
|
@ -416,7 +423,7 @@ mlr_dsl_cst_t* mlr_dsl_cst_alloc(mlr_dsl_ast_t* ptop, int type_inferencing, int
|
|||
// xxx do_exclude
|
||||
if (do_filter && pe->pnext == NULL) {
|
||||
sllv_append(pcst->pmain_statements, alloc_final_filter_statement(
|
||||
pcst, pnode, type_inferencing, context_flags));
|
||||
pcst, pnode, negate_filter, type_inferencing, context_flags));
|
||||
} else {
|
||||
sllv_append(pcst->pmain_statements, mlr_dsl_cst_alloc_statement(pcst, pnode,
|
||||
type_inferencing, context_flags));
|
||||
|
|
@ -523,7 +530,7 @@ void mlr_dsl_cst_free(mlr_dsl_cst_t* pcst) {
|
|||
// ----------------------------------------------------------------
|
||||
// xxx comment
|
||||
static mlr_dsl_cst_statement_t* alloc_final_filter_statement(mlr_dsl_cst_t* pcst, mlr_dsl_ast_node_t* pnode,
|
||||
int type_inferencing, int context_flags)
|
||||
int negate_filter, int type_inferencing, int context_flags)
|
||||
{
|
||||
switch(pnode->type) {
|
||||
|
||||
|
|
@ -567,7 +574,7 @@ static mlr_dsl_cst_statement_t* alloc_final_filter_statement(mlr_dsl_cst_t* pcst
|
|||
|
||||
default:
|
||||
// xxx comment
|
||||
return alloc_final_filter(pcst, pnode, type_inferencing, context_flags);
|
||||
return alloc_final_filter(pcst, pnode, negate_filter, type_inferencing, context_flags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1622,10 +1629,11 @@ static mlr_dsl_cst_statement_t* alloc_bare_boolean(mlr_dsl_cst_t* pcst, mlr_dsl_
|
|||
|
||||
// ----------------------------------------------------------------
|
||||
static mlr_dsl_cst_statement_t* alloc_final_filter(mlr_dsl_cst_t* pcst, mlr_dsl_ast_node_t* pnode,
|
||||
int type_inferencing, int context_flags)
|
||||
int negate_filter, int type_inferencing, int context_flags)
|
||||
{
|
||||
mlr_dsl_cst_statement_t* pstatement = alloc_blank();
|
||||
|
||||
// xxx negate
|
||||
pstatement->pnode_handler = handle_filter;
|
||||
pstatement->prhs_evaluator = rval_evaluator_alloc_from_ast(pnode, pcst->pfmgr, type_inferencing, context_flags);
|
||||
return pstatement;
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ typedef struct _mlr_dsl_cst_t {
|
|||
mlr_dsl_cst_t* mlr_dsl_cst_alloc_filterable(mlr_dsl_ast_t* ptop, int type_inferencing);
|
||||
|
||||
mlr_dsl_cst_t* mlr_dsl_cst_alloc(mlr_dsl_ast_t* past, int type_inferencing,
|
||||
int do_filter); // xxx temp
|
||||
int do_filter, int negate_filter); // xxx temp
|
||||
|
||||
mlr_dsl_cst_statement_t* mlr_dsl_cst_alloc_statement(mlr_dsl_cst_t* pcst, mlr_dsl_ast_node_t* pnode,
|
||||
int type_inferencing, int context_flags);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue