|
ADS
Algorithms and Data Structures
|
Arithmetic expressions with a STACK [see ADT.h], beyond the book: the operands are nonnegative integers, the operators the binary +, -, * and / (the division truncated toward zero), and the tokens of an expression may be separated by spaces. More...
#include "ADS/Contract.h"#include "ADS/stack/ArrayStack.h"#include <cstddef>#include <limits>#include <string>#include <string_view>#include <vector>#include "ADS/stack/impl/Expressions.tpp"Go to the source code of this file.
Namespaces | |
| namespace | ADS |
Functions | |
| long | ADS::evalPostfix (std::string_view e) |
| the value of the postfix expression \( e \) | |
| std::string | ADS::toPostfixParenthesized (std::string_view e) |
| the postfix form of the fully parenthesized infix expression \( e \), its tokens separated by one space | |
| std::string | ADS::toPostfix (std::string_view e) |
| the postfix form of the infix expression \( e \), with the usual precedences and the associativity to the left, its tokens separated by one space | |
Arithmetic expressions with a STACK [see ADT.h], beyond the book: the operands are nonnegative integers, the operators the binary +, -, * and / (the division truncated toward zero), and the tokens of an expression may be separated by spaces.
The contracts [see Contract.h]: each operator of a postfix expression finds two operands on the stack, one item is left at the end, no division is by 0 and no operation overflows a long (an operand beyond a long throws the std::out_of_range of std::stol); an infix expression has balanced parentheses and only the tokens above, and a fully parenthesized one has an operator for each pair of parentheses. The functions are defined in Expressions.tpp.