blob: 2bd208177995031e8731952fc854a27becc4a085 (
plain)
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
|
#include <stdlib.h>
#include <stdio.h>
#include <readline/readline.h>
#include <string.h>
#include "defs.h"
#include "preproc.h"
#include "exec.h"
int main() {
char* line;
ShellState shstate = {.shell_vars = make_KeyValMap(1), .aliases = make_KeyValMap(1)};
while (1) {
line = readline("$ ");
if (line[0] == '\0') continue;
if (strcmp(line, "exit") == 0) exit(0);
PreprocArena arena = {
.tokens = make_TokenVec(256),
.chunks = make_ChunkVec(256),
.regions = make_RegionVec(256),
};
TokenPtrVec line_tok_ptrs = lex(line, &arena);
Token* tokstream = malloc(sizeof(Token) * line_tok_ptrs.count);
for (int i = 0; i < line_tok_ptrs.count; i++) {
tokstream[i] = **get_from_TokenPtrVec(&line_tok_ptrs, i);
}
Pipeline pl = parse_tokstream(tokstream);
run_pipeline(pl, &shstate);
free(tokstream);
}
free(line);
}
|