aicasm_scan.l (23942) | aicasm_scan.l (26997) |
---|---|
1%{ 2/* 3 * Lexical Analyzer for the Aic7xxx SCSI Host adapter sequencer assembler. 4 * 5 * Copyright (c) 1997 Justin T. Gibbs. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright | 1%{ 2/* 3 * Lexical Analyzer for the Aic7xxx SCSI Host adapter sequencer assembler. 4 * 5 * Copyright (c) 1997 Justin T. Gibbs. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright |
12 * notice immediately at the beginning of the file, without modification, 13 * this list of conditions, and the following disclaimer. | 12 * notice, this list of conditions, and the following disclaimer, 13 * without modification, immediately at the beginning of the file. |
14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * | 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * |
32 * $Id: scan.l,v 1.1 1997/03/16 07:08:17 gibbs Exp $ | 32 * $Id: scan.l,v 1.2 1997/03/16 17:31:59 bde Exp $ |
33 */ 34 35#include <sys/types.h> 36 37#include <limits.h> 38#include <stdio.h> 39#include <string.h> 40#include <sysexits.h> --- 162 unchanged lines hidden (view full) --- 203 } 204 } 205 206 if (newfile == NULL) { 207 perror(file_name); 208 stop("Unable to open input file", EX_SOFTWARE); 209 /* NOTREACHED */ 210 } | 33 */ 34 35#include <sys/types.h> 36 37#include <limits.h> 38#include <stdio.h> 39#include <string.h> 40#include <sysexits.h> --- 162 unchanged lines hidden (view full) --- 203 } 204 } 205 206 if (newfile == NULL) { 207 perror(file_name); 208 stop("Unable to open input file", EX_SOFTWARE); 209 /* NOTREACHED */ 210 } |
211 include = (include_t *)malloc(sizeof(include_t)); 212 if (include == NULL) { 213 stop("Unable to allocate include stack entry", EX_SOFTWARE); 214 /* NOTREACHED */ | 211 212 if (type != SOURCE_FILE) { 213 include = (include_t *)malloc(sizeof(include_t)); 214 if (include == NULL) { 215 stop("Unable to allocate include stack entry", 216 EX_SOFTWARE); 217 /* NOTREACHED */ 218 } 219 include->buffer = YY_CURRENT_BUFFER; 220 include->lineno = yylineno; 221 include->filename = yyfilename; 222 SLIST_INSERT_HEAD(&include_stack, include, links); |
215 } | 223 } |
216 include->buffer = YY_CURRENT_BUFFER; 217 include->lineno = yylineno; 218 include->filename = yyfilename; 219 SLIST_INSERT_HEAD(&include_stack, include, links); | |
220 yy_switch_to_buffer(yy_create_buffer(newfile, YY_BUF_SIZE)); 221 yylineno = 1; 222 yyfilename = strdup(file_name); 223} 224 225int 226yywrap() 227{ 228 include_t *include; 229 230 yy_delete_buffer(YY_CURRENT_BUFFER); 231 (void)fclose(yyin); 232 if (yyfilename != NULL) 233 free(yyfilename); | 224 yy_switch_to_buffer(yy_create_buffer(newfile, YY_BUF_SIZE)); 225 yylineno = 1; 226 yyfilename = strdup(file_name); 227} 228 229int 230yywrap() 231{ 232 include_t *include; 233 234 yy_delete_buffer(YY_CURRENT_BUFFER); 235 (void)fclose(yyin); 236 if (yyfilename != NULL) 237 free(yyfilename); |
238 yyfilename = NULL; |
|
234 include = include_stack.slh_first; 235 if (include != NULL) { 236 yy_switch_to_buffer(include->buffer); 237 yylineno = include->lineno; 238 yyfilename = include->filename; 239 SLIST_REMOVE_HEAD(&include_stack, links); 240 free(include); 241 return (0); 242 } 243 return (1); 244} | 239 include = include_stack.slh_first; 240 if (include != NULL) { 241 yy_switch_to_buffer(include->buffer); 242 yylineno = include->lineno; 243 yyfilename = include->filename; 244 SLIST_REMOVE_HEAD(&include_stack, links); 245 free(include); 246 return (0); 247 } 248 return (1); 249} |