1 /* Special state for handling include files */
6 * The contents of this file are subject to the Mozilla Public License
7 * Version 2.0 (the "License"); you may not use this file except in
8 * compliance with the License. You may obtain a copy of the License
9 * at http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS"
12 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
13 * the License for the specific language governing rights and
14 * limitations under the License.
16 * The initial developer of the original code is David A. Hinds
17 * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
18 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
20 * Alternatively, the contents of this file may be used under the
21 * terms of the GNU General Public License version 2 (the "GPL"), in
22 * which case the provisions of the GPL are applicable instead of the
23 * above. If you wish to allow the use of your version of this file
24 * only under the terms of the GPL and not to allow others to use
25 * your version of this file under the MPL, indicate your decision by
26 * deleting the provisions above and replace them with the notice and
27 * other provisions required by the GPL. If you do not delete the
28 * provisions above, a recipient may use your version of this file
29 * under either the MPL or the GPL.
39 #include <pcmcia/cs_types.h>
40 #include <pcmcia/cistpl.h>
45 /* For assembling nice error messages */
48 static int lex_number(char *);
49 static int lex_units(char *, int, int);
50 static int lex_float(char *);
51 static int lex_string(char *);
64 [ ]*[#;].* /* skip */ ;
70 checksum return CHECKSUM;
72 common_jedec return CJEDEC;
73 attr_jedec return AJEDEC;
75 dev_info return DEV_INFO;
76 attr_dev_info return ATTR_DEV_INFO;
77 no_info return NO_INFO;
78 NULL return lex_number("0");
79 ROM return lex_number("1");
80 EPROM return lex_number("3");
81 EEPROM return lex_number("4");
82 FLASH return lex_number("5");
83 SRAM return lex_number("6");
84 DRAM return lex_number("7");
85 fn_specific return lex_number("13");
90 last_index return LAST_INDEX;
94 cftable_entry return CFTABLE;
95 \[default\] return DEFAULT;
98 \[rdybsy\] return RDYBSY;
99 \[mwait\] return MWAIT;
100 \[audio\] return AUDIO;
101 \[readonly\] return READONLY;
102 \[pwrdown\] return PWRDOWN;
110 Istatic return ISTATIC;
117 \[8bit\] return BIT8;
118 \[16bit\] return BIT16;
119 \[lines return LINES;
120 \[range\] return RANGE;
123 \[level\] return LEVEL;
124 \[pulse\] return PULSE;
125 \[shared\] return SHARED;
127 timing return TIMING;
130 reserved return RESERVED;
132 multi_function return lex_number("0");
133 memory_card return lex_number("1");
134 serial_port return lex_number("2");
135 parallel_port return lex_number("3");
136 fixed_disk return lex_number("4");
137 video_adapter return lex_number("5");
138 network_adapter return lex_number("6");
139 aims_card return lex_number("7");
140 scsi_adapter return lex_number("8");
142 {int} return lex_number(yytext);
143 {hex} return lex_number(yytext);
145 {int}b return lex_units(yytext, 1, SIZE);
146 {int}kb return lex_units(yytext, 1024, SIZE);
147 {int}mb return lex_units(yytext, 1024*1024, SIZE);
149 {flt}s return lex_units(yytext, 1000000000, TIME);
150 {flt}ms return lex_units(yytext, 1000000, TIME);
151 {flt}us return lex_units(yytext, 1000, TIME);
152 {flt}ns return lex_units(yytext, 1, TIME);
153 {int}s return lex_units(yytext, 1000000000, TIME);
154 {int}ms return lex_units(yytext, 1000000, TIME);
155 {int}us return lex_units(yytext, 1000, TIME);
156 {int}ns return lex_units(yytext, 1, TIME);
158 {flt}V return lex_units(yytext, 100000, VOLTAGE);
159 {flt}mV return lex_units(yytext, 100, VOLTAGE);
160 {flt}uV return lex_units(yytext, 0.1, VOLTAGE);
161 {int}V return lex_units(yytext, 100000, VOLTAGE);
162 {int}mV return lex_units(yytext, 100, VOLTAGE);
163 {int}uV return lex_units(yytext, 0.1, VOLTAGE);
165 {flt}A return lex_units(yytext, 10000000, CURRENT);
166 {flt}mA return lex_units(yytext, 10000, CURRENT);
167 {flt}uA return lex_units(yytext, 10, CURRENT);
168 {int}A return lex_units(yytext, 10000000, CURRENT);
169 {int}mA return lex_units(yytext, 10000, CURRENT);
170 {int}uA return lex_units(yytext, 10, CURRENT);
172 {flt} return lex_float(yytext);
174 {str} return lex_string(yytext);
181 int yywrap() { return 1; }
184 /*======================================================================
186 Stuff to parse basic data types
188 ======================================================================*/
190 static int lex_number(char *s)
192 yylval.num = strtoul(s, NULL, 0);
196 static int lex_float(char *s)
198 yylval.flt = strtod(s, NULL);
202 static int lex_units(char *s, int scale, int token)
206 yylval.num = scale*f + 0.5;
210 static int lex_string(char *s)
213 yylval.str = malloc(n-1);
214 strncpy(yylval.str, s+1, n-2);
215 yylval.str[n-2] = '\0';
219 /*======================================================================
221 The main parser entry point
223 ======================================================================*/
225 void parse_cis(FILE *f)