}
}
+static jv f_negate(jv input) {
+ if (jv_get_kind(input) != JV_KIND_NUMBER) {
+ return type_error(input, "cannot be negated");
+ }
+ jv ret = jv_number(-jv_number_value(input));
+ jv_free(input);
+ return ret;
+}
+
static jv f_minus(jv input, jv a, jv b) {
jv_free(input);
if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) {
static struct cfunction function_list[] = {
{(cfunction_ptr)f_plus, "_plus", 3},
+ {(cfunction_ptr)f_negate, "_negate", 1},
{(cfunction_ptr)f_minus, "_minus", 3},
{(cfunction_ptr)f_multiply, "_multiply", 3},
{(cfunction_ptr)f_divide, "_divide", 3},
yylval->literal = jv_string_sized(yytext + 1, yyleng - 1); return FORMAT;
}
--?[0-9.]+([eE][+-]?[0-9]+)? {
+[0-9.]+([eE][+-]?[0-9]+)? {
yylval->literal = jv_parse_sized(yytext, yyleng); return LITERAL;
}
$$ = gen_update($1, $3, '+');
} |
+'-' Exp {
+ $$ = BLOCK($2, gen_call("_negate", gen_noop()));
+} |
+
Exp '-' Exp {
$$ = gen_binop($1, $3, '-');
} |