From 511058c0183248cce4d96c338b53fb58485c9307 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Sun, 11 Nov 2012 18:54:08 +0100 Subject: [PATCH] handling of op-[ --- parser.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/parser.c b/parser.c index 2d3dda9..1bd2205 100644 --- 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])) -- 2.39.2