eval_expr.h
来自「斯坦福Energy211/CME211课《c++编程——地球科学科学家和工程师》」· C头文件 代码 · 共 37 行
H
37 行
// This header file includes declarations that are needed// in more than one source file#include <iostream>#include <sstream>#include <stack>// These numeric codes identify the various types of tokens// that can appear in an expression, which are numbers,// arithmetic operators, and parentheses. #define TOK_NUM 100#define TOK_ADD 101#define TOK_SUB 102#define TOK_MUL 103#define TOK_DIV 104#define TOK_NEG 105#define TOK_LPAR 106#define TOK_RPAR 107// These tokens are included to easily detect and process// the end of input#define TOK_ERR 200#define TOK_EOF 201#define TOK_EOL 202using namespace std;// A stack of doubles is used to evaluate an expression.// Operands are pushed onto the stack. When an operation// is performed, its operands are popped off of the stack,// the operation is performed on them, and the result is// pushed back onto the stacktypedef stack<double> value_stack;// Main scanning and parsing functionsint nexttoken( string& tok_str );int Expr( value_stack& s, int token, string& tok_str );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?