/* -*-c-*- */ %{ /* * scan_mdl.l - scanner for an IC-CAP MDL data file * * Copyright (C) 2006 Stefan Jahn * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this package; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, * Boston, MA 02110-1301, USA. * * $Id$ * */ #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-register" #endif #if HAVE_CONFIG_H # include #endif #include #include #include #include #ifdef __MINGW32__ #include #endif #ifdef HAVE_UNISTD_H #include #endif #include "check_mdl.h" #include "parse_mdl.hpp" #if !HAVE_STRCHR # define strchr index # define strrchr rindex #endif using namespace qucs; %} WS [ \t\n\r] DIGIT [0-9] EXPONENT [Ee][+-]?{DIGIT}+ INT [+-]?{DIGIT}+ REAL [+-]?{DIGIT}+("."{DIGIT}+)?{EXPONENT}? DECIMAL {DIGIT}+ IDENT [a-zA-Z][a-zA-Z0-9_]* DIGITS {DIGIT}+ PIDENT {IDENT}("."({IDENT}|{DECIMAL}))* AIDENT {IDENT}("."{IDENT})*"["{DIGITS}","{DIGITS}"]" LINKS "MODEL"|"CIRC"|"PS"|"DUT"|"DPS"|"DAT"|"OUT"|"SWEEP"|"XFORM"|"MACRO"|"TCIRC"|"CONN"|"PLOT" %x VERSION BLKEDIT BLKEDIT1 CIRCUIT CIRCUIT1 PLINK PLIST PMEMBER %x TABDATA TABDATA1 %option yylineno noyywrap nounput noinput prefix="mdl_" %% ^"LINK" { BEGIN(PLINK); return LINK; } {LINKS} { mdl_lval.ident = strdup (mdl_text); BEGIN(INITIAL); return t_LINK; } \"[^\"]*\" { mdl_text[strlen (mdl_text) - 1] = '\0'; mdl_text[0] = '\0'; mdl_lval.ident = strdup (&mdl_text[1]); return String; } ^"View" { return t_VIEW; } ^"TABLE" { return t_TABLE; } ^"TABLE \"ICVIEWDATA\"" { BEGIN(TABDATA); return t_TABLE; } ^"PSTABLE" { return t_PSTABLE; } ^"BLKEDIT" { BEGIN(BLKEDIT); return t_BLKEDIT; } ^"CNTABLE" { return t_CNTABLE; } ^"OPTIMEDIT" { return t_OPTIMEDIT; } ^"HYPTABLE" { return t_HYPTABLE; } ^"element" { return t_ELEMENT; } ^"data" { return t_DATA; } ^"dataset" { return t_DATASET; } ^"datasize" { return t_DATASIZE; } ^"point" { return t_POINT; } ^"member" { BEGIN(PMEMBER); return t_MEMBER; } ^"list" { BEGIN(PLIST); return t_LIST; } ^"PlotOptimizerOpt" { return t_PLOTOPTIMIZEROPT; } ^"PlotOptimizerTraceSet" { return t_PLOTOPTIMIZERTRACESET; } ^"PlotOptimizerTraceRegSet" { return t_PLOTOPTIMIZERTRACEREGSET; } ^"PlotOptimizerTraceNatRegSet" { return t_PLOTOPTIMIZERTRACENATREGSET; } ^"PlotError" { return t_PLOTERROR; } ^"type" { return t_TYPE; } ^"editsize" { return t_EDITSIZE; } ^"plotsize" { return t_PLOTSIZE; } ^"optrange" { return t_OPTRANGE; } ^"param" { return t_PARAM; } ^"range" { return t_RANGE; } ^"term" { return t_TERM; } ^"calset" { return t_CALSET; } ^"caldata" { return t_CALDATA; } ^"applic" { return t_APPLIC; } ^"subapp" { return t_SUBAPP; } ^"connpair" { return t_CONNPAIR; } ^"circuitdeck" { BEGIN(CIRCUIT); return t_CIRCUITDECK; } {REAL} { /* identify float */ mdl_lval.f = strtod (mdl_text, NULL); return Real; } {IDENT}|{PIDENT}|{AIDENT} { mdl_lval.ident = strdup (mdl_text); return Identifier; } "{" { BEGIN(BLKEDIT1); return '{'; } "{" { BEGIN(CIRCUIT1); return '{'; } "{" { BEGIN(TABDATA1); return '{'; } "{" { /* pass the '{' to the parser */ return '{'; } "}" { /* pass the '{' to the parser */ return '}'; } <*>\r?\n|{WS} { /* skip end of line and spaces */ } ^"}" { BEGIN(INITIAL); return '}'; } . { /* ignore */ } <*>. { /* any other character is invalid */ fprintf (stderr, "line %d: syntax error, unrecognized character: `%s'\n", mdl_lineno, mdl_text); return InvalidCharacter; } %%