/* Considers whether *NODE may be coerced to type REQUIRED_TYPE.
Returns true if possible, false if disallowed.
- If DO_COERCION is zero, then *NODE is not modified and there
+ If DO_COERCION is false, then *NODE is not modified and there
are no side effects.
- Otherwise, DO_COERCION is nonzero. In this case, we perform
- the coercion if possible, possibly modifying *NODE. If the
- coercion is not possible then we free *NODE and set *NODE to
- a null pointer.
+ If DO_COERCION is true, we perform the coercion if possible,
+ modifying *NODE if necessary. If the coercion is not possible
+ then we free *NODE and set *NODE to a null pointer.
This function's interface is somewhat awkward. Use one of the
wrapper functions type_coercion(), type_coercion_assert(), or
case OP_ni_format:
if ((*node)->type == OP_format
- && check_input_specifier (&(*node)->format.f, 0))
+ && check_input_specifier (&(*node)->format.f, false)
+ && check_specifier_type (&(*node)->format.f, NUMERIC, false))
{
if (do_coercion)
(*node)->type = OP_ni_format;
case OP_no_format:
if ((*node)->type == OP_format
- && check_output_specifier (&(*node)->format.f, 0))
+ && check_output_specifier (&(*node)->format.f, false)
+ && check_specifier_type (&(*node)->format.f, NUMERIC, false))
{
if (do_coercion)
(*node)->type = OP_no_format;
}
if (do_coercion)
- msg (SE, _("Type mismatch while applying %s operator: "
- "cannot convert %s to %s."),
- operator_name,
- atom_type_name (actual_type), atom_type_name (required_type));
+ {
+ msg (SE, _("Type mismatch while applying %s operator: "
+ "cannot convert %s to %s."),
+ operator_name,
+ atom_type_name (actual_type), atom_type_name (required_type));
+ *node = NULL;
+ }
return false;
}
/* Convert the left-hand side to type OPERAND_TYPE. */
if (!type_coercion (e, operand_type, &node, operator->name))
- return node;
+ return NULL;
/* Parse the right-hand side and coerce to type
OPERAND_TYPE. */
static const struct operator ops[] =
{
{ '+', OP_ADD, "addition (\"+\")" },
- { '-', OP_SUB, "subtraction (\"-\")-" },
+ { '-', OP_SUB, "subtraction (\"-\")" },
};
return parse_binary_operators (e, parse_mul (e),
}
break;
- case T_NUM:
+ case T_POS_NUM:
+ case T_NEG_NUM:
{
union any_node *node = expr_allocate_number (e, tokval);
lex_get ();
return expr_allocate_binary (e, (vector->var[0]->type == NUMERIC
? OP_VEC_ELEM_NUM : OP_VEC_ELEM_STR),
- expr_allocate_vector (e, vector), element);
+ element, expr_allocate_vector (e, vector));
}
\f
/* Individual function parsing. */
}
else
{
- ds_create (&s, _("Function invocation "));
+ ds_puts (&s, _("Function invocation "));
put_invocation (&s, func_name, args, arg_cnt);
ds_puts (&s, _(" does not match any known function. Candidates are:"));
for (f = first; f < last; f++)
- {
- ds_printf (&s, "\n%s", f->prototype);
- }
+ ds_printf (&s, "\n%s", f->prototype);
}
ds_putc (&s, '.');