2018-09-28 17:54:21 +02:00
|
|
|
%{
|
|
|
|
|
// OpenSTA, Static Timing Analyzer
|
2025-01-22 02:54:33 +01:00
|
|
|
// Copyright (c) 2025, Parallax Software, Inc.
|
2018-09-28 17:54:21 +02:00
|
|
|
//
|
|
|
|
|
// 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
|
2022-01-04 18:17:08 +01:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2018-09-28 17:54:21 +02:00
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
2022-01-04 18:17:08 +01:00
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2025-01-22 02:54:33 +01:00
|
|
|
//
|
|
|
|
|
// The origin of this software must not be misrepresented; you must not
|
|
|
|
|
// claim that you wrote the original software.
|
|
|
|
|
//
|
|
|
|
|
// Altered source versions must be plainly marked as such, and must not be
|
|
|
|
|
// misrepresented as being the original software.
|
|
|
|
|
//
|
|
|
|
|
// This notice may not be removed or altered from any source distribution.
|
2018-09-28 17:54:21 +02:00
|
|
|
|
|
|
|
|
// Liberty function expression lexical analyzer
|
|
|
|
|
|
2020-11-11 16:32:25 +01:00
|
|
|
#include "util/FlexDisableRegister.hh"
|
2020-04-05 23:53:44 +02:00
|
|
|
#include "Debug.hh"
|
|
|
|
|
#include "StringUtil.hh"
|
2025-02-01 23:49:30 +01:00
|
|
|
#include "liberty/LibExprReaderPvt.hh"
|
|
|
|
|
#include "liberty/LibExprReader.hh"
|
|
|
|
|
#include "liberty/LibExprScanner.hh"
|
2018-09-28 17:54:21 +02:00
|
|
|
|
|
|
|
|
using sta::stringCopy;
|
|
|
|
|
using sta::FuncExpr;
|
|
|
|
|
|
2025-02-01 23:49:30 +01:00
|
|
|
#include "LibExprParse.hh"
|
2018-09-28 17:54:21 +02:00
|
|
|
|
2025-02-01 23:49:30 +01:00
|
|
|
#undef YY_DECL
|
|
|
|
|
#define YY_DECL \
|
|
|
|
|
int \
|
|
|
|
|
sta::LibExprScanner::lex(sta::LibExprParse::semantic_type *const yylval)
|
2018-09-28 17:54:21 +02:00
|
|
|
|
2025-02-01 23:49:30 +01:00
|
|
|
typedef sta::LibExprParse::token token;
|
2018-09-28 17:54:21 +02:00
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
2025-02-01 23:49:30 +01:00
|
|
|
%option c++
|
|
|
|
|
%option yyclass="sta::LibExprScanner"
|
|
|
|
|
%option prefix="LibExpr"
|
2018-09-28 17:54:21 +02:00
|
|
|
%option noyywrap
|
|
|
|
|
%option never-interactive
|
2025-02-01 23:49:30 +01:00
|
|
|
%option stack
|
|
|
|
|
/* %option debug */
|
2018-09-28 17:54:21 +02:00
|
|
|
|
|
|
|
|
%x ESCAPED_STRING
|
|
|
|
|
|
2023-02-19 01:20:40 +01:00
|
|
|
PORT [A-Za-z_]([A-Za-z0-9_\.\[\]])*
|
2018-09-28 17:54:21 +02:00
|
|
|
OP "'"|"!"|"^"|"*"|"&"|"+"|"|"|1|0
|
|
|
|
|
PAREN "("|")"
|
|
|
|
|
BLANK [ \t\r]
|
|
|
|
|
ESCAPE \\
|
|
|
|
|
QUOTE \"
|
|
|
|
|
EOL \r?\n
|
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
2025-02-01 23:49:30 +01:00
|
|
|
{OP}|{PAREN} { return ((int) yytext[0]); }
|
2018-09-28 17:54:21 +02:00
|
|
|
|
|
|
|
|
{ESCAPE}{EOL} { /* I doubt that escaped returns get thru the parser */ }
|
|
|
|
|
|
2025-02-01 23:49:30 +01:00
|
|
|
{ESCAPE}{QUOTE} { BEGIN(ESCAPED_STRING); token_.clear(); }
|
2018-09-28 17:54:21 +02:00
|
|
|
|
2025-02-01 23:49:30 +01:00
|
|
|
<ESCAPED_STRING>. { token_ += yytext[0]; }
|
2018-09-28 17:54:21 +02:00
|
|
|
|
|
|
|
|
<ESCAPED_STRING>{ESCAPE}{QUOTE} {
|
|
|
|
|
BEGIN(INITIAL);
|
2025-02-01 23:49:30 +01:00
|
|
|
yylval->string = stringCopy(token_.c_str());
|
|
|
|
|
return token::PORT;
|
2018-09-28 17:54:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{PORT} {
|
2025-02-01 23:49:30 +01:00
|
|
|
yylval->string = stringCopy(yytext);
|
|
|
|
|
return token::PORT;
|
2018-09-28 17:54:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{BLANK} {}
|
|
|
|
|
|
|
|
|
|
/* Send out of bound characters to parser. */
|
2025-02-01 23:49:30 +01:00
|
|
|
. { return (int) yytext[0]; }
|
2018-09-28 17:54:21 +02:00
|
|
|
|
|
|
|
|
%%
|