99 |
%type <nStatement> statement assignment |
%type <nStatement> statement assignment |
100 |
%type <nFunctionCall> functioncall |
%type <nFunctionCall> functioncall |
101 |
%type <nArgs> args opt_arr_assignment |
%type <nArgs> args opt_arr_assignment |
102 |
%type <nExpression> arg expr logical_or_expr logical_and_expr bitwise_or_expr bitwise_and_expr rel_expr add_expr mul_expr unary_expr concat_expr opt_assignment |
%type <nExpression> arg expr logical_or_expr logical_and_expr bitwise_or_expr bitwise_and_expr rel_expr add_expr mul_expr unary_expr concat_expr opt_assignment opt_expr |
103 |
%type <nCaseBranch> caseclause |
%type <nCaseBranch> caseclause |
104 |
%type <nCaseBranches> caseclauses |
%type <nCaseBranches> caseclauses |
105 |
%type <varQualifier> opt_qualifiers qualifiers qualifier |
%type <varQualifier> opt_qualifiers qualifiers qualifier |
375 |
} |
} |
376 |
} |
} |
377 |
} |
} |
378 |
| DECLARE opt_qualifiers VARIABLE '[' expr ']' opt_arr_assignment { |
| DECLARE opt_qualifiers VARIABLE '[' opt_expr ']' opt_arr_assignment { |
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; |
383 |
const char* name = $3; |
const char* name = $3; |
384 |
if (qPatch) |
if (qPatch) |
385 |
context->patchVars[name].nameBlock = CODE_BLOCK(@3); |
context->patchVars[name].nameBlock = CODE_BLOCK(@3); |
386 |
if (!$5->isConstExpr()) { |
if ($5 && !$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 && $5->exprType() != INT_EXPR) { |
389 |
PARSE_ERR(@5, (String("Size of array variable '") + name + "' declared with non integer expression.").c_str()); |
PARSE_ERR(@5, (String("Size of array variable '") + name + "' declared with non integer expression.").c_str()); |
390 |
} else if (context->variableByName(name)) { |
} else if (context->variableByName(name)) { |
391 |
PARSE_ERR(@3, (String("Redeclaration of variable '") + name + "'.").c_str()); |
PARSE_ERR(@3, (String("Redeclaration of variable '") + name + "'.").c_str()); |
396 |
} else { |
} else { |
397 |
IntExprRef sizeExpr = $5; |
IntExprRef sizeExpr = $5; |
398 |
ArgsRef args = $7; |
ArgsRef args = $7; |
399 |
vmint size = sizeExpr->evalInt(); |
vmint size = (sizeExpr) ? sizeExpr->evalInt() : (args) ? args->argsCount() : 0; |
400 |
if (size <= 0) { |
if (size == 0) |
401 |
PARSE_ERR(@5, (String("Array variable '") + name + "' must be declared with positive array size.").c_str()); |
PARSE_WRN(@5, (String("Array variable '") + name + "' declared with zero array size.").c_str()); |
402 |
} else if (sizeExpr->unitType() || sizeExpr->hasUnitFactorNow()) { |
if (size < 0) { |
403 |
|
PARSE_ERR(@5, (String("Array variable '") + name + "' must not be declared with negative array size.").c_str()); |
404 |
|
} else if (sizeExpr && (sizeExpr->unitType() || sizeExpr->hasUnitFactorNow())) { |
405 |
PARSE_ERR(@5, "Units are not allowed as array size."); |
PARSE_ERR(@5, "Units are not allowed as array size."); |
406 |
} else { |
} else { |
407 |
if (sizeExpr->isFinal()) |
if (sizeExpr && sizeExpr->isFinal()) |
408 |
PARSE_WRN(@5, "Final operator '!' is meaningless here."); |
PARSE_WRN(@5, "Final operator '!' is meaningless here."); |
409 |
if (!args) { |
if (!args) { |
410 |
if (name[0] == '?') { |
if (name[0] == '?') { |
417 |
} else { |
} else { |
418 |
if (qPatch) |
if (qPatch) |
419 |
context->patchVars[name].exprBlock = ASSIGNED_EXPR_BLOCK(@7); |
context->patchVars[name].exprBlock = ASSIGNED_EXPR_BLOCK(@7); |
420 |
if (size <= 0) { |
if (size == 0) |
421 |
PARSE_ERR(@5, (String("Array variable '") + name + "' must be declared with positive array size.").c_str()); |
PARSE_WRN(@5, (String("Array variable '") + name + "' declared with zero array size.").c_str()); |
422 |
|
if (size < 0) { |
423 |
|
PARSE_ERR(@5, (String("Array variable '") + name + "' must not be declared with negative array size.").c_str()); |
424 |
} else if (args->argsCount() > size) { |
} else if (args->argsCount() > size) { |
425 |
PARSE_ERR(@7, (String("Array variable '") + name + |
PARSE_ERR(@7, (String("Array variable '") + name + |
426 |
"' was declared with size " + ToString(size) + |
"' was declared with size " + ToString(size) + |
938 |
} |
} |
939 |
} |
} |
940 |
|
|
941 |
|
opt_expr: |
942 |
|
/* epsilon (empty argument) */ { |
943 |
|
$$ = NULL; |
944 |
|
} |
945 |
|
| expr { |
946 |
|
$$ = $1; |
947 |
|
} |
948 |
|
|
949 |
expr: |
expr: |
950 |
concat_expr |
concat_expr |
951 |
|
|