blob: 2757d606a6c63c893a447903b712f0f38085b7a5 (
plain) (
blame)
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
|
#ifndef ARZU_INTERPRETER_PARSER
#define ARZU_INTERPRETER_PARSER
#include <list>
#include <deque>
#include <string>
#include <fstream>
#include "Memory.h"
using namespace std;
struct Instruction {
string name;
unsigned argc;
void (*exec)(Memory&);
Instruction(const char* str, unsigned argc, void (*exec)(Memory&));
};
struct Atom {
bool (*isAtomChar)(char);
MemoryData* (*absorb)(ifstream&);
Atom(bool (*isAtomChar)(char), MemoryData* (*absorb)(ifstream&));
};
class PNParser {
deque<Instruction> instr;
deque<Atom> atoms;
void evaluateFunction(Memory& mem, Function* func, ifstream& inFile);
void pushToWork(Memory& mem, MemoryData* data, ifstream& inFile);
void parseScope(ifstream& inFile, Memory& mem, int start, int end);
public:
PNParser() = default;
void addInstr(Instruction);
void addAtom(Atom);
void parse(ifstream&, Memory&);
};
#endif
|