From 98e97dfc4e6981fb2cf0f8b729bad6849e009d03 Mon Sep 17 00:00:00 2001 From: Sebeck10 Date: Wed, 2 Nov 2022 11:07:44 +0900 Subject: [PATCH] simplification of the language --- ccmeta.leg | 20 ++++++++++++-------- tests-parsimony/001.c | 2 -- tests-parsimony/002.c | 3 +-- tests-parsimony/003.c | 1 - 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ccmeta.leg b/ccmeta.leg index 9b994eb..fd85f7d 100644 --- a/ccmeta.leg +++ b/ccmeta.leg @@ -2170,26 +2170,28 @@ _FLOAT128 = '_Float128' !IDREST &{gnu} { $$= newToken("_Float1 # the semicolon has to be explicit with no space eaten afterwards to prevent the # input buffer from moving past it before redirecting input from the imported file -metaCatch = META_AT ( m:mvalue { map_append(outputProgram, m) } - | META_LCB m:mstmts { map_append(outputProgram, m) } - | META_IMPORT s:META_STRING ";" { inputStackPush(get(s, String, value)) } +metaCatch = META_AT ( m:mvalue { map_append(outputProgram, m) } + | META_LCB m:mstmts { map_append(outputProgram, m) } + | META_IMPORT s:META_STRING ";" { inputStackPush(get(s, String, value)) } ) -mvalue = { listBegin() } ( i:META_IDENT { listAppend(eval(globals, newGetVariable(i))) } +mvalue = { listBegin() } ( i:META_IDENT { listAppend(eval(globals, newGetVariable(i))) } | META_LPAREN ( i:MO_OPERATION | i:meta_block | i:meta_exp - ) META_RPAREN { listAppend(eval(globals, i)) } - ) { $$ = listEnd() } + ) META_RPAREN { listAppend(eval(globals, i)) } + ) { $$ = listEnd() } -mstmts = { listBegin() } ( s:meta_stmt { eval(globals, s) } )* +mstmts = { listBegin() } ( s:meta_stmt { eval(globals, s) } + | a:meta_append { eval(globals, a) } + )* ( (META_NIL META_SEMICOLON )? META_RCB { listEnd(); $$ = null } | META_DAT META_SEMICOLON META_RCB { $$ = listEnd() } ) + meta_stmt = s:meta_block { $$ = s } - | META_DAT META_DOT META_APPEND META_LPAREN s:meta_exp META_RPAREN META_SEMICOLON { $$ = newUnary(Append_proto, s) } | META_SEMICOLON { $$ = null } | l:META_IDENT p:meta_paramList e:meta_block { $$ = newFunc(l, p, e, null) } | META_IF META_LPAREN c:meta_exp META_RPAREN t:meta_stmt META_ELSE f:meta_stmt { $$ = newIf(c, t, f ) } @@ -2207,6 +2209,8 @@ meta_stmt = s:meta_block | t:meta_try { $$ = t } | e:meta_exp META_SEMICOLON { $$ = e } +meta_append = META_DAT META_DOT META_APPEND META_LPAREN s:meta_exp META_RPAREN META_SEMICOLON { $$ = newUnary(Append_proto, s) } + meta_block = META_LCB m:meta_makeMap ( s:meta_stmt { map_append(m, s) } ) * diff --git a/tests-parsimony/001.c b/tests-parsimony/001.c index 09373be..a5c125c 100644 --- a/tests-parsimony/001.c +++ b/tests-parsimony/001.c @@ -10,8 +10,6 @@ nil; } -@(`declaration int a = 0;); - enum foo { FOO, BAR, BAZ }; char *x[] = @(newCinitializer([newCstring("X"), comma, newCstring("Y")])); int i = @(newCint("42")); diff --git a/tests-parsimony/002.c b/tests-parsimony/002.c index cbb212c..c0b7fef 100644 --- a/tests-parsimony/002.c +++ b/tests-parsimony/002.c @@ -2,9 +2,8 @@ saved = `initializer (1,2,"string",21<<1); cons = `constant 2; two = `integer 2; - @@.append(`declaration char *test = "foo";); - @@; } + @{print("6 outputs : \n");} @{a = `constant 10;} char t = @(`constant '@a'); diff --git a/tests-parsimony/003.c b/tests-parsimony/003.c index cf1b674..391d120 100644 --- a/tests-parsimony/003.c +++ b/tests-parsimony/003.c @@ -3,7 +3,6 @@ forLoop = (`statement for (int i = 0; i < 10; ++i) printf("%d\n", i);); whileLoop = `statement while (i < 10) { printf("%d\n", i); ++il; }; useForLoop = 1; - x = null; } int main()