-
Notifications
You must be signed in to change notification settings - Fork 0
/
extend.hpp
55 lines (36 loc) · 944 Bytes
/
extend.hpp
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
//
// Created by tate on 01-03-19.
//
#ifndef YS2_NAMESPACE_HPP
#define YS2_NAMESPACE_HPP
#include <string>
#include <unordered_map>
class Value;
class Frame;
class Exit;
// definition - gets run as soon as it's placed onto stack (in between tokens)
class Def {
public:
bool native; // use the fxnptr?
bool run;
Value* _val;
Exit (*act)(Frame&);
Def(const Value& value, const bool runnable = false);
Def(Exit (*action)(Frame&));
Def(const Def& def);
Def();
~Def();
};
// collection of labelled defs
typedef std::unordered_map<std::string, Def> Namespace;
// for handling things which aren't simple space delimited operators
// ie- adding a new literal type
typedef struct Token {
// if i want to call this from another token/operator
const char* name;
// condition for parsing
bool (*condition)(Frame&);
// run if condition true or if called externally
Exit (*act)(Frame&);
} Token;
#endif //YS2_NAMESPACE_HPP