blob: a9ec939c5ca4c6eb8b8a24476083ce8519c1e39d (
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
|
#ifndef PRINT_C
#define PRINT_C PRINT_C
#include<print.h>
void print_keyword_enum(enum Keyword code)
{
switch(code)
{
case KW_MACHINE:
printf("KW_MACHINE");
break;
case KW_STATE:
printf("KW_STATE");
break;
case KW_FROM:
printf("KW_FROM");
break;
case KW_TO:
printf("KW_TO");
break;
case KW_ON:
printf("KW_ON");
break;
case KW_ID:
printf("KW_ID");
break;
case KW_STRING:
printf("KW_STRING");
break;
case KW_NOP:
printf("KW_NOP");
break;
case KW_EOF:
printf("KW_EOF");
break;
case KW_OPEN_SQUARE:
printf("KW_OPEN_SQUARE");
break;
case KW_CLOSE_SQUARE:
printf("KW_CLOSE_SQUARE");
break;
case KW_PIPE:
printf("KW_PIPE");
break;
case KW_SEMI_COLUMN:
printf("KW_SEMI_COLUMN");
break;
case KW_STARTING:
printf("KW_STARTING");
break;
default:
printf("LEXERROR");
}
}
void print_token(struct token *token)
{
size_t i;
printf("[ ");
print_keyword_enum(token->type);
printf(" ");
for(i=0;i<token->size;++i)
printf("%c",token->data[i]);
printf(" ] ");
}
void print_tokens(struct Queue *tokens)
{
struct Queue_Node *it;
for(it=tokens->first;it!=NULL;it=it->prev)
{
print_token( (struct token*)(it->data));
printf(" ");
}
}
#endif
|