-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconvert.c
More file actions
145 lines (108 loc) · 2.13 KB
/
convert.c
File metadata and controls
145 lines (108 loc) · 2.13 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include <stdio.h>
#ifdef IBMPC
#include <stdlib.h>
#endif
#include "misc.h"
#include "defs.h"
#include "cvt.h"
#include "struct.h"
#include "tokens.h"
BOOLEAN syntax_error;
extern char *text_buffer, *text_ptr;
extern int line_count;
/*
* Determine statement type and call appropriate parse routine.
* Return statement class or, if a reserved word, reserved word token.
*/
parse_statement(first_token)
TOKEN *first_token;
{
int token_type;
/* Flush standard output and standard error */
(void) fflush(stdout);
(void) fflush(stderr);
/* Flag no error yet */
syntax_error = FALSE;
switch (first_token->token_class) {
case RESERVED:
token_type = first_token->token_type;
switch (token_type) {
case DECLARE :
parse_declare(first_token);
break;
case DO :
parse_do(first_token);
break;
case IF :
parse_if(first_token);
break;
case THEN :
parse_then();
break;
case ELSE :
parse_else(first_token);
break;
case GOTO :
parse_goto(first_token);
break;
case GO :
parse_go(first_token);
break;
case CALL :
parse_call(first_token);
break;
case RETURN :
parse_return(first_token);
break;
case END :
parse_end(first_token);
break;
case DISABLE :
parse_int_ctl(first_token);
break;
case ENABLE :
parse_int_ctl(first_token);
break;
case OUTPUT :
parse_output(first_token);
break;
case OUTWORD :
parse_outword(first_token);
break;
case OUTHWORD :
parse_outhword(first_token);
break;
default :
parse_error("Illegal reserved word");
return ERROR;
}
return token_type;
case IDENTIFIER:
parse_identifier(first_token);
break;
case LABEL:
parse_label();
break;
case END_OF_LINE:
parse_eol(first_token);
break;
case END_OF_FILE:
out_white_space(first_token);
return END_OF_FILE;
default:
parse_error("Illegal statement");
return ERROR;
}
return first_token->token_class;
}
parse_new_statement()
{
TOKEN first_token;
/* Get first token on line */
(void) get_token(&first_token);
return parse_statement(&first_token);
}
parse_file()
{
while (parse_new_statement() != END_OF_FILE) ;
}