Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
scan_zvr.l
Go to the documentation of this file.
1 /* -*-c-*- */
2 
3 %{
4 /*
5  * scan_zvr.l - scanner for a ZVR data file
6  *
7  * Copyright (C) 2006, 2007 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 "check_zvr.h"
46 #include "tokens_zvr.h"
47 
48 #if !HAVE_STRCHR
49 # define strchr index
50 # define strrchr rindex
51 #endif
52 
53 using namespace qucs;
54 
55 %}
56 
57 WS [ \t\n\r]
58 DIGIT [0-9]
59 EXPONENT [Ee][+-]?{DIGIT}+
60 INT [+-]?{DIGIT}+
61 REAL [+-]?{DIGIT}+("."{DIGIT}+)?{EXPONENT}?
62 DECIMAL {DIGIT}+
63 IDENT [a-zA-Z][a-zA-Z-]*
64 DIGITS {DIGIT}+
65 DIDENT [A-Z]({DIGIT}{1,2})?
66 
67 %x VERSION
68 
69 %option yylineno noyywrap nounput prefix="zvr_"
70 
71 %%
72 
73 <INITIAL>"ZVR," {
74  BEGIN(VERSION);
75  return ZVR;
76 }
77 
78 <VERSION>{DIGITS}"."{DIGITS} {
79  BEGIN(INITIAL);
80  return Version;
81 }
82 
83 <INITIAL>{REAL} {
84  zvr_lval.f = strtod (zvr_text, NULL);
85  return Real;
86 }
87 
88 <INITIAL>("Hz")|("none")|("dB") {
89  zvr_lval.ident = strdup (zvr_text);
90  return Unit;
91 }
92 
93 <INITIAL>("RI")|("COMPLEX")|("MAGNITUDE")|("PHASE")|("MA")|("DB") {
94  zvr_lval.ident = strdup (zvr_text);
95  return DataFMT;
96 }
97 
98 <INITIAL>{DIDENT} {
99  zvr_lval.ident = strdup (zvr_text);
100  return DataTYP;
101 }
102 
103 <INITIAL>{IDENT} {
104  zvr_lval.ident = strdup (zvr_text);
105  return Identifier;
106 }
107 
108 <INITIAL>(("re")|("im")|("mag")|("ang")|("db"))?{DIDENT} {
109  zvr_lval.ident = strdup (zvr_text);
110  return DataIDN;
111 }
112 
113 <INITIAL>";" { /* pass the ';' to the parser */ return ';'; }
114 
115 <*>\r?\n|{WS} { /* skip end of line and spaces */ }
116 
117 <*>. { /* any other character is invalid */
118  fprintf (stderr,
119  "line %d: syntax error, unrecognized character: `%s'\n",
120  zvr_lineno, zvr_text);
121  return InvalidCharacter;
122 }
123 
124 %%
#define INT(con)
Definition: evaluate.cpp:68
int zvr_lineno
DataFMT
Definition: parse_zvr.y:122
Identifier
Definition: parse_csv.y:87
n
Definition: parse_citi.y:147
r
Definition: parse_mdl.y:515
DataTYP
Definition: parse_zvr.y:120
< INITIAL >< INITIAL >< INITIAL >< INITIAL > return InvalidCharacter
Definition: scan_netlist.l:698
x
Definition: parse_mdl.y:498
t_TABLE String Real
Definition: parse_mdl.y:382
name prefix
Definition: parse_spice.y:131
#define A(a)
Definition: eqndefined.cpp:72
Unit
Definition: parse_zvr.y:120
REAL
Definition: parse_vcd.y:236