-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathparser.c
61 lines (59 loc) · 1.05 KB
/
parser.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
51
52
53
54
55
56
57
58
59
60
61
#include "parser.h"
void ma_parse(
struct DynArray *tkns,
struct hashtable *symbol_table,
struct maExp *top_level
)
{
int idx = 0;
struct DynArray stack;
da_DynArray_init(&stack, 0, sizeof(maExp));
while (idx < tkns->size) {
maToken* t;
da_get_ref(tkns, idx, &t);
switch (t->tag) {
case MA_TKN_NAT:
da_append(&stack, t);
break;
case MA_TKN_VAR:
da_append(&stack, t);
break;
/*
MA_TKN_NAT_TYPE,
MA_TKN_ARROW_TYPE,
MA_TKN_CMD_TYPE,
MA_TKN_LBRACKET,
MA_TKN_RBRACKET,
MA_TKN_LPAREN,
MA_TKN_RPAREN,
MA_TKN_LAMBDA,
MA_TKN_VBAR,
MA_TKN_DOT,
MA_TKN_COLON,
MA_TKN_SEMICOLON,
MA_TKN_RIGHTARROW,
MA_TKN_LEFTARROW,
MA_TKN_ASSIGN,
MA_TKN_SYMBOL,
*/
}
}
da_DynArray_del(&stack);
}
/* SHIFT REDUCE TABLE
* + , - , / , % , * , ^ , NAT , VAR , { , } , ( , ) , \ , | , .
*
*
*
*
*
*
*
* ; , -> , <- , := , fix , is , cmd , ret , bnd , dcl , in , @
*
*
*
*
*
*
*/