Qucs-core
0.0.19
|
00001 /* -*-c-*- */ 00002 00003 %{ 00004 /* 00005 * scan_mdl.l - scanner for an IC-CAP MDL data file 00006 * 00007 * Copyright (C) 2006 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_mdl.h" 00051 #include "tokens_mdl.h" 00052 00053 #if !HAVE_STRCHR 00054 # define strchr index 00055 # define strrchr rindex 00056 #endif 00057 00058 using namespace qucs; 00059 00060 %} 00061 00062 WS [ \t\n\r] 00063 DIGIT [0-9] 00064 EXPONENT [Ee][+-]?{DIGIT}+ 00065 INT [+-]?{DIGIT}+ 00066 REAL [+-]?{DIGIT}+("."{DIGIT}+)?{EXPONENT}? 00067 DECIMAL {DIGIT}+ 00068 IDENT [a-zA-Z][a-zA-Z0-9_]* 00069 DIGITS {DIGIT}+ 00070 PIDENT {IDENT}("."({IDENT}|{DECIMAL}))* 00071 AIDENT {IDENT}("."{IDENT})*"["{DIGITS}","{DIGITS}"]" 00072 LINKS "MODEL"|"CIRC"|"PS"|"DUT"|"DPS"|"DAT"|"OUT"|"SWEEP"|"XFORM"|"MACRO"|"TCIRC"|"CONN"|"PLOT" 00073 00074 %x VERSION BLKEDIT BLKEDIT1 CIRCUIT CIRCUIT1 PLINK PLIST PMEMBER 00075 %x TABDATA TABDATA1 00076 00077 %option yylineno noyywrap nounput noinput prefix="mdl_" 00078 00079 %% 00080 00081 <INITIAL>^"LINK" { 00082 BEGIN(PLINK); 00083 return LINK; 00084 } 00085 00086 <PLINK,PLIST,PMEMBER>{LINKS} { 00087 mdl_lval.ident = strdup (mdl_text); 00088 BEGIN(INITIAL); 00089 return t_LINK; 00090 } 00091 00092 <INITIAL,BLKEDIT>\"[^\"]*\" { 00093 mdl_text[strlen (mdl_text) - 1] = '\0'; 00094 mdl_text[0] = '\0'; 00095 mdl_lval.ident = strdup (&mdl_text[1]); 00096 return String; 00097 } 00098 00099 <INITIAL>^"View" { 00100 return t_VIEW; 00101 } 00102 00103 <INITIAL>^"TABLE" { 00104 return t_TABLE; 00105 } 00106 00107 <INITIAL>^"TABLE \"ICVIEWDATA\"" { 00108 BEGIN(TABDATA); 00109 return t_TABLE; 00110 } 00111 00112 <INITIAL>^"PSTABLE" { 00113 return t_PSTABLE; 00114 } 00115 00116 <INITIAL>^"BLKEDIT" { 00117 BEGIN(BLKEDIT); 00118 return t_BLKEDIT; 00119 } 00120 00121 <INITIAL>^"CNTABLE" { 00122 return t_CNTABLE; 00123 } 00124 00125 <INITIAL>^"OPTIMEDIT" { 00126 return t_OPTIMEDIT; 00127 } 00128 00129 <INITIAL>^"HYPTABLE" { 00130 return t_HYPTABLE; 00131 } 00132 00133 <INITIAL>^"element" { 00134 return t_ELEMENT; 00135 } 00136 00137 <INITIAL>^"data" { 00138 return t_DATA; 00139 } 00140 00141 <INITIAL>^"dataset" { 00142 return t_DATASET; 00143 } 00144 00145 <INITIAL>^"datasize" { 00146 return t_DATASIZE; 00147 } 00148 00149 <INITIAL>^"point" { 00150 return t_POINT; 00151 } 00152 00153 <INITIAL>^"member" { 00154 BEGIN(PMEMBER); 00155 return t_MEMBER; 00156 } 00157 00158 <INITIAL>^"list" { 00159 BEGIN(PLIST); 00160 return t_LIST; 00161 } 00162 00163 <INITIAL>^"PlotOptimizerOpt" { 00164 return t_PLOTOPTIMIZEROPT; 00165 } 00166 00167 <INITIAL>^"PlotOptimizerTraceSet" { 00168 return t_PLOTOPTIMIZERTRACESET; 00169 } 00170 00171 <INITIAL>^"PlotOptimizerTraceRegSet" { 00172 return t_PLOTOPTIMIZERTRACEREGSET; 00173 } 00174 00175 <INITIAL>^"PlotOptimizerTraceNatRegSet" { 00176 return t_PLOTOPTIMIZERTRACENATREGSET; 00177 } 00178 00179 <INITIAL>^"PlotError" { 00180 return t_PLOTERROR; 00181 } 00182 00183 <INITIAL>^"type" { 00184 return t_TYPE; 00185 } 00186 00187 <INITIAL>^"editsize" { 00188 return t_EDITSIZE; 00189 } 00190 00191 <INITIAL>^"plotsize" { 00192 return t_PLOTSIZE; 00193 } 00194 00195 <INITIAL>^"optrange" { 00196 return t_OPTRANGE; 00197 } 00198 00199 <INITIAL>^"param" { 00200 return t_PARAM; 00201 } 00202 00203 <INITIAL>^"range" { 00204 return t_RANGE; 00205 } 00206 00207 <INITIAL>^"term" { 00208 return t_TERM; 00209 } 00210 00211 <INITIAL>^"calset" { 00212 return t_CALSET; 00213 } 00214 00215 <INITIAL>^"caldata" { 00216 return t_CALDATA; 00217 } 00218 00219 <INITIAL>^"applic" { 00220 return t_APPLIC; 00221 } 00222 00223 <INITIAL>^"subapp" { 00224 return t_SUBAPP; 00225 } 00226 00227 <INITIAL>^"connpair" { 00228 return t_CONNPAIR; 00229 } 00230 00231 <INITIAL>^"circuitdeck" { 00232 BEGIN(CIRCUIT); 00233 return t_CIRCUITDECK; 00234 } 00235 00236 <INITIAL>{REAL} { /* identify float */ 00237 mdl_lval.f = strtod (mdl_text, NULL); 00238 return Real; 00239 } 00240 00241 <INITIAL>{IDENT}|{PIDENT}|{AIDENT} { 00242 mdl_lval.ident = strdup (mdl_text); 00243 return Identifier; 00244 } 00245 00246 <BLKEDIT>"{" { BEGIN(BLKEDIT1); return '{'; } 00247 <CIRCUIT>"{" { BEGIN(CIRCUIT1); return '{'; } 00248 <TABDATA>"{" { BEGIN(TABDATA1); return '{'; } 00249 00250 <INITIAL>"{" { /* pass the '{' to the parser */ return '{'; } 00251 <INITIAL>"}" { /* pass the '{' to the parser */ return '}'; } 00252 00253 <*>\r?\n|{WS} { /* skip end of line and spaces */ } 00254 00255 <BLKEDIT1,CIRCUIT1,TABDATA1>^"}" { BEGIN(INITIAL); return '}'; } 00256 <BLKEDIT1,CIRCUIT1,TABDATA1>. { /* ignore */ } 00257 00258 <*>. { /* any other character is invalid */ 00259 fprintf (stderr, 00260 "line %d: syntax error, unrecognized character: `%s'\n", 00261 mdl_lineno, mdl_text); 00262 return InvalidCharacter; 00263 } 00264 00265 %%