mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-25 08:53:55 +00:00
semicolon iterate
This commit is contained in:
parent
12cab51b4a
commit
6a35e1bec4
1 changed files with 15 additions and 5 deletions
|
|
@ -68,15 +68,25 @@ md_statement_list(A) ::= md_statement(B). {
|
|||
A = mlr_dsl_ast_node_alloc_unary("list", MD_AST_NODE_TYPE_STATEMENT_LIST, B);
|
||||
}
|
||||
}
|
||||
md_statement_list(A) ::= md_statement_list(B) MD_TOKEN_SEMICOLON md_statement(C). {
|
||||
if (C->type == MD_AST_NODE_TYPE_NOP) {
|
||||
A = B;
|
||||
|
||||
//md_statement_list(A) ::= md_statement_list(B) MD_TOKEN_SEMICOLON md_statement(C). {
|
||||
// if (C->type == MD_AST_NODE_TYPE_NOP) {
|
||||
// A = B;
|
||||
// } else {
|
||||
// A = mlr_dsl_ast_node_append_arg(B, C);
|
||||
// }
|
||||
//}
|
||||
|
||||
// xxx cmt why prepend not postpend
|
||||
md_statement_list(A) ::= md_statement(B) MD_TOKEN_SEMICOLON md_statement_list(C). {
|
||||
if (B->type == MD_AST_NODE_TYPE_NOP) {
|
||||
A = C;
|
||||
} else {
|
||||
A = mlr_dsl_ast_node_append_arg(B, C);
|
||||
A = mlr_dsl_ast_node_prepend_arg(C, B);
|
||||
}
|
||||
//mlr_dsl_ast_node_print(C);
|
||||
}
|
||||
|
||||
|
||||
// This allows for trailing semicolon, as well as empty string (or whitespace) between semicolons:
|
||||
md_statement(A) ::= . {
|
||||
A = mlr_dsl_ast_node_alloc_zary("nop", MD_AST_NODE_TYPE_NOP);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue