From 6a35e1bec44ab305b44dfdda5d10a3440b8a9d34 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Mon, 23 May 2016 09:16:46 -0400 Subject: [PATCH] semicolon iterate --- c/dsls/mlr_dsl_parse.y | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/c/dsls/mlr_dsl_parse.y b/c/dsls/mlr_dsl_parse.y index 1d87416f7..a9f85b161 100644 --- a/c/dsls/mlr_dsl_parse.y +++ b/c/dsls/mlr_dsl_parse.y @@ -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);