-
Notifications
You must be signed in to change notification settings - Fork 0
/
lexing_process.c
50 lines (46 loc) · 1.36 KB
/
lexing_process.c
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
#include <stdlib.h>
#include "compiler.h"
#include "utils/vector.h"
/**
* for init lexing process
* @param compileProcess
* @param functions
* @param private
* @return
*/
struct lexing_process *create_lexing_process(struct compile_process *compileProcess,
struct lexing_process_functions *functions,
void *private) {
struct lexing_process *lexingProcess = calloc(1, sizeof(struct lexing_process));
lexingProcess->functions = functions;
lexingProcess->token_vector = vector_create(sizeof(struct token));
lexingProcess->compiler = compileProcess;
lexingProcess->private = private;
lexingProcess->position.line = 1;
lexingProcess->position.column = 1;
return lexingProcess;
}
/**
* for free lexing_process
* @param lexingProcess
*/
void free_lexing_process(struct lexing_process *lexingProcess) {
vector_free(lexingProcess->token_vector);
free(lexingProcess);
}
/**
* get the private data of lexing process
* @param lexingProcess
* @return
*/
void *lexing_process_private(struct lexing_process *lexingProcess) {
return lexingProcess->private;
}
/**
* get the token vector of lexing process
* @param lexingProcess
* @return
*/
struct vector *lexing_process_tokens(struct lexing_process *lexingProcess) {
return lexingProcess->token_vector;
}