# HG changeset patch # User Laurent Bessard # Date 1350920680 -7200 # Node ID dd57e63bdc3d2e8f6550e819947efd8363081d4b # Parent 736b36a83548e33f8e28db04c9ee5cf89a5352ae# Parent a20a70021d37f4ddd89840c0dcc94ad5b1fd0ea3 Merged diff -r a20a70021d37 -r dd57e63bdc3d stage1_2/iec_flex.ll --- a/stage1_2/iec_flex.ll Sun Oct 21 16:55:08 2012 +0200 +++ b/stage1_2/iec_flex.ll Mon Oct 22 17:44:40 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 a20a70021d37 -r dd57e63bdc3d stage4/generate_c/generate_c.cc --- a/stage4/generate_c/generate_c.cc Sun Oct 21 16:55:08 2012 +0200 +++ b/stage4/generate_c/generate_c.cc Mon Oct 22 17:44:40 2012 +0200 @@ -1022,8 +1022,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 a20a70021d37 -r dd57e63bdc3d stage4/generate_c/generate_c_base.cc --- a/stage4/generate_c/generate_c_base.cc Sun Oct 21 16:55:08 2012 +0200 +++ b/stage4/generate_c/generate_c_base.cc Mon Oct 22 17:44:40 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; + } /***************************/