-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd.h
80 lines (57 loc) · 1.31 KB
/
cmd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#pragma once
#include <vector>
#include "repl/context.h"
#include "repl/expr.h"
#include "repl/parsing.h"
#include "repl/result.h"
#include "repl/token.h"
using Lookahead = std::vector<Token>::const_iterator;
class Cmd {
public:
virtual ~Cmd() {}
virtual void Eval(Context &) const = 0;
static Result<Cmd> Parse(Lookahead &);
};
class LetCmd : public Cmd {
public:
LetCmd(std::string id, std::unique_ptr<Expr> expr);
void Eval(Context &) const override;
private:
std::string id_;
std::unique_ptr<Expr> expr_;
};
class NopCmd : public Cmd {
public:
NopCmd(std::unique_ptr<Expr> expr);
void Eval(Context &) const override;
private:
std::unique_ptr<Expr> expr_;
};
class SizeCmd : public Cmd {
public:
SizeCmd(std::unique_ptr<Expr> expr);
void Eval(Context &) const override;
private:
std::unique_ptr<Expr> expr_;
};
class DepthCmd : public Cmd {
public:
DepthCmd(std::unique_ptr<Expr> expr);
void Eval(Context &) const override;
private:
std::unique_ptr<Expr> expr_;
};
class TTCmd : public Cmd {
public:
TTCmd(std::unique_ptr<Expr> expr);
void Eval(Context &) const override;
private:
std::unique_ptr<Expr> expr_;
};
class CheckCmd : public Cmd {
public:
CheckCmd(std::unique_ptr<Expr> expr);
void Eval(Context &) const override;
private:
std::unique_ptr<Expr> expr_;
};