/* 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;
- /* This is a temporary fix, awaiting the patch for various
- other character problems. The resolution and translation
- of substrings and concatenations are so kludged up that
- putting parentheses around them breaks everything. */
- if (e->ts.type == BT_CHARACTER && e->ref)
- return e;
-
- 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.operator = 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 operator, locus *where,
- gfc_expr *op1, gfc_expr *op2)
-{
- gfc_expr *new;
-
- new = gfc_get_expr ();
- new->expr_type = EXPR_OP;
- new->value.op.operator = operator;
- new->where = *where;
-
- new->value.op.op1 = op1;
- new->value.op.op2 = op2;
-
- return new;
-}
-
-
/* Match a level 1 expression. */
static match
*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;
}