3 * Sub-Lexical Analyzer for macro invokation in
4 * the Aic7xxx SCSI Host adapter sequencer assembler.
6 * Copyright (c) 2001 Adaptec Inc.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions, and the following disclaimer,
14 * without modification.
15 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
16 * substantially similar to the "NO WARRANTY" disclaimer below
17 * ("Disclaimer") and any redistribution must be conditioned upon
18 * including a substantially similar Disclaimer requirement for further
19 * binary redistribution.
20 * 3. Neither the names of the above-listed copyright holders nor the names
21 * of any contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
24 * Alternatively, this software may be distributed under the terms of the
25 * GNU General Public License ("GPL") version 2 as published by the Free
26 * Software Foundation.
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
38 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGES.
41 * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_scan.l#8 $
46 #include <sys/types.h>
57 #include <sys/queue.h>
61 #include "aicasm_symbol.h"
62 #include "aicasm_macro_gram.h"
64 #define MAX_STR_CONST 4096
65 static char string_buf[MAX_STR_CONST];
66 static char *string_buf_ptr;
67 static int parren_count;
72 WORD [A-Za-z_][-A-Za-z_0-9]*
86 if (parren_count == 1) {
87 string_buf_ptr = string_buf;
90 *string_buf_ptr++ = '(';
93 if (parren_count == 1) {
94 if (string_buf_ptr != string_buf) {
96 * Return an argument and
97 * rescan this parren so we
98 * can return it as well.
100 *string_buf_ptr = '\0';
101 mmlval.str = string_buf;
102 string_buf_ptr = string_buf;
110 *string_buf_ptr++ = ')';
117 *string_buf_ptr++ = *yptr++;
120 if (string_buf_ptr != string_buf) {
122 * Return an argument and
123 * rescan this comma so we
124 * can return it as well.
126 *string_buf_ptr = '\0';
127 mmlval.str = string_buf;
128 string_buf_ptr = string_buf;
135 /* May be a symbol or a macro invocation. */
136 mmlval.sym = symtable_get(mmtext);
137 if (mmlval.sym->type != MACRO) {
138 stop("Expecting Macro Name",
147 snprintf(buf, sizeof(buf), "Invalid character "
149 stop(buf, EX_DATAERR);
156 stop("EOF encountered in macro call", EX_DATAERR);