--- linuxsampler/trunk/src/scriptvm/scanner.l 2017/07/11 23:06:38 3307 +++ linuxsampler/trunk/src/scriptvm/scanner.l 2017/07/15 01:14:20 3308 @@ -76,6 +76,13 @@ if (nl) yycolumn = countCharsPastLastNewLine(yytext); \ } +// if compiled for debugging, throw an exception instead of exiting on fatal +// lexer errors (so the debugger may pause with the appropriate back trace) +#if DEBUG +# include +# define YY_FATAL_ERROR(msg) throw std::runtime_error(msg) +#endif + %} /* use Flex's built-in support for line numbers @@ -176,13 +183,21 @@ */ <*>"USE_CODE_IF"[ \t]*"(" { - //printf("USE_CODE_IF\n"); + //printf("{%s}\n", yytext); yy_push_state(PREPROC_IF, yyscanner); } +"USE_CODE_IF"[ \t]*"("{ID}")" { + //printf("[EAT{%s}\n", yytext); + yy_push_state(PREPROC_BODY_EAT, yyscanner); +} <*>"USE_CODE_IF_NOT"[ \t]*"(" { //printf("USE_CODE_IF_NOT\n"); yy_push_state(PREPROC_IF_NOT, yyscanner); } +"USE_CODE_IF_NOT"[ \t]*"("{ID}")" { + //printf("[EAT{%s}\n", yytext); + yy_push_state(PREPROC_BODY_EAT, yyscanner); +} {ID} { //printf("preproc use code if '%s'\n", yytext); yy_pop_state(yyscanner); @@ -204,18 +219,20 @@ yy_push_state(PREPROC_BODY_USE, yyscanner); } [ \t]*")" { - //printf("PREPROCESSOR EAT : \n"); + //printf("PREPROCESSOR EAT : {%s}\n", yytext); yy_pop_state(yyscanner); yy_push_state(PREPROC_BODY_EAT, yyscanner); } -<*>.*"END_USE_CODE" { +"END_USE_CODE" { //printf("-->END_USE_CODE\n"); yy_pop_state(yyscanner); } [ \t\r\n]* { /* eat up code block filtered out by preprocessor */ + //printf("PREPROCESSOR EAT2 : {%s}\n", yytext); processLocation(); } .* { /* eat up code block filtered out by preprocessor */ + //printf("PREPROCESSOR EAT3 : {%s}\n", yytext); yyextra->addPreprocessorComment(yylloc->first_line, yylloc->last_line, yylloc->first_column+1, yylloc->last_column+1); }