* Implementation of GiNaC's parser. */
/*
- * GiNaC Copyright (C) 1999-2019 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2023 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "mul.h"
#include "constant.h"
#include "function.h"
+#include "operators.h"
#include <cstdint> // for uintptr_t
#include <sstream>
return list;
}
-extern const ex _ex0;
-
-/// unary_expr: [+-] expression
-ex parser::parse_unary_expr()
-{
- // Unlike most other parse_* method this one does NOT consume
- // current token so parse_binop_rhs() knows what kind of operator
- // is being parsed.
-
- // There are different kinds of expressions which need to be handled:
- // -a+b
- // -(a)
- // +a
- // +(a)
- // Delegate the work to parse_binop_rhs(), otherwise we end up
- // duplicating it here.
- ex lhs = _ex0; // silly trick
- ex e = parse_binop_rhs(0, lhs);
- return e;
-}
-
/// primary: identifier_expr | number_expr | paren_expr | unary_expr
ex parser::parse_primary()
{
case '{':
return parse_lst_expr();
case '-':
+ return -parse_unary_expr();
case '+':
return parse_unary_expr();
case lexer::token_type::literal: