forked from The-OpenROAD-Project/OpenSTA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpefLex.ll
217 lines (181 loc) · 4.67 KB
/
SpefLex.ll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
%{
// OpenSTA, Static Timing Analyzer
// Copyright (c) 2024, Parallax Software, Inc.
//
// This program 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 3 of the License, or
// (at your option) any later version.
//
// This program 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 program. If not, see <https://www.gnu.org/licenses/>.
#include <string.h>
#include <string>
#include "util/FlexDisableRegister.hh"
#include "StringUtil.hh"
#include "parasitics/SpefReaderPvt.hh"
#include "SpefParse.hh"
#define YY_NO_INPUT
static std::string spef_token;
void
spefFlushBuffer()
{
YY_FLUSH_BUFFER;
}
// Reset the start condition to INITIAL.
void
spefResetScanner()
{
BEGIN(0);
}
%}
/* %option debug */
%option noyywrap
%option nounput
%option never-interactive
%x COMMENT
%x QUOTE
ALPHA [A-Za-z]
DIGIT [0-9]
BLANK [ \t\r]
POS_SIGN "+"
NEG_SIGN "-"
POS_INTEGER {DIGIT}+
SIGN {POS_SIGN}|{NEG_SIGN}
INTEGER {SIGN}?{DIGIT}+
DECIMAL {SIGN}?{DIGIT}+"."{DIGIT}*
FRACTION {SIGN}?"."{DIGIT}+
RADIX {DECIMAL}|{FRACTION}|{INTEGER}
EXP {RADIX}[eE]{INTEGER}
FLOAT {DECIMAL}|{FRACTION}|{EXP}
HCHAR "."|"/"|"|"|":"
PREFIX_BUS_DELIM "["|"{"|"("|"<"
SUFFIX_BUS_DELIM "]"|"}"|")"|">"
SPECIAL_CHAR "!"|"#"|"$"|"%"|"&"|"`"|"("|")"|"*"|"+"|","|"-"|"."|"/"|":"|";"|"<"|"="|">"|"?"|"@"|"["|"\\"|"]"|"^"|"'"|"{"|"|"|"}"|"~"
ESCAPED_CHAR_SET {SPECIAL_CHAR}|\"
ESCAPED_CHAR \\{ESCAPED_CHAR_SET}
IDENT_ACHAR {ESCAPED_CHAR}|{ALPHA}|"_"
IDENT_CHAR {IDENT_ACHAR}|{DIGIT}
ID {IDENT_ACHAR}{IDENT_CHAR}*
BUS_SUB {DIGIT}|{ALPHA}|"_"
BIT_IDENT {ID}({PREFIX_BUS_DELIM}{BUS_SUB}+{SUFFIX_BUS_DELIM})+
ID_OR_BIT {ID}|{BIT_IDENT}
IDENT {INTEGER}*{ID_OR_BIT}({HCHAR}|{INTEGER}|{ID_OR_BIT})*
IDENT_OR_BIT {ID}|{BIT_IDENT}
PATH {IDENT_OR_BIT}({HCHAR}{IDENT_OR_BIT})*
NAME_PAIR ({PATH}|{INDEX}){HCHAR}({INDEX}|{IDENT_OR_BIT}|{POS_INTEGER})
INDEX "*"{POS_INTEGER}
%%
"*BUS_DELIMITER" { return BUS_DELIMITER; }
"*C2_R1_C1" { return C2_R1_C1; }
"*C" { return KW_C; }
"*CAP" { return CAP; }
"*CELL" { return CELL; }
"*CONN" { return CONN; }
"*C_UNIT" { return C_UNIT; }
"*SPEF" { return SPEF; }
"*DATE" { return DATE; }
"*DEFINE" { return DEFINE; }
"*DELIMITER" { return DELIMITER; }
"*DESIGN" { return DESIGN; }
"*DESIGN_FLOW" { return DESIGN_FLOW; }
"*DIVIDER" { return DIVIDER; }
"*DRIVER" { return DRIVER; }
"*D_NET" { return D_NET; }
"*D_PNET" { return D_PNET; }
"*D" { return KW_D; }
"*END" { return END; }
"*GROUND_NETS" { return GROUND_NETS; }
"*INDUC" { return INDUC; }
"*I" { return KW_I; }
"*K" { return KW_K; }
"*L" { return KW_L; }
"*LOADS" { return LOADS; }
"*L_UNIT" { return L_UNIT; }
"*NAME_MAP" { return NAME_MAP; }
"*N" { return KW_N; }
"*PDEFINE" { return PDEFINE; }
"*PHYSICAL_PORTS" { return PHYSICAL_PORTS; }
"*PORTS" { return PORTS; }
"*POWER_NETS" { return POWER_NETS; }
"*PROGRAM" { return PROGRAM; }
"*P" { return KW_P; }
"*Q" { return KW_Q; }
"*RC" { return RC; }
"*RES" { return RES; }
"*R_NET" { return R_NET; }
"*R_PNET" { return R_PNET; }
"*R_UNIT" { return R_UNIT; }
"*S" { return KW_S; }
"*T_UNIT" { return T_UNIT; }
"*VENDOR" { return VENDOR; }
"*VERSION" { return PVERSION; }
"*V" { return KW_V; }
"//".*\n { /* Single line comment */
sta::spef_reader->incrLine();
}
"/*" { BEGIN COMMENT; }
<COMMENT>{
.
\n { sta::spef_reader->incrLine(); }
"*/" { BEGIN INITIAL; }
<<EOF>> {
SpefParse_error("unterminated comment");
BEGIN(INITIAL);
yyterminate();
}
}
"\"" { BEGIN QUOTE; spef_token.erase(); }
<QUOTE>{
\r?\n {
sta::spef_reader->incrLine();
}
"\\". { spef_token += yytext[1]; }
"\"" {
BEGIN INITIAL;
SpefParse_lval.string = sta::stringCopy(spef_token.c_str());
return QSTRING;
}
. { spef_token += yytext[0]; }
<<EOF>> {
SpefParse_error("unterminated quoted string");
BEGIN(INITIAL);
yyterminate();
}
}
{BLANK}*\n {
sta::spef_reader->incrLine();
}
{INTEGER} {
SpefParse_lval.integer = atoi(yytext);
return INTEGER;
}
{FLOAT} {
SpefParse_lval.number = static_cast<float>(atof(yytext));
return FLOAT;
}
{IDENT} {
SpefParse_lval.string = sta::spef_reader->translated(yytext);
return IDENT;
}
{PATH}|{NAME_PAIR} {
SpefParse_lval.string = sta::spef_reader->translated(yytext);
return NAME;
}
{INDEX} {
SpefParse_lval.string = sta::stringCopy(yytext);
return INDEX;
}
{HCHAR} {
char ch = yytext[0];
return ((int) ch);
}
{BLANK} /* ignore blanks */ ;
/* Send out of bound characters to parser. */
. { return ((int) yytext[0]); }
%%