/* -*-c-*- */ %{ /* * scan_zvr.l - scanner for a ZVR data file * * Copyright (C) 2006, 2007 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_zvr.h" #include "parse_zvr.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-Z-]* DIGITS {DIGIT}+ DIDENT [A-Z]({DIGIT}{1,2})? %x VERSION %option yylineno noyywrap nounput noinput prefix="zvr_" %% "ZVR," { BEGIN(VERSION); return ZVR; } {DIGITS}"."{DIGITS} { BEGIN(INITIAL); return Version; } {REAL} { zvr_lval.f = strtod (zvr_text, NULL); return Real; } ("Hz")|("none")|("dB") { zvr_lval.ident = strdup (zvr_text); return Unit; } ("RI")|("COMPLEX")|("MAGNITUDE")|("PHASE")|("MA")|("DB") { zvr_lval.ident = strdup (zvr_text); return DataFMT; } {DIDENT} { zvr_lval.ident = strdup (zvr_text); return DataTYP; } {IDENT} { zvr_lval.ident = strdup (zvr_text); return Identifier; } (("re")|("im")|("mag")|("ang")|("db"))?{DIDENT} { zvr_lval.ident = strdup (zvr_text); return DataIDN; } ";" { /* pass the ';' to the parser */ return ';'; } <*>\r?\n|{WS} { /* skip end of line and spaces */ } <*>. { /* any other character is invalid */ fprintf (stderr, "line %d: syntax error, unrecognized character: `%s'\n", zvr_lineno, zvr_text); return InvalidCharacter; } %%