+ if (lex_token (lexer) != T_NEG_NUM || lex_next_token (lexer, 1) != T_EXP)
+ return parse_binary_operators (lexer, e, &op, 1,
+ parse_primary, chain_warning);
+
+ /* Special case for situations like "-5**6", which must be parsed as
+ -(5**6). */
+
+ int start_ofs = lex_ofs (lexer);
+ struct expr_node *lhs = expr_allocate_number (e, -lex_tokval (lexer));
+ lex_get (lexer);
+ expr_add_location (lexer, e, start_ofs, lhs);
+
+ struct expr_node *node = parse_binary_operators__ (
+ lexer, e, &op, 1, parse_primary, chain_warning, lhs);
+ if (!node)
+ return NULL;
+
+ node = expr_allocate_unary (e, OP_NEG, node);
+ expr_add_location (lexer, e, start_ofs, node);
+ return node;
+}
+
+static double
+ymd_to_offset (int y, int m, int d)
+{
+ char *error;
+ double retval = calendar_gregorian_to_offset (
+ y, m, d, settings_get_fmt_settings (), &error);
+ if (error)
+ {
+ msg (SE, "%s", error);
+ free (error);
+ }
+ return retval;
+}
+
+static struct expr_node *
+expr_date (struct expression *e, int year_digits)
+{
+ static const char *months[12] =
+ {
+ "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
+ "JUL", "AUG", "SEP", "OCT", "NOV", "DEC",
+ };
+
+ time_t last_proc_time = time_of_last_procedure (e->ds);
+ struct tm *time = localtime (&last_proc_time);
+
+ char *tmp = (year_digits == 2
+ ? xasprintf ("%02d-%s-%02d", time->tm_mday, months[time->tm_mon],
+ time->tm_year % 100)
+ : xasprintf ("%02d-%s-%04d", time->tm_mday, months[time->tm_mon],
+ time->tm_year + 1900));
+
+ struct substring s;
+ ss_alloc_substring_pool (&s, ss_cstr (tmp), e->expr_pool);
+
+ free (tmp);
+
+ return expr_allocate_string (e, s);