/* -*-c-*- */ %{ /* * scan_citi.l - scanner for CITIfiles * * 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 "logging.h" #include "complex.h" #include "object.h" #include "vector.h" #include "dataset.h" #include "check_citi.h" #include "parse_citi.hpp" using namespace qucs; %} WS [ \t\n\r] ID [a-zA-Z_][a-zA-Z0-9_\.]* DIGIT [0-9] EXPONENT [Ee][+-]?{DIGIT}+ INT [+-]?{DIGIT}+ FLOAT1 [+-]?{DIGIT}+{EXPONENT} FLOAT2 [+-]?{DIGIT}*"."{DIGIT}+({EXPONENT})? SPACE [ \t] EOL \r?\n %x COMMENTS FLOATS LISTS DATAS VALUES %option yylineno noyywrap nounput noinput prefix="citi_" %% {EOL}+ { /* detect end of line */ return Eol; } <*>{SPACE} /* skip spaces */ {INT} { /* identify integer */ citi_lval.d = strtol (citi_text, NULL, 10); return Integer; } [a-zA-Z]"."{DIGIT}+"."{DIGIT}+ { return Version; } ("RI"|"MAG"|"MAGANGLE"|"DBANGLE") { citi_lval.ident = strdup (citi_text); return VarType; } ^"CITIFILE" { return CITIFILE; } ^"VAR" { return VAR; } ^"DATA" { BEGIN(DATAS); return DATA; } ^"NAME" { return NAME; } ^"BEGIN" { BEGIN(FLOATS); return Begin; } ^"CONSTANT" { BEGIN(VALUES); return CONSTANT; } ^"COMMENT" { BEGIN(COMMENTS); } ^"SEG_LIST_BEGIN" { BEGIN(LISTS); return SegListBegin; } ^"VAR_LIST_BEGIN" { BEGIN(LISTS); return VarListBegin; } ^"SEG_LIST_END" { BEGIN(INITIAL); return SegListEnd; } ^"VAR_LIST_END" { BEGIN(INITIAL); return VarListEnd; } ^"SEG" { return SEG; } {ID} { /* identify identifier */ citi_lval.ident = strdup (citi_text); return Identifier; } ({FLOAT1}|{FLOAT2}|{INT}) { /* identify float */ citi_lval.f = strtod (citi_text, NULL); return Float; } {EOL}+ { BEGIN(INITIAL); return Eol; } "," { /* pass the ',' to the parser */ return ','; } "[" { /* pass the '[' to the parser */ return '['; } "]" { /* pass the ']' to the parser */ BEGIN(INITIAL); return ']'; } {EOL}+ { BEGIN(INITIAL); return Eol; } "," { /* pass the ',' to the parser */ return ','; } ^"END" { BEGIN(INITIAL); return End; } ^"#" { /* leave these characters */ BEGIN(COMMENTS); } . { /* skip any character in here */ } {EOL}+ { BEGIN(INITIAL); /* skipping ends here */ } <*>. { /* any other character in invalid */ logprint (LOG_ERROR, "line %d: syntax error, unrecognized character: `%s'\n", citi_lineno, citi_text); return InvalidCharacter; } %%