From 23e7badcb5fa09c52f595642b370419171f293bc Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sun, 28 Feb 2016 08:29:30 -0500 Subject: [PATCH] unset iterate --- c/mapping/mlr_dsl_cst.c | 28 +++++++++++++++++++++++----- c/todo.txt | 4 ++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/c/mapping/mlr_dsl_cst.c b/c/mapping/mlr_dsl_cst.c index 3077c717c..ee058141c 100644 --- a/c/mapping/mlr_dsl_cst.c +++ b/c/mapping/mlr_dsl_cst.c @@ -221,7 +221,7 @@ static mlr_dsl_cst_statement_t* cst_statement_alloc(mlr_dsl_ast_node_t* past, in // // Here past is the =; pright is the 5; pleft is the string of bracket references // ending at the oosvar name. - + // // Bracket operators come in from the right. So the highest AST node is the rightmost map, and the // lowest is the oosvar name. Hence sllv_prepend rather than sllv_append. if (pnode->type == MD_AST_NODE_TYPE_OOSVAR_LEVEL_KEY) { @@ -263,17 +263,35 @@ static mlr_dsl_cst_statement_t* cst_statement_alloc(mlr_dsl_ast_node_t* past, in } else if (pnode->type == MD_AST_NODE_TYPE_OOSVAR_NAME) { sllv_append(pstatement->pitems, mlr_dsl_cst_statement_item_alloc( pnode->text, - NULL, // xxx needs to be poosvar_lhs_keylist_evaluators if keyed + sllv_alloc(), NULL, NULL)); } else if (pnode->type == MD_AST_NODE_TYPE_OOSVAR_LEVEL_KEY) { + sllv_t* poosvar_lhs_keylist_evaluators = sllv_alloc(); + mlr_dsl_ast_node_t* pwalker = pnode; + while (TRUE) { + if (pwalker->type == MD_AST_NODE_TYPE_OOSVAR_LEVEL_KEY) { + mlr_dsl_ast_node_t* pkeynode = pwalker->pchildren->phead->pnext->pvvalue; + sllv_prepend(poosvar_lhs_keylist_evaluators, + rval_evaluator_alloc_from_ast(pkeynode, type_inferencing)); + } else { + sllv_prepend(poosvar_lhs_keylist_evaluators, + rval_evaluator_alloc_from_string(mlr_strdup_or_die(pwalker->text))); + } + if (pwalker->pchildren == NULL) + break; + pwalker = pwalker->pchildren->phead->pvvalue; + } + sllv_append(pstatement->pitems, mlr_dsl_cst_statement_item_alloc( - pnode->text, - NULL, // xxx needs to be poosvar_lhs_keylist_evaluators if keyed + pwalker->text, + poosvar_lhs_keylist_evaluators, NULL, NULL)); } else { - // xxx abend + fprintf(stderr, "%s: internal coding error detected in file %s at line %d.\n", + MLR_GLOBALS.argv0, __FILE__, __LINE__); + exit(1); } } diff --git a/c/todo.txt b/c/todo.txt index d75a7275a..de443c874 100644 --- a/c/todo.txt +++ b/c/todo.txt @@ -16,6 +16,7 @@ TOP-OF-LIST SUMMARY * allow begin/end srec assignments in the grammar, to allow better error messages than 'syntax error' in the caller ! valgrinds ! xxxes +* ack hash algo * double-check oosvar+emit+tri-split-null by re-implementing as many mappers as possible using ossvars + emit ? @x = $0 ? $0 = @x ? @@ -53,6 +54,9 @@ UNSET ================================================================ PARAMETERIZED EMIT +!! need submaps: + mlr put -v 'emit @a["sums"]' + * evolve & extend the UTs * handle too-short, too-long, just-right cases * rename functions