From df08508ca534b2ae772d387c189e7422d85581c2 Mon Sep 17 00:00:00 2001 From: theo <2022xmm3@kuas.ac.jp> Date: Sun, 23 Oct 2022 00:56:58 +0900 Subject: [PATCH] variable "lang" removed from file and comments updated to avoid conflicts --- ccmeta.leg | 29 ++++++++++++----------------- tests-parsimony/002.c | 8 ++++---- tests-parsimony/004.c | 6 +++--- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/ccmeta.leg b/ccmeta.leg index 0ba28f9..0d85bf1 100644 --- a/ccmeta.leg +++ b/ccmeta.leg @@ -1293,7 +1293,7 @@ typedef enum { C = 1, } language; -language lang = C, printLang = C; +language printLang = C; int getProtoNumber(oop obj) { return get(map_get(map_get(obj, __proto___symbol), __name___symbol), Symbol, prototype); @@ -1445,9 +1445,8 @@ sCharSequence = ( escapeSequence | !EOL [^\"\\] )* #" primaryExpression = stringLiteral | constant | id | META_AT ( META_LCB x:mstmts { $$ = eval(globals, x) } - | META_OPERATORS META_LPAREN x:mexp { $$ = eval(globals, x) } - | META_LPAREN x:mexp { $$ = eval(globals, x) } - | META_COMMA x:mcomma { $$ = eval(globals, x) } + | META_OPERATORS META_LPAREN x:mvalue { $$ = eval(globals, x) } + | x:mvalue { $$ = eval(globals, x) } ) | l:LPAREN x:expression r:RPAREN { $$= new_C_subexpr(l, x, r) } | l:LPAREN x:compoundStatement r:RPAREN &{gnu} { $$= new_C_subexpr(l, x, r) } @@ -2158,22 +2157,18 @@ _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 @{ lang= META } ( META_OPERATORS META_LPAREN m:mexp { eval(globals, m) } - | META_LPAREN m:mexp { eval(globals, m) } - | META_LCB m:mstmts - | META_IMPORT s:META_STRING ";" { inputStackPush(get(s, String, value)) } - ) - - +metaCatch = META_AT ( META_OPERATORS META_LPAREN m:mvalue { eval(globals, m) } + | META_LPAREN m:mvalue { eval(globals, m) } + | META_LCB m:mstmts + | META_IMPORT s:META_STRING ";" { inputStackPush(get(s, String, value)) } + ) -mexp = @{ lang = META } s:meta_exp META_RPAREN @{ lang = C } { $$= s } - | @{ lang = C } &{ 0 } -mcomma = @{ lang = META } s:meta_exp @{ lang = C } { $$= s } - | @{ lang = C } &{ 0 } +mvalue = i:META_IDENT { $$ = newGetVariable(i) } + | META_LPAREN ( i:meta_block | i:meta_exp ) META_RPAREN { $$ = i } -mstmts = @{ lang = META } -- ( s:meta_stmt { eval(globals, s) })* META_RCB { lang = C } - | @{ lang = C } &{ 0 } +mstmts = ( s:meta_stmt { eval(globals, s) })* META_RCB + | &{ 0 } meta_stmt = s:meta_block { $$ = s } | META_SEMICOLON { $$ = null } diff --git a/tests-parsimony/002.c b/tests-parsimony/002.c index 87ef222..eee98a9 100644 --- a/tests-parsimony/002.c +++ b/tests-parsimony/002.c @@ -4,11 +4,11 @@ two = `integer 2; } -@(a = `constant 10) +@{a = `constant 10;} char t = @(`constant 't'); -int i = @(cons); +int i = @cons; int q = @(`constant 10); int k = @(`initializer (1,2,"stringy thingy",21<<1)); -int i = @(saved); -int w = @(a); +int i = @saved; +int w = @a; diff --git a/tests-parsimony/004.c b/tests-parsimony/004.c index 3a56528..ec291b3 100644 --- a/tests-parsimony/004.c +++ b/tests-parsimony/004.c @@ -6,11 +6,11 @@ } -int x = @{`initializer 2 * @,num;}; +int x = @{`initializer 2 * @(num);}; int main() { - int i = @(`initializer 2 * @,num); - int y = @,test; + int i = @(`initializer 2 * @num); + int y = @test; int a = @{ num = `integer 21;