Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
scan_mdl.l
Go to the documentation of this file.
1 /* -*-c-*- */
2 
3 %{
4 /*
5  * scan_mdl.l - scanner for an IC-CAP MDL data file
6  *
7  * Copyright (C) 2006 Stefan Jahn <stefan@lkcc.org>
8  *
9  * This is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2, or (at your option)
12  * any later version.
13  *
14  * This software 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.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this package; see the file COPYING. If not, write to
21  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  *
24  * $Id$
25  *
26  */
27 
28 #if HAVE_CONFIG_H
29 # include <config.h>
30 #endif
31 
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <ctype.h>
36 
37 #ifdef __MINGW32__
38 #include <io.h>
39 #endif
40 
41 #ifdef HAVE_UNISTD_H
42 #include <unistd.h>
43 #endif
44 
45 #include "check_mdl.h"
46 #include "tokens_mdl.h"
47 
48 #if !HAVE_STRCHR
49 # define strchr index
50 # define strrchr rindex
51 #endif
52 
53 using namespace qucs;
54 
55 %}
56 
57 WS [ \t\n\r]
58 DIGIT [0-9]
59 EXPONENT [Ee][+-]?{DIGIT}+
60 INT [+-]?{DIGIT}+
61 REAL [+-]?{DIGIT}+("."{DIGIT}+)?{EXPONENT}?
62 DECIMAL {DIGIT}+
63 IDENT [a-zA-Z][a-zA-Z0-9_]*
64 DIGITS {DIGIT}+
65 PIDENT {IDENT}("."({IDENT}|{DECIMAL}))*
66 AIDENT {IDENT}("."{IDENT})*"["{DIGITS}","{DIGITS}"]"
67 LINKS "MODEL"|"CIRC"|"PS"|"DUT"|"DPS"|"DAT"|"OUT"|"SWEEP"|"XFORM"|"MACRO"|"TCIRC"|"CONN"|"PLOT"
68 
69 %x VERSION BLKEDIT BLKEDIT1 CIRCUIT CIRCUIT1 PLINK PLIST PMEMBER
70 %x TABDATA TABDATA1
71 
72 %option yylineno noyywrap nounput prefix="mdl_"
73 
74 %%
75 
76 <INITIAL>^"LINK" {
77  BEGIN(PLINK);
78  return LINK;
79 }
80 
81 <PLINK,PLIST,PMEMBER>{LINKS} {
82  mdl_lval.ident = strdup (mdl_text);
83  BEGIN(INITIAL);
84  return t_LINK;
85 }
86 
87 <INITIAL,BLKEDIT>\"[^\"]*\" {
88  mdl_text[strlen (mdl_text) - 1] = '\0';
89  mdl_text[0] = '\0';
90  mdl_lval.ident = strdup (&mdl_text[1]);
91  return String;
92 }
93 
94 <INITIAL>^"View" {
95  return t_VIEW;
96 }
97 
98 <INITIAL>^"TABLE" {
99  return t_TABLE;
100 }
101 
102 <INITIAL>^"TABLE \"ICVIEWDATA\"" {
103  BEGIN(TABDATA);
104  return t_TABLE;
105 }
106 
107 <INITIAL>^"PSTABLE" {
108  return t_PSTABLE;
109 }
110 
111 <INITIAL>^"BLKEDIT" {
112  BEGIN(BLKEDIT);
113  return t_BLKEDIT;
114 }
115 
116 <INITIAL>^"CNTABLE" {
117  return t_CNTABLE;
118 }
119 
120 <INITIAL>^"OPTIMEDIT" {
121  return t_OPTIMEDIT;
122 }
123 
124 <INITIAL>^"HYPTABLE" {
125  return t_HYPTABLE;
126 }
127 
128 <INITIAL>^"element" {
129  return t_ELEMENT;
130 }
131 
132 <INITIAL>^"data" {
133  return t_DATA;
134 }
135 
136 <INITIAL>^"dataset" {
137  return t_DATASET;
138 }
139 
140 <INITIAL>^"datasize" {
141  return t_DATASIZE;
142 }
143 
144 <INITIAL>^"point" {
145  return t_POINT;
146 }
147 
148 <INITIAL>^"member" {
149  BEGIN(PMEMBER);
150  return t_MEMBER;
151 }
152 
153 <INITIAL>^"list" {
154  BEGIN(PLIST);
155  return t_LIST;
156 }
157 
158 <INITIAL>^"PlotOptimizerOpt" {
159  return t_PLOTOPTIMIZEROPT;
160 }
161 
162 <INITIAL>^"PlotOptimizerTraceSet" {
163  return t_PLOTOPTIMIZERTRACESET;
164 }
165 
166 <INITIAL>^"PlotOptimizerTraceRegSet" {
167  return t_PLOTOPTIMIZERTRACEREGSET;
168 }
169 
170 <INITIAL>^"PlotOptimizerTraceNatRegSet" {
171  return t_PLOTOPTIMIZERTRACENATREGSET;
172 }
173 
174 <INITIAL>^"PlotError" {
175  return t_PLOTERROR;
176 }
177 
178 <INITIAL>^"type" {
179  return t_TYPE;
180 }
181 
182 <INITIAL>^"editsize" {
183  return t_EDITSIZE;
184 }
185 
186 <INITIAL>^"plotsize" {
187  return t_PLOTSIZE;
188 }
189 
190 <INITIAL>^"optrange" {
191  return t_OPTRANGE;
192 }
193 
194 <INITIAL>^"param" {
195  return t_PARAM;
196 }
197 
198 <INITIAL>^"range" {
199  return t_RANGE;
200 }
201 
202 <INITIAL>^"term" {
203  return t_TERM;
204 }
205 
206 <INITIAL>^"calset" {
207  return t_CALSET;
208 }
209 
210 <INITIAL>^"caldata" {
211  return t_CALDATA;
212 }
213 
214 <INITIAL>^"applic" {
215  return t_APPLIC;
216 }
217 
218 <INITIAL>^"subapp" {
219  return t_SUBAPP;
220 }
221 
222 <INITIAL>^"connpair" {
223  return t_CONNPAIR;
224 }
225 
226 <INITIAL>^"circuitdeck" {
227  BEGIN(CIRCUIT);
228  return t_CIRCUITDECK;
229 }
230 
231 <INITIAL>{REAL} { /* identify float */
232  mdl_lval.f = strtod (mdl_text, NULL);
233  return Real;
234 }
235 
236 <INITIAL>{IDENT}|{PIDENT}|{AIDENT} {
237  mdl_lval.ident = strdup (mdl_text);
238  return Identifier;
239 }
240 
241 <BLKEDIT>"{" { BEGIN(BLKEDIT1); return '{'; }
242 <CIRCUIT>"{" { BEGIN(CIRCUIT1); return '{'; }
243 <TABDATA>"{" { BEGIN(TABDATA1); return '{'; }
244 
245 <INITIAL>"{" { /* pass the '{' to the parser */ return '{'; }
246 <INITIAL>"}" { /* pass the '{' to the parser */ return '}'; }
247 
248 <*>\r?\n|{WS} { /* skip end of line and spaces */ }
249 
250 <BLKEDIT1,CIRCUIT1,TABDATA1>^"}" { BEGIN(INITIAL); return '}'; }
251 <BLKEDIT1,CIRCUIT1,TABDATA1>. { /* ignore */ }
252 
253 <*>. { /* any other character is invalid */
254  fprintf (stderr,
255  "line %d: syntax error, unrecognized character: `%s'\n",
256  mdl_lineno, mdl_text);
257  return InvalidCharacter;
258 }
259 
260 %%
#define INT(con)
Definition: evaluate.cpp:68
Identifier
Definition: parse_csv.y:87
n
Definition: parse_citi.y:147
r
Definition: parse_mdl.y:515
< INITIAL >< INITIAL >< INITIAL >< INITIAL > return InvalidCharacter
Definition: scan_netlist.l:698
int mdl_lineno
x
Definition: parse_mdl.y:498
t_TABLE String Real
Definition: parse_mdl.y:382
#define TABLE(x)
Definition: bondwire.cpp:65
name prefix
Definition: parse_spice.y:131
#define Z0
Wave impedance in vacuum ( )
Definition: constants.h:53
REAL
Definition: parse_vcd.y:236