Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
scan_touchstone.l
Go to the documentation of this file.
1 /* -*-c-*- */
2 
3 %{
4 /*
5  * scan_touchstone.l - scanner for Touchstone files
6  *
7  * Copyright (C) 2003, 2004, 2005, 2008 Stefan Jahn <stefan@lkcc.org>
8  *
9  * This is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2, or (at your option)
12  * any later version.
13  *
14  * This software is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this package; see the file COPYING. If not, write to
21  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  *
24  * $Id$
25  *
26  */
27 
28 #if HAVE_CONFIG_H
29 # include <config.h>
30 #endif
31 
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <ctype.h>
36 
37 #ifdef __MINGW32__
38 #include <io.h>
39 #endif
40 
41 #ifdef HAVE_UNISTD_H
42 #include <unistd.h>
43 #endif
44 
45 #include "logging.h"
46 #include "complex.h"
47 #include "object.h"
48 #include "vector.h"
49 #include "dataset.h"
50 #include "check_touchstone.h"
51 #include "tokens_touchstone.h"
52 
53 using namespace qucs;
54 
55 %}
56 
57 WS [ \t\n\r]
58 ID [a-zA-Z_][a-zA-Z0-9_]*
59 DIGIT [0-9]
60 EXPONENT [Ee][+-]?{DIGIT}+
61 INT [+-]?{DIGIT}+
62 FLOAT1 [+-]?{DIGIT}+{EXPONENT}
63 FLOAT2 [+-]?{DIGIT}*"."{DIGIT}+({EXPONENT})?
64 SPACE [ \t]
65 
66 %x COMMENT
67 %option yylineno noyywrap nounput prefix="touchstone_"
68 
69 %%
70 
71 <INITIAL>[Rr] { /* pass the 'R' to the parser */ return 'R'; }
72 <INITIAL>^# { /* pass the leading '#' to the parser */ return '#'; }
73 <INITIAL>\r?\n { /* detect end of line */ return Eol; }
74 
75 <*>{SPACE} /* skip spaces */
76 
77 <INITIAL>{ID} { /* identify identifier */
78  touchstone_lval.ident = strdup (touchstone_text);
79  return Option;
80  }
81 
82 <INITIAL>({FLOAT1}|{FLOAT2}|{INT}) { /* identify float */
83  touchstone_lval.f = strtod (touchstone_text, NULL);
84  return Float;
85  }
86 
87 <INITIAL>"!" { /* leave these characters */
88  BEGIN(COMMENT);
89  }
90 
91 <INITIAL>. { /* any other character in invalid */
93  "line %d: syntax error, unrecognized character: `%s'\n",
94  touchstone_lineno, touchstone_text);
95  return InvalidCharacter;
96  }
97 
98 <COMMENT>. { /* skip any character in here */ }
99 <COMMENT>\r?\n { BEGIN(INITIAL); /* skipping ends here */ return Eol; }
100 
101 %%
#define INT(con)
Definition: evaluate.cpp:68
t
Definition: parse_vcd.y:290
int touchstone_lineno
n
Definition: parse_citi.y:147
r
Definition: parse_mdl.y:515
RLC_Device Node Node Value MODEL_Ident PairList Eol
Definition: parse_spice.y:225
< INITIAL >< INITIAL >< INITIAL >< INITIAL > return InvalidCharacter
Definition: scan_netlist.l:698
#define Z_(r, c)
Definition: hbsolver.cpp:689
x
Definition: parse_mdl.y:498
Float
Definition: parse_citi.y:213
name prefix
Definition: parse_spice.y:131
WS[\t\n\r] SIMPLEID *[a-zA-Z_][a-zA-Z0-9_] POSTID[a-zA-Z0-9_] ID
Definition: scan_netlist.l:581
#define LOG_ERROR
Definition: logging.h:28
void logprint(int level, const char *format,...)
Definition: logging.c:37
#define Z0
Wave impedance in vacuum ( )
Definition: constants.h:53