Qucs-core  0.0.19
scan_spice.l
Go to the documentation of this file.
00001 /* -*-c-*- */
00002 
00003 %{
00004 /*
00005  * scan_spice.l - scanner for a Spice netlist
00006  *
00007  * Copyright (C) 2004-2009 Stefan Jahn <stefan@lkcc.org>
00008  *
00009  * This is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2, or (at your option)
00012  * any later version.
00013  *
00014  * This software is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this package; see the file COPYING.  If not, write to
00021  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
00022  * Boston, MA 02110-1301, USA.
00023  *
00024  * $Id$
00025  *
00026  */
00027 
00028 #if defined(__clang__)
00029 #pragma clang diagnostic push
00030 #pragma clang diagnostic ignored "-Wdeprecated-register"
00031 #endif
00032 
00033 #if HAVE_CONFIG_H
00034 # include <config.h>
00035 #endif
00036 
00037 #include <stdio.h>
00038 #include <stdlib.h>
00039 #include <string.h>
00040 #include <ctype.h>
00041 
00042 #ifdef __MINGW32__
00043 #include <io.h>
00044 #endif
00045 
00046 #ifdef HAVE_UNISTD_H
00047 #include <unistd.h>
00048 #endif
00049 
00050 #include "check_spice.h"
00051 #include "tokens_spice.h"
00052 
00053 #if !HAVE_STRCHR
00054 # define strchr  index
00055 # define strrchr rindex
00056 #endif
00057 
00058 /* fixing invalid identifiers */
00059 static void spice_fix_identifier (char * ident) {
00060   char * p;
00061   for (p = ident; *p != '\0'; p++)
00062     switch (*p) {
00063     case '+': *p = 'P'; break;
00064     case '-': *p = 'N'; break;
00065     case '/': *p = '_'; break;
00066     }
00067 }
00068 
00069 %}
00070 
00071 WS       [ \t\n\r]
00072 TITLE    [* \t0-9A-Za-z][A-Za-z0-9\- \t;#:=()/\.,*\\]*\r*\n
00073 SPACE    [ \t]
00074 NAME     [A-Z][A-Z0-9]*
00075 IDENT    [A-Za-z_][A-Za-z0-9_\-/]*
00076 IDENT2   [A-Za-z0-9_][A-Za-z0-9_\-/]*
00077 FILE     [/A-Za-z0-9_][/\\:A-Za-z0-9_\.]*
00078 DIGIT    [0-9]
00079 EXPONENT [Ee][+-]?{DIGIT}+
00080 INT      [+-]?{DIGIT}+
00081 FLOAT1   [+-]?{DIGIT}+{EXPONENT}
00082 FLOAT2   [+-]?{DIGIT}*"."{DIGIT}+({EXPONENT})?
00083 FLOAT3   [+-]?{DIGIT}+"."
00084 NUMBER   ({INT}|{FLOAT1}|{FLOAT2}|{FLOAT3}){SFX}?{UNIT}?
00085 SFX      ([tT]|[gG]|[mM]|[kK]|[uU]|[nN]|[pP]|[fF]|[mM][iI][lL]|[mM][eE][gG])
00086 UNIT     ([sS]|[vV]|[aA]|[oO][hH][mM]|[mM][hH][oO]|[fF]|[hH])
00087 NODE     ([A-Za-z0-9_#\+-]+|[\+]|[-])
00088 EOL      \r*\n
00089 CSFX     [A-Za-z0-9_]*
00090 
00091      /* Source functions */
00092 FUN1     ([dD][eE][cC]|[lL][iI][nN]|[oO][cC][tT]|[dD][cC]|[aA][cC])
00093 FUN2     ([sS][iI][nN]|[pP][uU][lL][sS][eE]|[pP][wW][lL]|[eE][xX][pP])
00094 FUN3     ([dD][iI][sS][tT][oO][fF][12])
00095 FUNCTION ({FUN1}|{FUN2}|{FUN3})
00096 
00097      /* Device Models */
00098 MODEL1   ([rR]|[cC]|[sS][wW]|[cC][sS][wW]|[uU][rR][cC]|[lL][tT][rR][aA])
00099 MODEL2   ([dD]|[nN][pP][nN]|[pP][nN][pP]|[nN][jJ][fF]|[pP][jJ][fF])
00100 MODEL3   ([nN][mM][oO][sS]|[pP][mM][oO][sS]|[nN][mM][fF]|[pP][mM][fF])
00101 MODEL4   ([rR][eE][sS]|[vV][sS][wW][iI][tT][cC][hH])
00102 MODEL    ({MODEL1}|{MODEL2}|{MODEL3}|{MODEL4})
00103 
00104      /* Voltage derivatives */
00105 VFUN     ([vV]|[vV][rR]|[vV][iI]|[vV][mM]|[vV][pP]|[vV][dD][bB])
00106 
00107      /* Options specials */
00108 OPT1     ([aA][cC][cC][tT]|[lL][iI][sS][tT]|[nN][oO][mM][oO][dD])
00109 OPT2     ([nN][oO][pP][aA][gG][eE]|[nN][oO][dD][eE]|[oO][pP][tT][sS])
00110 OPT3     ([tT][rR][yY][tT][oO][cC][oO][mM][pP][aA][cC][tT])
00111 OPT4     ([kK][eE][eE][pP][oO][pP][iI][nN][fF][oO]|[bB][aA][dD][mM][oO][sS]3)
00112 OPT5     ([pP][oO][sS][tT]|[tT][rR][aA][nN][sS])
00113 OPTS     ({OPT1}|{OPT2}|{OPT3}|{OPT4}|{OPT5})
00114 
00115      /* Model specific properties */
00116 MOD1     ([nN][oO][cC][oO][nN][tT][rR][oO][lL])
00117 MOD2     ([sS][tT][eT][pP][lL][iI][mM][iI][tT])
00118 MOD3     ([qQ][uU][aA][dD][iI][nN][tT][eE][rR][pP])
00119 MOD4     ([nN][oO][pP][rR][iI][nN][tT])
00120 MODS     ({MOD1}|{MOD2}|{MOD3}|{MOD4})
00121 
00122      /* Plot/Print specific identifiers */
00123 SIM1     ([aA][cC]|[dD][cC]|[tT][rR][aA][nN]|[nN][oO][iI][sS][eE])
00124 SIM2     ([dD][iI][sS][tT][oO]|[pP][zZ])
00125 SIMS     ({SIM1}|{SIM2})
00126 
00127      /* MOS specific device properties */
00128 MOS1     ([lL]|[wW]|[aA][dDsS]|[pP][dDsS]|[nN][rR][dDsS]|[dD][eE][bB][uU][gG])
00129 MOS2     ([rR][gG][eE][oO][mM][oO][dD]|[tT][sSdD]|[mM])
00130 MOS      ({MOS1}|{MOS2})
00131 
00132      /* analog behavioural */
00133 TABLE    [tT][aA][bB][lL][eE]
00134 VALUE    [vV][aA][lL][uU][eE]
00135 FREQ     [fF][rR][eE][qQ]
00136 LAPLACE  [lL][aA][pP][lL][aA][cC][eE]
00137 POLY     [pP][oO][lL][yY]
00138 
00139 %x COMMENT IVREF DEVPROP LREF MODREF1 MODREF2 IGNORE FUNREF FILEREF VREF
00140 %x STARTUP VSINGLE ISWITCH VSWITCH CONTROL GEVALS INLINE SUBCKT TLPROP RLCPROP
00141 %x FHVALS
00142 %option yylineno noyywrap nounput noinput prefix="spice_"
00143 
00144 %%
00145 
00146 <INITIAL>^{TITLE} { /* detect initial title lines */
00147     spice_lval.str = strdup (spice_text);
00148     BEGIN(STARTUP);
00149     return TitleLine;
00150 }
00151 
00152 <STARTUP,INITIAL>^{SPACE}+ { /* Spice3 ignores any lines starting spaces */
00153     BEGIN(COMMENT);
00154   }
00155 
00156 <STARTUP,INITIAL>^"*" { /* ignored region begins here */
00157     BEGIN(COMMENT);
00158   }
00159 
00160 <STARTUP,INITIAL,IVREF,DEVPROP,LREF,MODREF1,MODREF2,IGNORE,FUNREF,
00161  FILEREF,VREF,VSINGLE,ISWITCH,VSWITCH,CONTROL,GEVALS,INLINE,SUBCKT,
00162  TLPROP,RLCPROP,FHVALS>[\*\$] {
00163     /* ignored inline region begins here (3f5, 2g6 and hspice) */
00164     BEGIN(INLINE);
00165   }
00166 
00167 <STARTUP,INITIAL>^"."[cC][oO][nN][tT][rR][oO][lL] {
00168     /* control (interactive) region start */
00169     BEGIN(CONTROL);
00170 }
00171 
00172 <CONTROL>.     { /* skip any character in here */ }
00173 <CONTROL>{EOL} { /* skip any character in here */ }
00174 
00175 <CONTROL>^"."[eE][nN][dD][cC] {
00176     BEGIN(STARTUP);
00177 }
00178 
00179 <STARTUP,INITIAL>\x1a {
00180   /* skip EOF character */
00181 }
00182 
00183 <STARTUP,INITIAL>^"."[sS][uU][bB][cC][kK][tT] {
00184     /* subcircuit definition start */
00185     spice_lval.ident = strdup (&spice_text[1]);
00186     BEGIN(SUBCKT);
00187     return SUBCKT_Action;
00188 }
00189 
00190 <STARTUP>^"."[eE][nN][dD][sS] { /* subcircuit definition end */
00191     BEGIN(SUBCKT);
00192     return ENDS_Action;
00193 }
00194 
00195 <STARTUP,INITIAL>^[rRlLcC]{CSFX} { /* R, L and C instances */
00196     spice_lval.ident = strdup (spice_text);
00197     BEGIN(RLCPROP);
00198     return RLC_Device;
00199 }
00200 
00201 <STARTUP,INITIAL>^[kK]{CSFX} { /* Mutual inductor instances */
00202     spice_lval.ident = strdup (spice_text);
00203     BEGIN(LREF);
00204     return K_Device;
00205 }
00206 
00207 <STARTUP,INITIAL>^[iIvV]{CSFX} {
00208     /* voltage and current source instances */
00209     spice_lval.ident = strdup (spice_text);
00210     BEGIN(FUNREF);
00211     return IV_Source;
00212 }
00213 
00214 <STARTUP,INITIAL>^[gGeE]{CSFX} {
00215     /* voltage controlled source instances */
00216     spice_lval.ident = strdup (spice_text);
00217     BEGIN(GEVALS);
00218     return GE_Source;
00219 }
00220 
00221 <STARTUP,INITIAL>^[fFhH]{CSFX} {
00222     /* current controlled source instances */
00223     spice_lval.ident = strdup (spice_text);
00224     BEGIN(FHVALS);
00225     return FH_Source;
00226 }
00227 
00228 <STARTUP,INITIAL>^[bB]{CSFX} {
00229     /* non-linear dependent source instances */
00230     spice_lval.ident = strdup (spice_text);
00231     BEGIN(IGNORE);
00232     return B_Source;
00233 }
00234 
00235 <STARTUP,INITIAL>^[xX]{CSFX} { /* subcircuit instances */
00236     spice_lval.ident = strdup (spice_text);
00237     BEGIN(STARTUP);
00238     return X_Device;
00239 }
00240 
00241 <STARTUP,INITIAL>^[oO]{CSFX} { /* lossy transline */
00242     spice_lval.ident = strdup (spice_text);
00243     BEGIN(STARTUP);
00244     return O_Device;
00245 }
00246 
00247 <STARTUP,INITIAL>^[tT]{CSFX} { /* lossless transline */
00248     spice_lval.ident = strdup (spice_text);
00249     BEGIN(TLPROP);
00250     return T_Device;
00251 }
00252 
00253 <STARTUP,INITIAL>^[uU]{CSFX} { /* distributed lossy transline */
00254     spice_lval.ident = strdup (spice_text);
00255     BEGIN(STARTUP);
00256     return U_Device;
00257 }
00258 
00259 <STARTUP,INITIAL>^[sS]{CSFX} { /* voltage controlled switch */
00260     spice_lval.ident = strdup (spice_text);
00261     BEGIN(VSWITCH);
00262     return S_Device;
00263 }
00264 
00265 <STARTUP,INITIAL>^[wW]{CSFX} { /* current controlled switch */
00266     spice_lval.ident = strdup (spice_text);
00267     BEGIN(ISWITCH);
00268     return W_Device;
00269 }
00270 
00271 <STARTUP,INITIAL>^"."[mM][oO][dD][eE][lL] { /* device Model definitions */
00272     spice_lval.ident = strdup (&spice_text[1]);
00273     BEGIN(MODREF1);
00274     return MODEL_Action;
00275 }
00276 
00277 <STARTUP,INITIAL>^"."[tT][rR][aA][nN] { /* transient analysis */
00278     spice_lval.ident = strdup (&spice_text[1]);
00279     BEGIN(STARTUP);
00280     return TRAN_Action;
00281 }
00282 
00283 <STARTUP,INITIAL>^"."[pP][lL][oO][tT] { /* plotting action */
00284     spice_lval.ident = strdup (&spice_text[1]);
00285     BEGIN(IVREF);
00286     return PLOT_Action;
00287 }
00288 
00289 <STARTUP,INITIAL>^"."[aA][cC] { /* AC analysis */
00290     spice_lval.ident = strdup (&spice_text[1]);
00291     BEGIN(FUNREF);
00292     return AC_Action;
00293 }
00294 
00295 <STARTUP,INITIAL>^"."[dD][iI][sS][tT][oO] { /* distortion analysis */
00296     spice_lval.ident = strdup (&spice_text[1]);
00297     BEGIN(FUNREF);
00298     return DISTO_Action;
00299 }
00300 
00301 <STARTUP,INITIAL>^"."[nN][oO][dD][eE][sS][eE][tT] { /* nodeset functionality */
00302     spice_lval.ident = strdup (&spice_text[1]);
00303     BEGIN(VSINGLE);
00304     return NODESET_Action;
00305 }
00306 
00307 <STARTUP,INITIAL>^"."[iI][cC] { /* nodeset functionality */
00308     spice_lval.ident = strdup (&spice_text[1]);
00309     BEGIN(VSINGLE);
00310     return NODESET_Action;
00311 }
00312 
00313 <STARTUP,INITIAL>^"."[dD][cC] { /* DC analysis */
00314     spice_lval.ident = strdup (&spice_text[1]);
00315     BEGIN(IVREF);
00316     return DC_Action;
00317 }
00318 
00319 <STARTUP,INITIAL>^"."[oO][pP] { /* operating point analysis */
00320     spice_lval.ident = strdup (&spice_text[1]);
00321     BEGIN(STARTUP);
00322     return OP_Action;
00323 }
00324 
00325 <STARTUP,INITIAL>^"."[tT][eE][mM][pP] { /* temperature analysis (Spice 2g6) */
00326     spice_lval.ident = strdup (&spice_text[1]);
00327     BEGIN(STARTUP);
00328     return TEMP_Action;
00329 }
00330 
00331 <STARTUP,INITIAL>^"."[pP][rR][iI][nN][tT] { /* printing action */
00332     spice_lval.ident = strdup (&spice_text[1]);
00333     BEGIN(VREF);
00334     return PRINT_Action;
00335 }
00336 
00337 <STARTUP,INITIAL>^"."[oO][pP][tT][iI][oO][nN][sS] { /* general options */
00338     spice_lval.ident = strdup (&spice_text[1]);
00339     BEGIN(STARTUP);
00340     return OPTIONS_Action;
00341 }
00342 
00343 <STARTUP,INITIAL>^"."[oO][pP][tT] { /* general options (abbrev.) */
00344     spice_lval.ident = strdup (&spice_text[1]);
00345     BEGIN(STARTUP);
00346     return OPTIONS_Action;
00347 }
00348 
00349 <STARTUP,INITIAL>^"."[oO][pP][tT][iI][oO][nN] { /* general options (abbrev.) */
00350     spice_lval.ident = strdup (&spice_text[1]);
00351     BEGIN(STARTUP);
00352     return OPTIONS_Action;
00353 }
00354 
00355 <STARTUP,INITIAL>^"."[wW][iI][dD][tT][hH] { /* special width of ??? */
00356     spice_lval.ident = strdup (&spice_text[1]);
00357     BEGIN(STARTUP);
00358     return WIDTH_Action;
00359 }
00360 
00361 <STARTUP,INITIAL>^"."[nN][oO][iI][sS][eE] { /* noise analysis */
00362     spice_lval.ident = strdup (&spice_text[1]);
00363     BEGIN(IVREF);
00364     return NOISE_Action;
00365 }
00366 
00367 <STARTUP,INITIAL>^"."[iI][nN][cC][lL][uU][dD][eE] { /* file include */
00368     spice_lval.ident = strdup (&spice_text[1]);
00369     BEGIN(FILEREF);
00370     return INCLUDE_Action;
00371 }
00372 
00373 <STARTUP,INITIAL>^"."[pP][zZ] { /* pole-zero analysis */
00374     spice_lval.ident = strdup (&spice_text[1]);
00375     BEGIN(STARTUP);
00376     return PZ_Action;
00377 }
00378 
00379 <STARTUP,INITIAL>^"."[sS][aA][vV][eE] { /* save line */
00380     spice_lval.ident = strdup (&spice_text[1]);
00381     BEGIN(IGNORE);
00382     return SAVE_Action;
00383 }
00384 
00385 <STARTUP,INITIAL>^"."[sS][eE][nN][sS] { /* sensitivity analysis */
00386     spice_lval.ident = strdup (&spice_text[1]);
00387     BEGIN(IGNORE);
00388     return SENS_Action;
00389 }
00390 
00391 <STARTUP,INITIAL>^"."[tT][fF] { /* transfer function analysis */
00392     spice_lval.ident = strdup (&spice_text[1]);
00393     BEGIN(IGNORE);
00394     return TF_Action;
00395 }
00396 
00397 <STARTUP,INITIAL>^"."[fF][oO][uU][rR] { /* fourier analysis */
00398     spice_lval.ident = strdup (&spice_text[1]);
00399     BEGIN(IGNORE);
00400     return FOUR_Action;
00401 }
00402 
00403 <STARTUP>[cC][uU][rR]|[vV][oO][lL] { /* pole-zero specials */
00404     spice_lval.ident = strdup (spice_text);
00405     return CurVol;
00406 }
00407 
00408 <STARTUP>[pP][oO][lL]|[zZ][eE][rR]|[pP][zZ] { /* other pole-zero specials */
00409     spice_lval.ident = strdup (spice_text);
00410     return PoleZero;
00411 }
00412 
00413 <FILEREF>{FILE} { /* a file reference */
00414     spice_lval.ident = strdup (spice_text);
00415     return File;
00416 }
00417 
00418 <IVREF,VREF>[aA][lL][lL] { /* a print special */
00419     spice_lval.ident = strdup (spice_text);
00420     return ALL_Special;
00421 }
00422 
00423 <RLCPROP>[tT][cC] { /* a TC special */
00424     spice_lval.ident = strdup (spice_text);
00425     return TC_Special;
00426 }
00427 
00428 <DEVPROP,VSWITCH,ISWITCH>[oO][fF][fF] { /* a device special */
00429     spice_lval.ident = strdup (spice_text);
00430     return OFF_Special;
00431 }
00432 
00433 <VSWITCH,ISWITCH>[oO][nN] { /* a device special */
00434     spice_lval.ident = strdup (spice_text);
00435     return ON_Special;
00436 }
00437 
00438 <TLPROP,DEVPROP>[iI][cC] { /* another device special */
00439     spice_lval.ident = strdup (spice_text);
00440     return IC_Special;
00441 }
00442 
00443 <DEVPROP>[tT][eE][mM][pP] { /* another device special */
00444     spice_lval.ident = strdup (spice_text);
00445     return TEMP_Special;
00446 }
00447 
00448 <DEVPROP>{MOS} { /* another device special */
00449     spice_lval.ident = strdup (spice_text);
00450     return MOS_Special;
00451 }
00452 
00453 <IVREF,VREF>{VFUN} { /* voltage derivatives (plotting and printing) */
00454     spice_lval.ident = strdup (spice_text);
00455     return VoltFunc;
00456 }
00457 
00458 <VSINGLE>[vV] { /* voltage derivatives (plotting and printing) */
00459     spice_lval.ident = strdup (spice_text);
00460     return VoltFunc;
00461 }
00462 
00463 <STARTUP>{OPTS} { /* option specials */
00464     spice_lval.ident = strdup (spice_text);
00465     return Options;
00466 }
00467 
00468 <STARTUP>{MODS} { /* Model specials */
00469     spice_lval.ident = strdup (spice_text);
00470     return ModelProps;
00471 }
00472 
00473 <IVREF,VREF,ISWITCH,FHVALS>[vV]{CSFX} { /* voltage source references */
00474     spice_lval.ident = strdup (spice_text);
00475     return V_Source;
00476 }
00477 
00478 <IVREF>[iI]{CSFX} { /* current source references */
00479     spice_lval.ident = strdup (spice_text);
00480     return I_Source;
00481 }
00482 
00483 <IVREF,VREF>[iI] { /* I function (plotting and printing) */
00484     spice_lval.ident = strdup (spice_text);
00485     return CurrFunc;
00486 }
00487 
00488 <IVREF,VREF>{SIMS} { /* print/plot specific identifiers */
00489     spice_lval.ident = strdup (spice_text);
00490     return SIM_Type;
00491 }
00492 
00493 <LREF>[lL]{CSFX} { /* inductor references */
00494     spice_lval.ident = strdup (spice_text);
00495     return L_Device;
00496 }
00497 
00498 <STARTUP>^[dD]{CSFX} { /* diode instances */
00499     spice_lval.ident = strdup (spice_text);
00500     BEGIN(DEVPROP);
00501     return Diode_Device;
00502 }
00503 
00504 <STARTUP>^[qQ]{CSFX} { /* BJT instances */
00505     spice_lval.ident = strdup (spice_text);
00506     BEGIN(DEVPROP);
00507     return Bipolar_Device;
00508 }
00509 
00510 <STARTUP>^[jJ]{CSFX} { /* JFET instances */
00511     spice_lval.ident = strdup (spice_text);
00512     BEGIN(DEVPROP);
00513     return JFET_Device;
00514 }
00515 
00516 <STARTUP>^[mM]{CSFX} { /* MOSFET instances */
00517     spice_lval.ident = strdup (spice_text);
00518     BEGIN(DEVPROP);
00519     return MOSFET_Device;
00520 }
00521 
00522 <STARTUP>^[zZ]{CSFX} { /* MESFET instances */
00523     spice_lval.ident = strdup (spice_text);
00524     BEGIN(DEVPROP);
00525     return MESFET_Device;
00526 }
00527 
00528 <STARTUP,INITIAL>"."[Ee][Nn][Dd]{SPACE}*{EOL}* { /* identify end of netlist */
00529     return End;
00530 }
00531 
00532 <STARTUP,IVREF,DEVPROP,LREF,FUNREF,VREF,VSINGLE,ISWITCH,VSWITCH,
00533  GEVALS,TLPROP,RLCPROP,FHVALS>{DIGIT}+ {
00534     /* identify node (containing digits) */
00535     spice_lval.ident = strdup (spice_text);
00536     return Digits;
00537 }
00538 
00539 <STARTUP,IVREF,DEVPROP,LREF,FUNREF,VREF,VSINGLE,GEVALS,TLPROP,
00540  RLCPROP,FHVALS>{NUMBER} {
00541     /* identify float (any kind) */
00542     spice_lval.ident = strdup (spice_text);
00543     return Floats;
00544 }
00545 
00546 <GEVALS,FHVALS,RLCPROP>{POLY} {
00547     /* identify analog behaviour */
00548     spice_lval.ident = strdup (spice_text);
00549     return Behave;
00550 }
00551 
00552 <GEVALS,FHVALS>{TABLE}|{VALUE}|{FREQ}|{LAPLACE} {
00553     /* identify analog behaviour */
00554     spice_lval.ident = strdup (spice_text);
00555     BEGIN(IGNORE);
00556     return Behave;
00557 }
00558 
00559 <IVREF,FUNREF>{FUNCTION} { /* function specials (e.g. in sources) */
00560     spice_lval.ident = strdup (spice_text);
00561     return Function;
00562 }
00563 
00564 <MODREF2>{MODEL} { /* Model specification specials */
00565     spice_lval.ident = strdup (spice_text);
00566     BEGIN(STARTUP);
00567     return MODEL_Spec;
00568 }
00569 
00570 <STARTUP,DEVPROP,MODREF2,ISWITCH,VSWITCH,
00571  TLPROP,RLCPROP>{IDENT} { /* arbitrary identifier */
00572     spice_lval.ident = strdup (spice_text);
00573     spice_fix_identifier (spice_lval.ident);
00574     return Identifier;
00575 }
00576 
00577 <SUBCKT>{IDENT2} { /* arbitrary identifier */
00578     spice_lval.ident = strdup (spice_text);
00579     spice_fix_identifier (spice_lval.ident);
00580     BEGIN(STARTUP);
00581     return Identifier;
00582 }
00583 
00584 <MODREF1>{IDENT2} { /* arbitrary identifier */
00585     spice_lval.ident = strdup (spice_text);
00586     spice_fix_identifier (spice_lval.ident);
00587     BEGIN(MODREF2);
00588     return Identifier;
00589 }
00590 
00591 <IVREF,VREF>[vV]{CSFX}#[bB][rR][aA][nN][cC][hH] {
00592     /* I function (plotting and printing) */
00593     spice_lval.ident = strdup (spice_text);
00594     return BranchFunc;
00595 }
00596 
00597 <IVREF,VREF>@[a-zA-Z]{CSFX}\[[a-zA-Z]{CSFX}\] {
00598     /* operating point (plotting and printing) */
00599     spice_lval.ident = strdup (spice_text);
00600     return OpFunc;
00601 }
00602 
00603 <STARTUP,IVREF,DEVPROP,FUNREF,VREF,VSINGLE,ISWITCH,VSWITCH,GEVALS,
00604  TLPROP,RLCPROP,FHVALS>{NODE} {
00605     /* identify node */
00606     spice_lval.ident = strdup (spice_text);
00607     return Nodes;
00608 }
00609 
00610 <STARTUP,IVREF,DEVPROP,LREF,IGNORE,FUNREF,FILEREF,VREF,VSINGLE,
00611  ISWITCH,VSWITCH,GEVALS,SUBCKT,TLPROP,RLCPROP,FHVALS>{EOL} {
00612     /* detect end of line */
00613     BEGIN(STARTUP);
00614     return Eol;
00615 }
00616 
00617 <*>{SPACE}|{EOL}+\+|[()=,] {
00618     /* skip spaces, '=', '(', ')', ',' and the leading '+' */
00619 }
00620 
00621 <COMMENT>{EOL} { BEGIN(STARTUP); /* skipping ends here */ }
00622 <COMMENT>. { /* skip any character in here */ }
00623 <IGNORE>.  { /* skip any character in here */ }
00624 
00625 <INLINE>{EOL} { BEGIN(STARTUP); return Eol; /* skipping ends here */ }
00626 <INLINE>.  { /* skip any character in here */ }
00627 <*>.       { /* skip any character in here */ }
00628 
00629 <*>. { /* any other character is invalid */
00630     fprintf (stderr,
00631              "line %d: syntax error, unrecognized character: `%s'\n",
00632              spice_lineno, spice_text);
00633     return InvalidCharacter;
00634 }
00635 
00636 %%