/[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 2888 by schoenebeck, Sun Apr 24 18:16:10 2016 UTC revision 3054 by schoenebeck, Thu Dec 15 12:47:45 2016 UTC
# Line 38  Line 38 
38  }  }
39    
40  static void scanner_error(YYLTYPE* locp, LinuxSampler::ParserContext* context, const char* err) {  static void scanner_error(YYLTYPE* locp, LinuxSampler::ParserContext* context, const char* err) {
41      context->addErr(locp->first_line, locp->first_column, err);      context->addErr(locp->first_line, locp->last_line, locp->first_column, locp->last_column, err);
42  }  }
43    
44  static void scanner_warning(YYLTYPE* locp, LinuxSampler::ParserContext* context, const char* txt) {  static void scanner_warning(YYLTYPE* locp, LinuxSampler::ParserContext* context, const char* txt) {
45      context->addWrn(locp->first_line, locp->first_column, txt);      context->addWrn(locp->first_line, locp->last_line, locp->first_column, locp->last_column, txt);
46  }  }
47    
48  #define SCANNER_ERR(txt)  scanner_error(yylloc, yyextra, txt)  #define SCANNER_ERR(txt)  scanner_error(yylloc, yyextra, txt)
49  #define SCANNER_WRN(txt)  scanner_warning(yylloc, yyextra, txt)  #define SCANNER_WRN(txt)  scanner_warning(yylloc, yyextra, txt)
50    
51    // shut up warning that 'register' keyword is deprecated as of C++11
52    #if defined(__cplusplus) && __cplusplus >= 201103L
53    # define register
54    #endif
55    
56  using namespace LinuxSampler;  using namespace LinuxSampler;
57    
58  static int countNewLineChars(const char* txt) {  static int countNewLineChars(const char* txt) {
# Line 58  static int countNewLineChars(const char* Line 63  static int countNewLineChars(const char*
63  }  }
64    
65  static int countCharsPastLastNewLine(const char* txt) {  static int countCharsPastLastNewLine(const char* txt) {
66      const int n = strlen(txt);      const int n = (int)strlen(txt);
67      for (int i = n - 1; i >= 0; --i)      for (int i = n - 1; i >= 0; --i)
68          if (txt[i] == '\n')          if (txt[i] == '\n')
69              return n - i - 1;              return n - i - 1;
# Line 96  static int countCharsPastLastNewLine(con Line 101  static int countCharsPastLastNewLine(con
101  %x PREPROC_SET_COND PREPROC_RESET_COND PREPROC_IF PREPROC_IF_NOT PREPROC_BODY_EAT PREPROC_PRE_BODY_USE PREPROC_PRE_BODY_EAT  %x PREPROC_SET_COND PREPROC_RESET_COND PREPROC_IF PREPROC_IF_NOT PREPROC_BODY_EAT PREPROC_PRE_BODY_USE PREPROC_PRE_BODY_EAT
102    
103  DIGIT    [0-9]  DIGIT    [0-9]
104  ID       [a-zA-Z0-9_]*  ID       [a-zA-Z0-9_]+
105    
106  %%  %%
107    
# Line 111  ID       [a-zA-Z0-9_]* Line 116  ID       [a-zA-Z0-9_]*
116      return INTEGER;      return INTEGER;
117  }  }
118    
119  {DIGIT}+"."{DIGIT}* {   /* there is currently no support for floating point numbers in NKSP yet */
120     /*{DIGIT}+"."{DIGIT}* {
121      printf("A float: %s (%g)\n", yytext, atof(yytext));      printf("A float: %s (%g)\n", yytext, atof(yytext));
122  }   }*/
123    
124    
125   /* Preprocessor statement:  SET_CONDITION(name) */   /* Preprocessor statement:  SET_CONDITION(name) */
# Line 223  ID       [a-zA-Z0-9_]* Line 229  ID       [a-zA-Z0-9_]*
229  "declare" return DECLARE;  "declare" return DECLARE;
230  "while" return WHILE;  "while" return WHILE;
231  "if" return IF;  "if" return IF;
232    ".or." return BITWISE_OR;
233  "or" return OR;  "or" return OR;
234  "release" return RELEASE;  "release" return RELEASE;
235    ".and." return BITWISE_AND;
236  "and" return AND;  "and" return AND;
237    ".not." return BITWISE_NOT;
238  "not" return NOT;  "not" return NOT;
239  "else" return ELSE;  "else" return ELSE;
240  "controller" return CONTROLLER;  "controller" return CONTROLLER;
# Line 237  ID       [a-zA-Z0-9_]* Line 246  ID       [a-zA-Z0-9_]*
246  "const" return CONST_; // note: "CONST" is already defined for C/C++ compilers on Windows by default  "const" return CONST_; // note: "CONST" is already defined for C/C++ compilers on Windows by default
247  "polyphonic" return POLYPHONIC;  "polyphonic" return POLYPHONIC;
248  "mod" return MOD;  "mod" return MOD;
249    "function" return FUNCTION;
250    "call" return CALL;
251    
252  on|end|note|init|declare|if|then|begin|end|procedure|function {  [&,()[\]<>=*+#/-] {
253      printf("A keyword: %s\n", yytext);      return *yytext;
 }  
   
 [&,()[\]<>=*+#/-] { return *yytext; }  
   
 ("$"|"@"){ID} {  
     yylval->sValue = strdup(yytext);  
     return VARIABLE;  
254  }  }
255    
256  "%"{ID} {  ("$"|"@"|"%"){ID} {
257      yylval->sValue = strdup(yytext);      yylval->sValue = strdup(yytext);
258      return VARIABLE;      return VARIABLE;
259  }  }
# Line 274  on|end|note|init|declare|if|then|begin|e Line 278  on|end|note|init|declare|if|then|begin|e
278    
279  [ \t\r]+ /* eat up whitespace */  [ \t\r]+ /* eat up whitespace */
280    
281  "..." /* eat up */  . printf( "Unrecognized character: '%s' (line %d, column %d)\n", yytext, yylineno, yycolumn);
   
 . printf( "Unrecognized character: %s\n", yytext );  
282    
283  %%  %%
284    

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

  ViewVC Help
Powered by ViewVC