Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 1 | #ifndef VALUE_H_ |
| 2 | #define VALUE_H_ |
| 3 | |
| 4 | #include <memory> |
| 5 | #include <string> |
| 6 | #include <vector> |
| 7 | |
| 8 | #include "string_piece.h" |
| 9 | |
| 10 | using namespace std; |
| 11 | |
| 12 | class Evaluator; |
| 13 | |
| 14 | class Evaluable { |
| 15 | public: |
| 16 | virtual void Eval(Evaluator* ev, string* s) const = 0; |
| 17 | virtual shared_ptr<string> Eval(Evaluator*) const; |
| 18 | |
| 19 | protected: |
| 20 | Evaluable(); |
| 21 | virtual ~Evaluable(); |
| 22 | }; |
| 23 | |
| 24 | class Value : public Evaluable { |
| 25 | public: |
| 26 | virtual ~Value(); |
| 27 | |
| 28 | virtual Value* Compact() { return this; } |
| 29 | |
| 30 | string DebugString() const; |
| 31 | |
| 32 | protected: |
| 33 | Value(); |
| 34 | virtual string DebugString_() const = 0; |
| 35 | }; |
| 36 | |
Shinichiro Hamaji | d146f4c | 2015-06-17 17:51:24 +0900 | [diff] [blame^] | 37 | Value* ParseExprImpl(StringPiece s, const char* terms, bool is_command, |
| 38 | size_t* index_out, bool trim_right_space = false); |
| 39 | Value* ParseExpr(StringPiece s, bool is_command = false); |
Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 40 | |
| 41 | string JoinValues(const vector<Value*> vals, const char* sep); |
| 42 | |
Shinichiro Hamaji | 4c469b3 | 2015-06-15 19:53:36 +0900 | [diff] [blame] | 43 | Value* NewExpr3(Value* v1, Value* v2, Value* v3); |
| 44 | |
| 45 | Value* NewLiteral(const char* s); |
| 46 | |
Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 47 | #endif // VALUE_H_ |