blob: 02cf64fa9e18745711b8ffff05b820d9dd2aac61 [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 Hamaji66bd7bc2015-06-19 16:54:06 +090037enum struct ParseExprOpt {
38 NORMAL = 0,
39 DEFINE,
40 COMMAND,
41};
42
43Value* ParseExprImpl(StringPiece s, const char* terms, ParseExprOpt opt,
Shinichiro Hamajid146f4c2015-06-17 17:51:24 +090044 size_t* index_out, bool trim_right_space = false);
Shinichiro Hamaji66bd7bc2015-06-19 16:54:06 +090045Value* ParseExpr(StringPiece s, ParseExprOpt opt = ParseExprOpt::NORMAL);
Shinichiro Hamaji776ca302015-06-06 03:52:48 +090046
Shinichiro Hamaji76ff9832015-06-18 17:11:22 +090047string JoinValues(const vector<Value*>& vals, const char* sep);
Shinichiro Hamaji776ca302015-06-06 03:52:48 +090048
Shinichiro Hamaji4c469b32015-06-15 19:53:36 +090049Value* NewExpr3(Value* v1, Value* v2, Value* v3);
50
Shinichiro Hamajib74b8902015-06-22 18:22:30 +090051Value* NewLiteral(StringPiece s);
Shinichiro Hamaji4c469b32015-06-15 19:53:36 +090052
Shinichiro Hamaji776ca302015-06-06 03:52:48 +090053#endif // VALUE_H_