From 828912aa81ad96f8fb11fb13bd9bebd3786f6efc Mon Sep 17 00:00:00 2001 From: Nathan R Date: Mon, 23 Aug 2021 11:52:26 +0200 Subject: [PATCH] last day modifications, more incoming --- ccmeta.leg | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ccmeta.leg b/ccmeta.leg index 05c5641..cf32309 100644 --- a/ccmeta.leg +++ b/ccmeta.leg @@ -1264,11 +1264,15 @@ language lang = C, printLang = C; # yylval == null => "pseudo" op, e.g., change language -- ignored by REPL # yylval == 0 => end of input file while in META mode only -start = META_AT META_LPAREN s:meta_exp META_RPAREN { yylval= s } - | META_AT META_LCB { yylval= null; lang= META } - | &{ lang == META } - s:meta { yylval= s } - | &{ lang == META } - META_RCB { yylval= null; lang= C } - | &{ lang == C } s:externalDeclaration { yylval= s } +start = m:mexp { yylval= m } + | META_AT META_LCB { yylval= null; lang= META } + | &{ lang == META } - s:meta { yylval= s } + | &{ lang == META } - META_RCB { yylval= null; lang= C } + | &{ lang == C } s:externalDeclaration { yylval= s } + +mexp = META_AT META_LPAREN ( @{ lang = META } s:meta_exp META_RPAREN @{ lang = C } { $$= s } + | @{ lang = C } &{ 0 } + ) error = EOL* < (!EOL .)* EOL* (!EOL .)* > &{ error(yytext), 1 } @@ -1401,6 +1405,7 @@ sCharSequence = ( escapeSequence | !EOL [^\"\\] )* # 6.5.1 primaryExpression = stringLiteral | constant | id + | x:mexp { $$ = 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) } @@ -1866,12 +1871,12 @@ jumpStatement = g:GOTO i:id t:SEMI { $$= new_C_goto(g, newNullObject(), i ## translationUnit = externalDeclaration+ -externalDeclaration = { yylval = newComment(yytext); } +externalDeclaration = { $$ = newComment(yytext); } | ( SEMI &{gnu} | declaration | functionDefinition | &. &{ errmsg= "declaration expected" } error - ) { yylval= $$; } + ) functionDefinition = @{ C_declarationBegin() } ( s:functionDeclarationSpecifiers | &{gnu} {s=newNullObject()} ) @@ -4519,7 +4524,7 @@ int main(int argc, char **argv) map_set(globals, intern("clone" ), makeFunction(prim_clone, intern("clone" ), null, null, globals, null)); map_set(globals, intern("import" ), makeFunction(prim_import, intern("import" ), null, null, globals, null)); map_set(globals, intern("microseconds"), makeFunction(prim_microseconds, intern("microseconds"), null, null, globals, null)); - map_set(globals, intern("String" ), makeFunction(prim_String , intern("String" ), null, null, globals, null)); + map_set(globals, intern("string" ), makeFunction(prim_String , intern("string" ), null, null, globals, null)); map_set(globals, intern("scope"), makeFunction(prim_scope, intern("scope"), null, null, globals, null));