/* Expression parser.
- Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008
+ Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
Contributed by Andy Vaught
{
gfc_expr *e2;
- e2 = gfc_get_expr();
- e2->expr_type = EXPR_OP;
+ e2 = gfc_get_operator_expr (&e->where, INTRINSIC_PARENTHESES, e, NULL);
e2->ts = e->ts;
e2->rank = e->rank;
- e2->where = e->where;
- e2->value.op.op = INTRINSIC_PARENTHESES;
- e2->value.op.op1 = e;
- e2->value.op.op2 = NULL;
+
return e2;
}
{
match m;
gfc_expr *e;
- locus where;
m = gfc_match_literal_constant (result, 0);
if (m != MATCH_NO)
return m;
/* Match an expression in parentheses. */
- where = gfc_current_locus;
-
if (gfc_match_char ('(') != MATCH_YES)
return MATCH_NO;
}
-/* Build an operator expression node. */
-
-static gfc_expr *
-build_node (gfc_intrinsic_op op, locus *where,
- gfc_expr *op1, gfc_expr *op2)
-{
- gfc_expr *new_expr;
-
- new_expr = gfc_get_expr ();
- new_expr->expr_type = EXPR_OP;
- new_expr->value.op.op = op;
- new_expr->where = *where;
-
- new_expr->value.op.op1 = op1;
- new_expr->value.op.op2 = op2;
-
- return new_expr;
-}
-
-
/* Match a level 1 expression. */
static match
locus where;
match m;
+ gfc_gobble_whitespace ();
where = gfc_current_locus;
uop = NULL;
m = match_defined_operator (&uop);
*result = e;
else
{
- f = build_node (INTRINSIC_USER, &where, e, NULL);
+ f = gfc_get_operator_expr (&where, INTRINSIC_USER, e, NULL);
f->value.op.uop = uop;
*result = f;
}
/* As a GNU extension we support an expanded level-2 expression syntax.
Via this extension we support (arbitrary) nesting of unary plus and
minus operations following unary and binary operators, such as **.
- The grammar of section 7.1.1.3 is effectively rewitten as:
+ The grammar of section 7.1.1.3 is effectively rewritten as:
R704 mult-operand is level-1-expr [ power-op ext-mult-operand ]
R704' ext-mult-operand is add-op ext-mult-operand
return MATCH_ERROR;
}
- all = build_node (INTRINSIC_USER, &where, all, e);
+ all = gfc_get_operator_expr (&where, INTRINSIC_USER, all, e);
all->value.op.uop = uop;
}