/[svn]/linuxsampler/trunk/src/scriptvm/parser.y
ViewVC logotype

Diff of /linuxsampler/trunk/src/scriptvm/parser.y

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

revision 3732 by schoenebeck, Fri Jan 31 10:57:53 2020 UTC revision 3733 by schoenebeck, Sat Feb 1 18:11:20 2020 UTC
# Line 28  Line 28 
28              loc.first_line, loc.last_line, loc.first_column+1, \              loc.first_line, loc.last_line, loc.first_column+1, \
29              loc.last_column+1, loc.first_byte, loc.length_bytes \              loc.last_column+1, loc.first_byte, loc.length_bytes \
30          );          );
31        #define CODE_BLOCK(loc) { \
32            .firstLine = loc.first_line, .lastLine = loc.last_line, \
33            .firstColumn = loc.first_column+1, .lastColumn = loc.last_column+1, \
34            .firstByte = loc.first_byte, .lengthBytes = loc.length_bytes \
35        }
36        #define ASSIGNED_EXPR_BLOCK(loc) { \
37            .firstLine = loc.first_line, .lastLine = loc.last_line, \
38            .firstColumn = loc.first_column+3, .lastColumn = loc.last_column+1, \
39            .firstByte = loc.first_byte+2, .lengthBytes = loc.length_bytes-2 \
40        }
41      #define yytnamerr(res,str)  InstrScript_tnamerr(res, str)      #define yytnamerr(res,str)  InstrScript_tnamerr(res, str)
42  %}  %}
43    
# Line 61  Line 71 
71  %token ASSIGNMENT "operator ':='"  %token ASSIGNMENT "operator ':='"
72  %token CONST_ "keyword 'const'"  %token CONST_ "keyword 'const'"
73  %token POLYPHONIC "keyword 'polyphonic'"  %token POLYPHONIC "keyword 'polyphonic'"
74    %token PATCH "keyword 'patch'"
75  %token WHILE "keyword 'while'"  %token WHILE "keyword 'while'"
76  %token SYNCHRONIZED "keyword 'synchronized'"  %token SYNCHRONIZED "keyword 'synchronized'"
77  %token IF "keyword 'if'"  %token IF "keyword 'if'"
# Line 205  statement: Line 216  statement:
216          $$ = new NoOperation; // just as default result value          $$ = new NoOperation; // just as default result value
217          const bool qConst      = $2 & QUALIFIER_CONST;          const bool qConst      = $2 & QUALIFIER_CONST;
218          const bool qPolyphonic = $2 & QUALIFIER_POLYPHONIC;          const bool qPolyphonic = $2 & QUALIFIER_POLYPHONIC;
219            const bool qPatch      = $2 & QUALIFIER_PATCH;
220          const char* name = $3;          const char* name = $3;
221          ExpressionRef expr = $4;          ExpressionRef expr = $4;
222          //printf("declared var '%s'\n", name);          //printf("declared var '%s'\n", name);
223          const ExprType_t declType = exprTypeOfVarName(name);          const ExprType_t declType = exprTypeOfVarName(name);
224            if (qPatch)
225                context->patchVars[name].nameBlock = CODE_BLOCK(@3);
226          if (context->variableByName(name)) {          if (context->variableByName(name)) {
227              PARSE_ERR(@3, (String("Redeclaration of variable '") + name + "'.").c_str());              PARSE_ERR(@3, (String("Redeclaration of variable '") + name + "'.").c_str());
228          } else if (qConst && !expr) {          } else if (qConst && !expr) {
# Line 249  statement: Line 263  statement:
263                      }                      }
264                  }                  }
265              } else {              } else {
266                    if (qPatch)
267                        context->patchVars[name].exprBlock = ASSIGNED_EXPR_BLOCK(@4);
268                  if (qPolyphonic && !isNumber(expr->exprType())) {                  if (qPolyphonic && !isNumber(expr->exprType())) {
269                      PARSE_ERR(@3, "Polyphonic variables must only be declared either as integer or real number type.");                      PARSE_ERR(@3, "Polyphonic variables must only be declared either as integer or real number type.");
270                  } else if (expr->exprType() == STRING_EXPR) {                  } else if (expr->exprType() == STRING_EXPR) {
# Line 363  statement: Line 379  statement:
379          $$ = new NoOperation; // just as default result value          $$ = new NoOperation; // just as default result value
380          const bool qConst      = $2 & QUALIFIER_CONST;          const bool qConst      = $2 & QUALIFIER_CONST;
381          const bool qPolyphonic = $2 & QUALIFIER_POLYPHONIC;          const bool qPolyphonic = $2 & QUALIFIER_POLYPHONIC;
382            const bool qPatch      = $2 & QUALIFIER_PATCH;
383          const char* name = $3;          const char* name = $3;
384            if (qPatch)
385                context->patchVars[name].nameBlock = CODE_BLOCK(@3);
386          if (!$5->isConstExpr()) {          if (!$5->isConstExpr()) {
387              PARSE_ERR(@5, (String("Array variable '") + name + "' must be declared with constant array size.").c_str());              PARSE_ERR(@5, (String("Array variable '") + name + "' must be declared with constant array size.").c_str());
388          } else if ($5->exprType() != INT_EXPR) {          } else if ($5->exprType() != INT_EXPR) {
# Line 394  statement: Line 413  statement:
413                          PARSE_ERR(@3, (String("Variable '") + name + "' declared as unknown array type: use either '%' or '?' instead of '" + String(name).substr(0,1) + "'.").c_str());                          PARSE_ERR(@3, (String("Variable '") + name + "' declared as unknown array type: use either '%' or '?' instead of '" + String(name).substr(0,1) + "'.").c_str());
414                      }                      }
415                  } else {                  } else {
416                        if (qPatch)
417                            context->patchVars[name].exprBlock = ASSIGNED_EXPR_BLOCK(@7);
418                      if (size <= 0) {                      if (size <= 0) {
419                          PARSE_ERR(@5, (String("Array variable '") + name + "' must be declared with positive array size.").c_str());                          PARSE_ERR(@5, (String("Array variable '") + name + "' must be declared with positive array size.").c_str());
420                      } else if (args->argsCount() > size) {                      } else if (args->argsCount() > size) {
# Line 717  qualifier: Line 738  qualifier:
738      | POLYPHONIC  {      | POLYPHONIC  {
739          $$ = QUALIFIER_POLYPHONIC;          $$ = QUALIFIER_POLYPHONIC;
740      }      }
741        | PATCH  {
742            $$ = QUALIFIER_PATCH;
743        }
744    
745  opt_assignment:  opt_assignment:
746      /* epsilon (empty argument) */  {      /* epsilon (empty argument) */  {

Legend:
Removed from v.3732  
changed lines
  Added in v.3733

  ViewVC Help
Powered by ViewVC