-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLexicalParser.h
More file actions
75 lines (61 loc) · 1.05 KB
/
LexicalParser.h
File metadata and controls
75 lines (61 loc) · 1.05 KB
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
/*
* LexicalParser.h
*
* Created on: 07.04.2013
* Author: urandon
*/
#ifndef LEXICALPARSER_H_
#define LEXICALPARSER_H_
#include "Errors.h"
struct lexem {
int type;
int id;
int line;
lexem(int id, int type, int line);
lexem(const lexem & lex);
virtual ~lexem();
};
class LexicalParser {
public:
LexicalParser();
virtual ~LexicalParser();
struct buffer_t {
static const int DEFAULT_SIZE = 64;
char * data;
int size;
int allocated;
buffer_t();
~buffer_t();
void push(char ch);
void flush();
};
enum state_t {
H, N, I, K, A, S, SEP
};
enum lexem_type {
SEPARATOR,
EQUALITY,
NUMERIC,
STRING,
VARIABLE,
LABEL,
LABELREF,
FUNCTION,
KEYWORD
};
class map_t {
char ** strings;
int size, allocated;
public:
map_t();
~map_t();
int push(const char * s, int length);
int push(const char * s);
int getId(const char * s);
const char * getString(int id);
};
virtual lexem * push(int ch) = 0;
virtual bool isEmpty() = 0;
virtual const char * getString(int id) = 0;
};
#endif /* LEXICALPARSER_H_ */