# HG changeset patch # User Edouard Tisserant # Date 1350641432 -7200 # Node ID 736b36a83548e33f8e28db04c9ee5cf89a5352ae # Parent 73b56dc69e610ae030316bba6f7cbea674c69f1d Added double curly braces for pragma (kept single curly braces for compatibility). Added macro def and undef surrounding pragma to simplify user code. Moved useless comment from generated code back to code generator. diff -r 73b56dc69e61 -r 736b36a83548 stage1_2/iec_flex.ll --- a/stage1_2/iec_flex.ll Thu Sep 13 16:35:10 2012 +0200 +++ b/stage1_2/iec_flex.ll Fri Oct 19 12:10:32 2012 +0200 @@ -513,7 +513,7 @@ /* Any other pragma... */ -pragma "{"[^}]*"}" +pragma "{"[^}]*"}"|"{{"([^}]|"}"[^}])*"}}" /* NOTE: this seemingly unnecessary complex definition is required * to be able to eat up comments such as: @@ -849,8 +849,9 @@ /* Any other pragma we find, we just pass it up to the syntax parser... */ /* Note that the state is exclusive, so we have to include it here too. */ {pragma} {/* return the pragmma without the enclosing '{' and '}' */ - yytext[strlen(yytext)-1] = '\0'; - yylval.ID=strdup(yytext+1); + uint cut = yytext[1]=='{'?2:1; + yytext[strlen(yytext)-cut] = '\0'; + yylval.ID=strdup(yytext+cut); return pragma_token; } {pragma} {/* return the pragmma without the enclosing '{' and '}' */ diff -r 73b56dc69e61 -r 736b36a83548 stage4/generate_c/generate_c.cc --- a/stage4/generate_c/generate_c.cc Thu Sep 13 16:35:10 2012 +0200 +++ b/stage4/generate_c/generate_c.cc Fri Oct 19 12:10:32 2012 +0200 @@ -962,8 +962,7 @@ * To work around this we introduce the useless goto. */ s4o.print("\n"); - s4o.print(s4o.indent_spaces); - s4o.print("/* to humour the compiler, we insert a goto */\n"); + /* to humour the compiler, we insert a goto */ s4o.print(s4o.indent_spaces); s4o.print("goto "); s4o.print(END_LABEL); diff -r 73b56dc69e61 -r 736b36a83548 stage4/generate_c/generate_c_base.cc --- a/stage4/generate_c/generate_c_base.cc Thu Sep 13 16:35:10 2012 +0200 +++ b/stage4/generate_c/generate_c_base.cc Fri Oct 19 12:10:32 2012 +0200 @@ -260,7 +260,19 @@ void *visit(disable_code_generation_pragma_c * symbol) {s4o.disable_output(); return NULL;} /* Do not use print_token() as it will change everything into uppercase */ - void *visit(pragma_c *symbol) {return s4o.print(symbol->value);} + void *visit(pragma_c *symbol) { + s4o.print(s4o.indent_spaces); + s4o.print("#define GetFbVar(var,...) __GET_VAR(data__->var,__VA_ARGS__)\n"); + s4o.print(s4o.indent_spaces); + s4o.print("#define SetFbVar(var,val,...) __SET_VAR(data__->,var,val,__VA_ARGS__)\n"); + s4o.print(symbol->value); + s4o.print("\n"); + s4o.print(s4o.indent_spaces); + s4o.print("#undef GetFbVar\n"); + s4o.print(s4o.indent_spaces); + s4o.print("#undef SetFbVar\n"); + return NULL; + } /***************************/