From 99ed98b99ac2160e7d8fc52bd9650b34a983d205 Mon Sep 17 00:00:00 2001 From: theo <2022xmm3@kuas.ac.jp> Date: Thu, 27 Oct 2022 13:50:43 +0900 Subject: [PATCH] Fix the meta_block error --- ccmeta.leg | 10 +++++----- tests-parsimony/006.c | 28 ++++++++++++++++++++++++++++ tests-parsimony/tmp.c | 24 +++++++----------------- 3 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 tests-parsimony/006.c diff --git a/ccmeta.leg b/ccmeta.leg index bf38cad..946673b 100644 --- a/ccmeta.leg +++ b/ccmeta.leg @@ -2172,7 +2172,7 @@ _FLOAT128 = '_Float128' !IDREST &{gnu} { $$= newToken("_Float1 # input buffer from moving past it before redirecting input from the imported file metaCatch = META_AT ( m:mvalue { map_append(outputProgram, eval(globals, m)); } - | m:mexp { eval(globals, m) } + | m:mexp { map_append(outputProgram, m) } | META_LCB m:mstmts { map_append(outputProgram, m) } | META_IMPORT s:META_STRING ";" { inputStackPush(get(s, String, value)) } ) @@ -2181,9 +2181,9 @@ metaCatch = META_AT ( m:mvalue { map_ mvalue = i:META_IDENT { $$ = newGetVariable(i) } | META_LPAREN i:MO_OPERATION META_RPAREN { $$ = i } -mexp = META_LPAREN ( i:meta_block | i:meta_exp ) META_RPAREN { $$ = i } +mexp = { listBegin() } META_LPAREN ( i:meta_block | i:meta_exp ) META_RPAREN { $$ = eval(globals, listEnd()) } -mstmts = { listBegin() } ( s:meta_stmt { eval(globals, s) } )* META_RCB { $$ = listEnd() } +mstmts = { listBegin() } ( s:meta_stmt { eval(globals, s) } )* META_RCB { $$ = listEnd() } # oop ret = eval(globals, s); if (isReturnable(s, ret)) listAppend(ret) @@ -2207,9 +2207,9 @@ meta_stmt = s:meta_block | e:meta_exp META_SEMICOLON { $$ = e } meta_block = META_LCB m:meta_makeMap - ( s:meta_stmt { map_append(m, s) } + ( s:meta_stmt { eval(globals, s); map_append(m, s) } ) * - ( s:meta_exp { map_append(m, s) } + ( s:meta_exp { eval(globals, s); map_append(m, s) } ) ? META_RCB { $$ = newBlock(m) } diff --git a/tests-parsimony/006.c b/tests-parsimony/006.c new file mode 100644 index 0000000..3139032 --- /dev/null +++ b/tests-parsimony/006.c @@ -0,0 +1,28 @@ +@{ + (`declaration int a = 5;); + a = (`declaration int a = 5;); + @(`declaration int a = 5;); +}; + +@a; +@(t = `integer 2) +@(`declaration int abc = @t;); + +int main() { + @a; + int b = 0; + @{ + @(`declaration int c = 0;); + x = (`declaration int d = 5;); + @x; + if (1) { + if (1) { + x = (`declaration int d = 5;); + @x; + } + } + + }; + int e = 0; + return 0; +} \ No newline at end of file diff --git a/tests-parsimony/tmp.c b/tests-parsimony/tmp.c index 3139032..791070d 100644 --- a/tests-parsimony/tmp.c +++ b/tests-parsimony/tmp.c @@ -1,28 +1,18 @@ -@{ - (`declaration int a = 5;); - a = (`declaration int a = 5;); - @(`declaration int a = 5;); -}; -@a; -@(t = `integer 2) -@(`declaration int abc = @t;); int main() { - @a; - int b = 0; - @{ - @(`declaration int c = 0;); + @({ + @(`declaration int a = 5;); + t = 2; + print(t); + @(`declaration int a = 5;); x = (`declaration int d = 5;); - @x; + @x; if (1) { if (1) { x = (`declaration int d = 5;); @x; } } - - }; - int e = 0; - return 0; + }); } \ No newline at end of file