verilog parser
commit aa52884df77545280835532c21cb4d024eda5573
Author: James Cherry <cherry@parallaxsw.com>
Date: Sat Jan 25 11:20:33 2025 -0700
zlib optional
Signed-off-by: James Cherry <cherry@parallaxsw.com>
commit 5a46e0e5d1d9fe806d290fa34a4ad4aa0a9e4899
Author: James Cherry <cherry@parallaxsw.com>
Date: Fri Jan 24 19:19:33 2025 -0700
verilog prefix
Signed-off-by: James Cherry <cherry@parallaxsw.com>
commit 1b1fbf41c96f96a4c4b9f8b66f16f27688cb47a8
Author: James Cherry <cherry@parallaxsw.com>
Date: Fri Jan 24 17:09:32 2025 -0700
blank
Signed-off-by: James Cherry <cherry@parallaxsw.com>
commit 72488094a4696414ce5c37a4ab5bb78f4a9750c1
Author: James Cherry <cherry@parallaxsw.com>
Date: Fri Jan 24 16:47:55 2025 -0700
verilog parse reorg
Signed-off-by: James Cherry <cherry@parallaxsw.com>
Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
parent
eb7fe84055
commit
fafbcb216e
|
|
@ -307,7 +307,7 @@ flex_target(VerilogLex ${STA_HOME}/verilog/VerilogLex.ll
|
|||
bison_target(VerilogParse ${STA_HOME}/verilog/VerilogParse.yy
|
||||
${CMAKE_CURRENT_BINARY_DIR}/VerilogParse.cc
|
||||
# centos7 bison 3.0.4 < 3.3.0 uses parser_class_name instead of api.parsr.class
|
||||
COMPILE_FLAGS -Wno-deprecated)
|
||||
COMPILE_FLAGS "-Wno-deprecated")
|
||||
add_flex_bison_dependency(VerilogLex VerilogParse)
|
||||
|
||||
# Sdf scan/parse.
|
||||
|
|
@ -319,7 +319,6 @@ bison_target(SdfParse ${STA_HOME}/sdf/SdfParse.yy ${CMAKE_CURRENT_BINARY_DIR}/Sd
|
|||
)
|
||||
add_flex_bison_dependency(SdfLex SdfParse)
|
||||
|
||||
|
||||
# Saif scan/parse.
|
||||
flex_target(SaifLex ${STA_HOME}/power/SaifLex.ll ${CMAKE_CURRENT_BINARY_DIR}/SaifLex.cc
|
||||
COMPILE_FLAGS --prefix=SaifLex_
|
||||
|
|
|
|||
|
|
@ -32,10 +32,12 @@
|
|||
#ifdef ZLIB_FOUND
|
||||
|
||||
#include <zlib.h>
|
||||
#include "util/gzstream.hh"
|
||||
|
||||
#else // ZLIB_FOUND
|
||||
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
|
||||
#define gzFile FILE*
|
||||
#define gzopen fopen
|
||||
|
|
@ -44,4 +46,8 @@
|
|||
#define gzprintf fprintf
|
||||
#define Z_NULL nullptr
|
||||
|
||||
namespace gzstream {
|
||||
typedef std::ifstream igzstream;
|
||||
}
|
||||
|
||||
#endif // ZLIB_FOUND
|
||||
|
|
|
|||
|
|
@ -23,31 +23,33 @@
|
|||
//
|
||||
// This notice may not be removed or altered from any source distribution.
|
||||
|
||||
#include "util/FlexDisableRegister.hh"
|
||||
#include "VerilogNamespace.hh"
|
||||
#include "verilog/VerilogReader.hh"
|
||||
#include "verilog/VerilogReaderPvt.hh"
|
||||
#include "VerilogParse.hh"
|
||||
#include "verilog/VerilogScanner.hh"
|
||||
#include "util/FlexDisableRegister.hh"
|
||||
|
||||
#undef YY_DECL
|
||||
#define YY_DECL \
|
||||
int \
|
||||
sta::VerilogScanner::yylex(sta::VerilogParse::semantic_type *const yylval, \
|
||||
sta::VerilogScanner::lex(sta::VerilogParse::semantic_type *const yylval, \
|
||||
sta::VerilogParse::location_type *loc)
|
||||
|
||||
// update location on matching
|
||||
#define YY_USER_ACTION loc->step(); loc->columns(yyleng);
|
||||
|
||||
typedef sta::VerilogParse::token token;
|
||||
|
||||
%}
|
||||
|
||||
%option c++
|
||||
%option yyclass="sta::VerilogScanner"
|
||||
%option prefix="Verilog"
|
||||
%option noyywrap
|
||||
%option never-interactive
|
||||
%option stack
|
||||
%option yylineno
|
||||
/* %option debug */
|
||||
|
||||
%x COMMENT
|
||||
%x QSTRING
|
||||
|
|
|
|||
|
|
@ -22,45 +22,18 @@
|
|||
//
|
||||
// This notice may not be removed or altered from any source distribution.
|
||||
|
||||
%require "3.0"
|
||||
%skeleton "lalr1.cc"
|
||||
%debug
|
||||
%defines
|
||||
%define api.namespace {sta}
|
||||
|
||||
// bison 3.0.4 for centos7
|
||||
%define parser_class_name {VerilogParse}
|
||||
// bison 3.3.2
|
||||
//%define api.parser.class {VerilogParse}
|
||||
|
||||
%code requires {
|
||||
namespace sta {
|
||||
class VerilogReadcer;
|
||||
class VerilogScanner;
|
||||
}
|
||||
}
|
||||
|
||||
%locations
|
||||
|
||||
%parse-param { VerilogScanner *scanner }
|
||||
%parse-param { VerilogReader *reader }
|
||||
|
||||
%{
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "Report.hh"
|
||||
#include "PortDirection.hh"
|
||||
#include "verilog/VerilogReader.hh"
|
||||
#include "verilog/VerilogReaderPvt.hh"
|
||||
#include "verilog/VerilogScanner.hh"
|
||||
%}
|
||||
|
||||
%code {
|
||||
|
||||
#undef yylex
|
||||
#define yylex scanner->yylex
|
||||
#define yylex scanner->lex
|
||||
|
||||
// warning: variable 'yynerrs_' set but not used
|
||||
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
|
|
@ -73,10 +46,21 @@ sta::VerilogParse::error(const location_type &loc,
|
|||
{
|
||||
reader->report()->fileError(164,reader->filename(),loc.begin.line,"%s",msg.c_str());
|
||||
}
|
||||
%}
|
||||
|
||||
}
|
||||
|
||||
%require "3.0"
|
||||
%skeleton "lalr1.cc"
|
||||
%debug
|
||||
%define api.namespace {sta}
|
||||
%locations
|
||||
%define parse.assert
|
||||
%parse-param { VerilogScanner *scanner }
|
||||
%parse-param { VerilogReader *reader }
|
||||
|
||||
// bison 3.0.4 for centos7
|
||||
%define parser_class_name {VerilogParse}
|
||||
// bison 3.3.2
|
||||
//%define api.parser.class {VerilogParse}
|
||||
|
||||
%union {
|
||||
int ival;
|
||||
|
|
|
|||
|
|
@ -26,8 +26,7 @@
|
|||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "util/gzstream.hh"
|
||||
|
||||
#include "Zlib.hh"
|
||||
#include "Debug.hh"
|
||||
#include "Report.hh"
|
||||
#include "Error.hh"
|
||||
|
|
@ -2262,7 +2261,7 @@ VerilogScanner::VerilogScanner(std::istream *stream,
|
|||
void
|
||||
VerilogScanner::error(const char *msg)
|
||||
{
|
||||
report_->fileError(1866, "foo", lineno(), "%s", msg);
|
||||
report_->fileError(1866, filename_, lineno(), "%s", msg);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef __FLEX_LEXER_H
|
||||
#undef yyFlexLexer
|
||||
#define yyFlexLexer VerilogFlexLexer
|
||||
#include <FlexLexer.h>
|
||||
#endif
|
||||
|
||||
|
|
@ -35,7 +37,7 @@ namespace sta {
|
|||
|
||||
class Report;
|
||||
|
||||
class VerilogScanner : public yyFlexLexer
|
||||
class VerilogScanner : public VerilogFlexLexer
|
||||
{
|
||||
public:
|
||||
VerilogScanner(std::istream *stream,
|
||||
|
|
@ -43,15 +45,15 @@ public:
|
|||
Report *report);
|
||||
virtual ~VerilogScanner() {}
|
||||
|
||||
virtual int yylex(VerilogParse::semantic_type *const yylval,
|
||||
virtual int lex(VerilogParse::semantic_type *const yylval,
|
||||
VerilogParse::location_type *yylloc);
|
||||
// YY_DECL defined in VerilogLex.ll
|
||||
// Method body created by flex in VerilogLex.yy.cc
|
||||
// Method body created by flex in VerilogLex.cc
|
||||
|
||||
void error(const char *msg);
|
||||
|
||||
// Get rid of override virtual function warning.
|
||||
using FlexLexer::yylex;
|
||||
using yyFlexLexer::yylex;
|
||||
|
||||
private:
|
||||
const char *filename_;
|
||||
|
|
|
|||
Loading…
Reference in New Issue