annotate dspanal/char2bin.c @ 408:14302e075f37 default tip

hr-bits: further conditionalize SID-1-diff
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 22 Jul 2024 10:06:38 +0000
parents 8e816bba2ff7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
307
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This program will convert C char array files into straight binary
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * for further processing with other tools.
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <ctype.h>
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <strings.h>
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 /* lexer tokens */
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #define WORD 256
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #define NUMBER 257
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #define HEXBYTE 258
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 /* limits */
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 #define MAXWORD 63
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 #define MAXDIGITS 5
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 char *parser_filename;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 FILE *parser_readF;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 int parser_lineno;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 char parser_read_word[MAXWORD+1];
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 int parser_read_number;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 void
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 parse_error(msg)
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 char *msg;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 fprintf(stderr, "%s line %d: %s\n", parser_filename, parser_lineno,
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 msg);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 exit(1);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 static
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 my_getchar()
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 register int c;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 c = getc(parser_readF);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (c < 0)
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 return(c);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 if (!isascii(c))
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 parse_error("non-ASCII character");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 if (iscntrl(c) && c != '\n' && c != '\t')
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 parse_error("invalid control character");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 return(c);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 static void
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 handle_trad_comment()
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 register int c, flag;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 for (flag = 0; ; ) {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 c = my_getchar();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 if (c < 0)
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 parse_error("/* comment ends in EOF");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 if (c == '\n')
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 parser_lineno++;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 if (c == '/' && flag)
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 return;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 flag = (c == '*');
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 static void
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 handle_line_comment()
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 register int c;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 for (;;) {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 c = my_getchar();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 if (c < 0)
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 parse_error("// comment ends in EOF");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 if (c == '\n') {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 parser_lineno++;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 return;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 static void
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 handle_comment()
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 int c;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 c = my_getchar();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 switch (c) {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 case '*':
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 /* traditional C comment style */
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 handle_trad_comment();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 return;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 case '/':
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 /* new-fangled double slash comment style */
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 handle_line_comment();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 return;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 default:
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 parse_error("character after '/' is not '*' or '/'");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 exit(1);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 static void
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 handle_num_token(first_digit)
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 register int c, n;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 parser_read_number = first_digit - '0';
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 for (n = 1; ; n++) {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 c = my_getchar();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 if (!isdigit(c))
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 break;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 parser_read_number *= 10;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 parser_read_number += c - '0';
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 if (c >= 0) {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 if (isalpha(c) || c == '_')
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 parse_error(
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 "digits followed by letters: neither word nor number");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 ungetc(c, parser_readF);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 if (n > MAXDIGITS)
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 parse_error("number is too long (MAXDIGITS exceeded)");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 static int
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 decode_hex_digit(c)
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 register int c;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 if (isdigit(c))
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 return(c - '0');
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 else if (isupper(c))
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 return(c - 'A' + 10);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 else
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 return(c - 'a' + 10);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 static void
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 handle_hex_token()
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 register int c, n;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 c = my_getchar();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 if (c != 'x' && c != 'X')
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 parse_error("\'0\' not followed by \'x\'");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 parser_read_number = 0;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 for (n = 0; n < 2; n++) {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 c = my_getchar();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 if (!isxdigit(c))
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 parse_error("0x not followed by two hex digits");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 parser_read_number <<= 4;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 parser_read_number += decode_hex_digit(c);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 static void
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 handle_word_token(first_char)
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 register int c;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 register char *cp;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 register int len;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 cp = parser_read_word;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 *cp++ = first_char;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 for (len = 1; ; ) {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 c = my_getchar();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 if (!isalnum(c) && c != '_')
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 break;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 if (len >= MAXWORD)
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 parse_error("text token is too long");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 *cp++ = c;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 len++;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 *cp = '\0';
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 if (c < 0)
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 return;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 ungetc(c, parser_readF);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 get_token()
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 register int c;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 loop: c = my_getchar();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 switch (c) {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 case EOF:
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 return(0);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 case ' ':
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 case '\t':
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 goto loop;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 case '\n':
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 parser_lineno++;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 goto loop;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 case '/':
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 handle_comment();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 goto loop;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 case ',':
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 case ';':
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 case '=':
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 case '[':
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 case ']':
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 case '{':
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 case '}':
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 return(c);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 case '0':
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 handle_hex_token();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 return(HEXBYTE);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 if (isdigit(c)) {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 handle_num_token(c);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 return(NUMBER);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 if (isalpha(c) || c == '_') {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 handle_word_token(c);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 return(WORD);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 fprintf(stderr, "%s line %d: bad character \'%c\'\n", parser_filename,
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 parser_lineno, c);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 exit(1);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 main(argc, argv)
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 char **argv;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 register int t;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 FILE *outF;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 if (argc != 3) {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231 fprintf(stderr, "usage: %s char-array-file bin-output-file\n",
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 argv[0]);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 exit(1);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235 parser_filename = argv[1];
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 parser_readF = fopen(parser_filename, "r");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 if (!parser_readF) {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 perror(parser_filename);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 exit(1);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 parser_lineno = 1;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 t = get_token();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243 if (t != WORD || strcmp(parser_read_word, "const"))
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244 parse_error("expected \"const\" keyword");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245 t = get_token();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 if (t != WORD || strcmp(parser_read_word, "unsigned"))
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 parse_error("expected \"unsigned\" keyword");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248 t = get_token();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
249 if (t != WORD || strcmp(parser_read_word, "char"))
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
250 parse_error("expected \"char\" keyword");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
251 t = get_token();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
252 if (t != WORD)
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
253 parse_error("expected char array name");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
254 t = get_token();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
255 if (t != '[')
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
256 parse_error("expected \'[\'");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
257 t = get_token();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
258 if (t == NUMBER)
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
259 t = get_token();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
260 if (t != ']')
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
261 parse_error("expected \']\'");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
262 t = get_token();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
263 if (t != '=')
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
264 parse_error("expected \'=\'");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265 t = get_token();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266 if (t != '{')
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267 parse_error("expected \'{\'");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268 /* get first hex byte */
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269 t = get_token();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
270 if (t != HEXBYTE)
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
271 parse_error("expected first hex byte");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
272 outF = fopen(argv[2], "w");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
273 if (!outF) {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
274 perror(argv[2]);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
275 exit(1);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
277 putc(parser_read_number, outF);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
278 for (;;) {
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
279 t = get_token();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
280 if (t == '}')
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
281 break;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
282 if (t != ',')
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
283 parse_error("expected comma between bytes");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
284 t = get_token();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285 if (t == '}')
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
286 break;
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
287 if (t != HEXBYTE)
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
288 parse_error("expected next hex byte");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
289 putc(parser_read_number, outF);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
290 }
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
291 fclose(outF);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
292 t = get_token();
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
293 if (t != ';')
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
294 parse_error("expected terminating \';\'");
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
295 /* success! */
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
296 exit(0);
8e816bba2ff7 dspanal: char2bin utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
297 }