static const oper_info fte_operators[] = {
{ "(", 0, opid1('('), ASSOC_LEFT, 99, OP_PREFIX}, /* paren expression - non function call */
+ { "++", 1, opid3('S','+','+'), ASSOC_LEFT, 16, OP_SUFFIX},
+ { "--", 1, opid3('S','-','-'), ASSOC_LEFT, 16, OP_SUFFIX},
+
{ ".", 2, opid1('.'), ASSOC_LEFT, 15, 0 },
{ "(", 0, opid1('('), ASSOC_LEFT, 15, 0 }, /* function call */
{ "[", 2, opid1('['), ASSOC_LEFT, 15, 0 }, /* array subscript */
(ast_expression*)parser_const_float(parser, 1));
}
break;
+ case opid3('S','+','+'):
+ case opid3('S','-','-'):
+ /* prefix ++ */
+ if (exprs[0]->expression.vtype != TYPE_FLOAT) {
+ ast_type_to_string(exprs[0], ty1, sizeof(ty1));
+ parseerror(parser, "invalid type for prefix increment: %s", ty1);
+ return false;
+ }
+ if (op->id == opid3('+','+','P'))
+ addop = INSTR_ADD_F;
+ else
+ addop = INSTR_SUB_F;
+ if (ast_istype(exprs[0], ast_entfield)) {
+ out = (ast_expression*)ast_binstore_new(ctx, INSTR_STOREP_F, addop,
+ exprs[0],
+ (ast_expression*)parser_const_float(parser, 1));
+ } else {
+ out = (ast_expression*)ast_binstore_new(ctx, INSTR_STORE_F, addop,
+ exprs[0],
+ (ast_expression*)parser_const_float(parser, 1));
+ }
+ break;
case opid2('+','='):
case opid2('-','='):
if (exprs[0]->expression.vtype != exprs[1]->expression.vtype ||
else
{
/* classify the operator */
- /* TODO: suffix operators */
const oper_info *op;
const oper_info *olast = NULL;
size_t o;
for (o = 0; o < operator_count; ++o) {
if ((!(operators[o].flags & OP_PREFIX) == wantop) &&
- !(operators[o].flags & OP_SUFFIX) && /* remove this */
+ /* !(operators[o].flags & OP_SUFFIX) && / * remove this */
!strcmp(parser_tokval(parser), operators[o].op))
{
break;
} else {
DEBUGSHUNTDO(con_out("push operator %s\n", op->op));
vec_push(sy.ops, syop(parser_ctx(parser), op));
- wantop = false;
+ wantop = !!(op->flags & OP_SUFFIX);
}
}
if (!parser_next(parser)) {