/[svn]/linuxsampler/trunk/src/scriptvm/scanner.l
ViewVC logotype

Diff of /linuxsampler/trunk/src/scriptvm/scanner.l

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3054 by schoenebeck, Thu Dec 15 12:47:45 2016 UTC revision 3557 by schoenebeck, Sun Aug 18 00:06:04 2019 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (c) 2014-2016 Christian Schoenebeck and Andreas Persson   * Copyright (c) 2014-2017 Christian Schoenebeck and Andreas Persson
3   *   *
4   * http://www.linuxsampler.org   * http://www.linuxsampler.org
5   *   *
# Line 76  static int countCharsPastLastNewLine(con Line 76  static int countCharsPastLastNewLine(con
76      if (nl) yycolumn = countCharsPastLastNewLine(yytext); \      if (nl) yycolumn = countCharsPastLastNewLine(yytext); \
77  }  }
78    
79    // if compiled for debugging, throw an exception instead of exiting on fatal
80    // lexer errors (so the debugger may pause with the appropriate back trace)
81    #if DEBUG
82    # include <stdexcept>
83    # define YY_FATAL_ERROR(msg) throw std::runtime_error(msg)
84    #endif
85    
86  %}  %}
87    
88  /* use Flex's built-in support for line numbers  /* use Flex's built-in support for line numbers
# Line 112  ID       [a-zA-Z0-9_]+ Line 119  ID       [a-zA-Z0-9_]+
119  }  }
120    
121  {DIGIT}+ {  {DIGIT}+ {
122      yylval->iValue = atoi(yytext);      if (sizeof(vmint) < 8)
123            yylval->iValue = atoi(yytext);
124        else
125            yylval->iValue = atoll(yytext);
126      return INTEGER;      return INTEGER;
127  }  }
128    
# Line 176  ID       [a-zA-Z0-9_]+ Line 186  ID       [a-zA-Z0-9_]+
186   */   */
187    
188  <*>"USE_CODE_IF"[ \t]*"(" {  <*>"USE_CODE_IF"[ \t]*"(" {
189      //printf("USE_CODE_IF\n");      //printf("{%s}\n", yytext);
190      yy_push_state(PREPROC_IF, yyscanner);      yy_push_state(PREPROC_IF, yyscanner);
191  }  }
192    <PREPROC_BODY_EAT>"USE_CODE_IF"[ \t]*"("{ID}")" {
193        //printf("[EAT{%s}\n", yytext);
194        yy_push_state(PREPROC_BODY_EAT, yyscanner);
195    }
196  <*>"USE_CODE_IF_NOT"[ \t]*"(" {  <*>"USE_CODE_IF_NOT"[ \t]*"(" {
197      //printf("USE_CODE_IF_NOT\n");      //printf("USE_CODE_IF_NOT\n");
198      yy_push_state(PREPROC_IF_NOT, yyscanner);      yy_push_state(PREPROC_IF_NOT, yyscanner);
199  }  }
200    <PREPROC_BODY_EAT>"USE_CODE_IF_NOT"[ \t]*"("{ID}")" {
201        //printf("[EAT{%s}\n", yytext);
202        yy_push_state(PREPROC_BODY_EAT, yyscanner);
203    }
204  <PREPROC_IF>{ID} {  <PREPROC_IF>{ID} {
205      //printf("preproc use code if '%s'\n", yytext);      //printf("preproc use code if '%s'\n", yytext);
206      yy_pop_state(yyscanner);      yy_pop_state(yyscanner);
# Line 204  ID       [a-zA-Z0-9_]+ Line 222  ID       [a-zA-Z0-9_]+
222      yy_push_state(PREPROC_BODY_USE, yyscanner);      yy_push_state(PREPROC_BODY_USE, yyscanner);
223  }  }
224  <PREPROC_PRE_BODY_EAT>[ \t]*")" {  <PREPROC_PRE_BODY_EAT>[ \t]*")" {
225      //printf("PREPROCESSOR EAT : \n");      //printf("PREPROCESSOR EAT : {%s}\n", yytext);
226      yy_pop_state(yyscanner);      yy_pop_state(yyscanner);
227      yy_push_state(PREPROC_BODY_EAT, yyscanner);      yy_push_state(PREPROC_BODY_EAT, yyscanner);
228  }  }
229  <*>.*"END_USE_CODE" {  <PREPROC_BODY_EAT,PREPROC_BODY_USE>"END_USE_CODE" {
230      //printf("-->END_USE_CODE\n");      //printf("-->END_USE_CODE\n");
231      yy_pop_state(yyscanner);      yy_pop_state(yyscanner);
232  }  }
233  <PREPROC_BODY_EAT>[ \t\r\n]* { /* eat up code block filtered out by preprocessor */  <PREPROC_BODY_EAT>[ \t\r\n]* { /* eat up code block filtered out by preprocessor */
234        //printf("PREPROCESSOR EAT2 : {%s}\n", yytext);
235      processLocation();      processLocation();
236  }  }
237  <PREPROC_BODY_EAT>.* { /* eat up code block filtered out by preprocessor */  <PREPROC_BODY_EAT>.* { /* eat up code block filtered out by preprocessor */
238      processLocation();      //printf("PREPROCESSOR EAT3 : {%s}\n", yytext);
239        yyextra->addPreprocessorComment(yylloc->first_line, yylloc->last_line,
240                                        yylloc->first_column+1, yylloc->last_column+1);
241  }  }
242    
243    
# Line 248  ID       [a-zA-Z0-9_]+ Line 269  ID       [a-zA-Z0-9_]+
269  "mod" return MOD;  "mod" return MOD;
270  "function" return FUNCTION;  "function" return FUNCTION;
271  "call" return CALL;  "call" return CALL;
272    "synchronized" return SYNCHRONIZED;
273    
274  [&,()[\]<>=*+#/-] {  [&,()[\]<>=*+#/-] {
275      return *yytext;      return *yytext;
# Line 278  ID       [a-zA-Z0-9_]+ Line 300  ID       [a-zA-Z0-9_]+
300    
301  [ \t\r]+ /* eat up whitespace */  [ \t\r]+ /* eat up whitespace */
302    
303  . printf( "Unrecognized character: '%s' (line %d, column %d)\n", yytext, yylineno, yycolumn);  . {
304        printf( "Unrecognized character: '%s' (line %d, column %d)\n", yytext, yylineno, yycolumn);
305        return UNKNOWN_CHAR;
306    }
307    
308  %%  %%
309    

Legend:
Removed from v.3054  
changed lines
  Added in v.3557

  ViewVC Help
Powered by ViewVC