--- linuxsampler/trunk/src/scriptvm/scanner.l 2016/04/25 17:28:23 2889 +++ linuxsampler/trunk/src/scriptvm/scanner.l 2016/12/15 12:47:45 3054 @@ -48,6 +48,11 @@ #define SCANNER_ERR(txt) scanner_error(yylloc, yyextra, txt) #define SCANNER_WRN(txt) scanner_warning(yylloc, yyextra, txt) +// shut up warning that 'register' keyword is deprecated as of C++11 +#if defined(__cplusplus) && __cplusplus >= 201103L +# define register +#endif + using namespace LinuxSampler; static int countNewLineChars(const char* txt) { @@ -58,7 +63,7 @@ } static int countCharsPastLastNewLine(const char* txt) { - const int n = strlen(txt); + const int n = (int)strlen(txt); for (int i = n - 1; i >= 0; --i) if (txt[i] == '\n') return n - i - 1; @@ -96,7 +101,7 @@ %x PREPROC_SET_COND PREPROC_RESET_COND PREPROC_IF PREPROC_IF_NOT PREPROC_BODY_EAT PREPROC_PRE_BODY_USE PREPROC_PRE_BODY_EAT DIGIT [0-9] -ID [a-zA-Z0-9_]* +ID [a-zA-Z0-9_]+ %% @@ -111,9 +116,10 @@ return INTEGER; } -{DIGIT}+"."{DIGIT}* { + /* there is currently no support for floating point numbers in NKSP yet */ + /*{DIGIT}+"."{DIGIT}* { printf("A float: %s (%g)\n", yytext, atof(yytext)); -} + }*/ /* Preprocessor statement: SET_CONDITION(name) */ @@ -223,9 +229,12 @@ "declare" return DECLARE; "while" return WHILE; "if" return IF; +".or." return BITWISE_OR; "or" return OR; "release" return RELEASE; +".and." return BITWISE_AND; "and" return AND; +".not." return BITWISE_NOT; "not" return NOT; "else" return ELSE; "controller" return CONTROLLER; @@ -237,19 +246,14 @@ "const" return CONST_; // note: "CONST" is already defined for C/C++ compilers on Windows by default "polyphonic" return POLYPHONIC; "mod" return MOD; +"function" return FUNCTION; +"call" return CALL; -on|end|note|init|declare|if|then|begin|end|procedure|function { - printf("A keyword: %s\n", yytext); -} - -[&,()[\]<>=*+#/-] { return *yytext; } - -("$"|"@"){ID} { - yylval->sValue = strdup(yytext); - return VARIABLE; +[&,()[\]<>=*+#/-] { + return *yytext; } -"%"{ID} { +("$"|"@"|"%"){ID} { yylval->sValue = strdup(yytext); return VARIABLE; } @@ -274,9 +278,7 @@ [ \t\r]+ /* eat up whitespace */ -"..." /* eat up */ - -. printf( "Unrecognized character: %s\n", yytext ); +. printf( "Unrecognized character: '%s' (line %d, column %d)\n", yytext, yylineno, yycolumn); %%