blob: 55037dc0e6dfbbb4f1bcc56da6ff3c9245db99d5 [file] [log] [blame]
Shinichiro Hamaji776ca302015-06-06 03:52:48 +09001#ifndef VALUE_H_
2#define VALUE_H_
3
4#include <memory>
5#include <string>
6#include <vector>
7
8#include "string_piece.h"
9
10using namespace std;
11
12class Evaluator;
13
14class 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
24class 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 Hamajid146f4c2015-06-17 17:51:24 +090037Value* ParseExprImpl(StringPiece s, const char* terms, bool is_command,
38 size_t* index_out, bool trim_right_space = false);
39Value* ParseExpr(StringPiece s, bool is_command = false);
Shinichiro Hamaji776ca302015-06-06 03:52:48 +090040
41string JoinValues(const vector<Value*> vals, const char* sep);
42
Shinichiro Hamaji4c469b32015-06-15 19:53:36 +090043Value* NewExpr3(Value* v1, Value* v2, Value* v3);
44
45Value* NewLiteral(const char* s);
46
Shinichiro Hamaji776ca302015-06-06 03:52:48 +090047#endif // VALUE_H_