summaryrefslogtreecommitdiffstats
path: root/sh/token.h
blob: c961f0184fb66ed6c8be346ffe278036547e309f (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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#define TEOF 0
#define TNL 1
#define TSEMI 2
#define TBACKGND 3
#define TAND 4
#define TOR 5
#define TPIPE 6
#define TLP 7
#define TRP 8
#define TENDCASE 9
#define TENDBQUOTE 10
#define TREDIR 11
#define TWORD 12
#define TIF 13
#define TTHEN 14
#define TELSE 15
#define TELIF 16
#define TFI 17
#define TWHILE 18
#define TUNTIL 19
#define TFOR 20
#define TDO 21
#define TDONE 22
#define TBEGIN 23
#define TEND 24
#define TCASE 25
#define TESAC 26
#define TNOT 27

/* Array indicating which tokens mark the end of a list */
const char tokendlist[] = {
	1,
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	1,
	1,
	1,
	0,
	0,
	0,
	1,
	1,
	1,
	1,
	0,
	0,
	0,
	1,
	1,
	0,
	1,
	0,
	1,
	0,
};

const char *const tokname[] = {
	"end of file",
	"newline",
	"\";\"",
	"\"&\"",
	"\"&&\"",
	"\"||\"",
	"\"|\"",
	"\"(\"",
	"\")\"",
	"\";;\"",
	"\"`\"",
	"redirection",
	"word",
	"\"if\"",
	"\"then\"",
	"\"else\"",
	"\"elif\"",
	"\"fi\"",
	"\"while\"",
	"\"until\"",
	"\"for\"",
	"\"do\"",
	"\"done\"",
	"\"{\"",
	"\"}\"",
	"\"case\"",
	"\"esac\"",
	"\"!\"",
};

#define KWDOFFSET 13

const char *const parsekwd[] = {
	"if",
	"then",
	"else",
	"elif",
	"fi",
	"while",
	"until",
	"for",
	"do",
	"done",
	"{",
	"}",
	"case",
	"esac",
	"!",
	0
};