7 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 #include <io.h> /* for isatty() on win32 */
38 #include "ascend-grammar.h"
39 #include "ascend-int.h"
40 #include "file_wrappers.h"
43 extern char *ascend_ra_ptr;
44 extern char *ascend_ra_last;
45 #define YY_INPUT(buf,result,max_size) { int c = file_getc(yy_fh); \
46 result = (c==EOF) ? YY_NULL : (buf[0] = c, 1); }
48 #define YY_NEVER_INTERACTIVE 1
53 #define NO_USER "<none>"
56 #define YY_NO_UNISTD_H
73 WDD_CAUSE "Cause an attempt to place call to "
74 WDD_CALLNUM [^\n\r\t ]+
75 WDD_CHUNK "WD_DIALOUT_DISP: chunk"
76 WDD_TYPE "type "[^\n\r\t ]+
105 <INITIAL,sc_gen_byte>{XPFX} {
107 ascendlval.d = ASCEND_PFX_WDS_X;
111 <INITIAL,sc_gen_byte>{RPFX} {
113 ascendlval.d = ASCEND_PFX_WDS_R;
118 char *atcopy = strdup(ascendtext);
119 char colon = input();
120 char after = input();
123 unput(after); unput(colon);
125 if (after != '(' && after != ' ') {
127 if (pseudo_header != NULL) {
128 strncpy(pseudo_header->user, atcopy, ASCEND_MAX_STR_LEN);
129 pseudo_header->user[ASCEND_MAX_STR_LEN - 1] = '\0';
131 } else { /* We have a version 7 file */
133 if (pseudo_header != NULL) {
134 strncpy(pseudo_header->user, NO_USER, ASCEND_MAX_STR_LEN);
136 ascendlval.d = strtol(ascendtext, NULL, 10);
145 ascendlval.d = strtol(ascendtext, NULL, 10);
149 <sc_gen_task>(0x|0X)?{H}+ {
150 BEGIN(sc_gen_time_s);
151 ascendlval.d = strtoul(ascendtext, NULL, 16);
155 <sc_gen_task>\"[A-Za-z0-9_ ]+\" {
159 <sc_gen_time_s>{D}+ {
160 BEGIN(sc_gen_time_u);
161 ascendlval.d = strtol(ascendtext, NULL, 10);
165 <sc_gen_time_u>{D}+ {
166 BEGIN(sc_gen_octets);
167 /* We have the fractional portion of the time. We want it converted
170 ascendlval.d = strtol(ascendtext, NULL, 10);
171 for (scratch = ascendlval.d; scratch > 0; scratch /= 10)
177 <sc_gen_octets>{D}+ {
178 BEGIN(sc_gen_counter);
179 ascendlval.d = strtol(ascendtext, NULL, 10);
183 <sc_gen_counter,sc_gen_byte>"["{H}{4}"]:" {
188 <sc_gen_byte>{H}{2} {
189 ascendlval.b = (guint8)strtol(ascendtext, NULL, 16);
193 <sc_gen_byte>" "{4} {
201 <INITIAL,sc_gen_byte>{WDD_DATE} {
202 BEGIN(sc_wdd_date_d);
206 <sc_wdd_date_d>{D}{2} {
207 BEGIN(sc_wdd_date_m);
208 ascendlval.d = strtol(ascendtext, NULL, 10);
212 <sc_wdd_date_m>{D}{2} {
213 BEGIN(sc_wdd_date_y);
214 ascendlval.d = strtol(ascendtext, NULL, 10);
218 <sc_wdd_date_y>{D}{4} {
220 ascendlval.d = strtol(ascendtext, NULL, 10);
224 <sc_wdd_time>{WDD_TIME} {
225 BEGIN(sc_wdd_time_h);
229 <sc_wdd_time_h>{D}{2} {
230 BEGIN(sc_wdd_time_m);
231 ascendlval.d = strtol(ascendtext, NULL, 10);
235 <sc_wdd_time_m>{D}{2} {
236 BEGIN(sc_wdd_time_s);
237 ascendlval.d = strtol(ascendtext, NULL, 10);
241 <sc_wdd_time_s>{D}{2} {
243 ascendlval.d = strtol(ascendtext, NULL, 10);
247 <sc_wdd_cause>{WDD_CAUSE} {
248 BEGIN(sc_wdd_callnum);
252 <sc_wdd_callnum>{WDD_CALLNUM} {
254 if (pseudo_header != NULL) {
255 strncpy(pseudo_header->call_num, ascendtext, ASCEND_MAX_STR_LEN);
256 pseudo_header->call_num[ASCEND_MAX_STR_LEN - 1] = '\0';
261 <INITIAL,sc_wdd_chunk,sc_gen_byte>{WDD_CHUNK} {
262 BEGIN(sc_wdd_chunknum);
266 <sc_wdd_chunknum>{H}+ {
268 ascendlval.d = strtoul(ascendtext, NULL, 16);
272 <sc_wdd_type>{WDD_TYPE} {
277 (0x|0X)?{H}+ { return HEXNUM; }
279 task:|task|at|time:|octets { return KEYWORD; }
281 <<EOF>> { at_eof++; yyterminate(); }
287 void ascend_init_lexer(FILE_T fh)