-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirst.c
63 lines (57 loc) · 1.11 KB
/
first.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
62
63
#include <stdlib.h>
#include <string.h>
#include "first.h"
// return the first of <stats> and <stat>
int
first_stat(char* tkid)
{
if (strcmp(tkid, "readTK") == 0 || strcmp(tkid, "printTK") == 0 ||
strcmp(tkid, "iffTK") == 0 || strcmp(tkid, "iterTK") == 0 ||
strcmp(tkid, "letTK") == 0 || strcmp(tkid, "startTK") == 0) {
return 1;
}
return 0;
}
int
first_mvars(char* tkid)
{
if (strcmp(tkid, ".TK") == 0 || strcmp(tkid, ":TK") == 0) {
return 1;
}
return 0;
}
// return the first of <expr>
int
first_expr(char* tkid)
{
if (first_R(tkid) || first_M(tkid)) {
return 1;
}
return 0;
}
int
first_xhelp(char* tkid)
{
if (strcmp(tkid, "+TK") == 0 || strcmp(tkid, "-TK") == 0 ||
strcmp(tkid, "/TK") == 0 || strcmp(tkid, "*TK") == 0) {
return 1;
}
return 0;
}
int
first_M(char* tkid)
{
if (strcmp(tkid, "%TK") == 0) {
return 1;
}
return 0;
}
int
first_R(char* tkid)
{
if (strcmp(tkid, "(TK") == 0 || strcmp(tkid, "idTK") == 0 ||
strcmp(tkid, "intTK") == 0) {
return 1;
}
return 0;
}