4 * $Id: ascend-scanner.l,v 1.21 2001/11/13 23:55:43 gram Exp $
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.
34 #include <io.h> /* for isatty() on win32 */
39 #include "ascend-grammar.h"
40 #include "ascend-int.h"
41 #include "file_wrappers.h"
44 extern char *ascend_ra_ptr;
45 extern char *ascend_ra_last;
46 #define YY_INPUT(buf,result,max_size) { int c = file_getc(yy_fh); \
47 result = (c==EOF) ? YY_NULL : (buf[0] = c, 1); }
49 #define YY_NEVER_INTERACTIVE 1
54 #define NO_USER "<none>"
70 WDD_CAUSE "Cause an attempt to place call to "
71 WDD_CALLNUM [^\n\r\t ]+
72 WDD_CHUNK "WD_DIALOUT_DISP: chunk"
73 WDD_TYPE "type "[^\n\r\t ]+
100 <INITIAL,sc_gen_byte>{XPFX} {
102 ascendlval.d = ASCEND_PFX_WDS_X;
106 <INITIAL,sc_gen_byte>{RPFX} {
108 ascendlval.d = ASCEND_PFX_WDS_R;
113 char *atcopy = strdup(ascendtext);
114 char colon = input();
115 char after = input();
118 unput(after); unput(colon);
122 if (pseudo_header != NULL) {
123 strncpy(pseudo_header->user, atcopy, ASCEND_MAX_STR_LEN);
124 pseudo_header->user[ASCEND_MAX_STR_LEN - 1] = '\0';
126 } else { /* We have a version 7 file */
128 if (pseudo_header != NULL) {
129 strncpy(pseudo_header->user, NO_USER, ASCEND_MAX_STR_LEN);
131 ascendlval.d = strtol(ascendtext, NULL, 10);
140 ascendlval.d = strtol(ascendtext, NULL, 10);
145 BEGIN(sc_gen_time_s);
146 ascendlval.d = strtoul(ascendtext, NULL, 16);
150 <sc_gen_time_s>{D}+ {
151 BEGIN(sc_gen_time_u);
152 ascendlval.d = strtol(ascendtext, NULL, 10);
156 <sc_gen_time_u>{D}+ {
157 BEGIN(sc_gen_octets);
158 /* We have the fractional portion of the time. We want it converted
161 ascendlval.d = strtol(ascendtext, NULL, 10);
162 for (scratch = ascendlval.d; scratch > 0; scratch /= 10)
168 <sc_gen_octets>{D}+ {
169 BEGIN(sc_gen_counter);
170 ascendlval.d = strtol(ascendtext, NULL, 10);
174 <sc_gen_counter,sc_gen_byte>"["{H}{4}"]:" {
179 <sc_gen_byte>{H}{2} {
180 ascendlval.b = strtol(ascendtext, NULL, 16);
184 <INITIAL,sc_gen_byte>{WDD_DATE} {
185 BEGIN(sc_wdd_date_d);
189 <sc_wdd_date_d>{D}{2} {
190 BEGIN(sc_wdd_date_m);
191 ascendlval.d = strtol(ascendtext, NULL, 10);
195 <sc_wdd_date_m>{D}{2} {
196 BEGIN(sc_wdd_date_y);
197 ascendlval.d = strtol(ascendtext, NULL, 10);
201 <sc_wdd_date_y>{D}{4} {
203 ascendlval.d = strtol(ascendtext, NULL, 10);
207 <sc_wdd_time>{WDD_TIME} {
208 BEGIN(sc_wdd_time_h);
212 <sc_wdd_time_h>{D}{2} {
213 BEGIN(sc_wdd_time_m);
214 ascendlval.d = strtol(ascendtext, NULL, 10);
218 <sc_wdd_time_m>{D}{2} {
219 BEGIN(sc_wdd_time_s);
220 ascendlval.d = strtol(ascendtext, NULL, 10);
224 <sc_wdd_time_s>{D}{2} {
226 ascendlval.d = strtol(ascendtext, NULL, 10);
230 <sc_wdd_cause>{WDD_CAUSE} {
231 BEGIN(sc_wdd_callnum);
235 <sc_wdd_callnum>{WDD_CALLNUM} {
237 if (pseudo_header != NULL) {
238 strncpy(pseudo_header->call_num, ascendtext, ASCEND_MAX_STR_LEN);
239 pseudo_header->call_num[ASCEND_MAX_STR_LEN - 1] = '\0';
244 <INITIAL,sc_wdd_chunk,sc_gen_byte>{WDD_CHUNK} {
245 BEGIN(sc_wdd_chunknum);
249 <sc_wdd_chunknum>{H}+ {
251 ascendlval.d = strtoul(ascendtext, NULL, 16);
255 <sc_wdd_type>{WDD_TYPE} {
261 {H}+ { return HEXNUM; }
263 task:|time:|octets { return KEYWORD; }
265 <<EOF>> { at_eof++; yyterminate(); }
271 int ascendwrap() { return 1; }
273 void ascend_init_lexer(FILE_T fh, FILE *nfh)