]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
handling of op-[
authorWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 11 Nov 2012 17:54:08 +0000 (18:54 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 11 Nov 2012 17:54:08 +0000 (18:54 +0100)
parser.c

index 2d3dda9452247d6004a865af49142176314c2d55..1bd22059f850e088caac594ec8e7bfccd9c58ce1 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -463,6 +463,20 @@ static bool parser_sy_pop(parser_t *parser, shunt *sy)
             }
             break;
 
+        case opid1('['):
+            if (exprs[0]->expression.vtype != TYPE_ARRAY) {
+                ast_type_to_string(exprs[0], ty1, sizeof(ty1));
+                parseerror(parser, "cannot index value of type %s", ty1);
+                return false;
+            }
+            if (exprs[1]->expression.vtype != TYPE_FLOAT) {
+                ast_type_to_string(exprs[0], ty1, sizeof(ty1));
+                parseerror(parser, "index must be of type float, not %s", ty1);
+                return false;
+            }
+            out = (ast_expression*)ast_array_index_new(ctx, exprs[0], exprs[1]);
+            break;
+
         case opid1(','):
             if (blocks[0]) {
                 if (!ast_block_exprs_add(blocks[0], exprs[1]))