Ai
1 Star 0 Fork 0

hongcez/verilog-parser

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
verilog_parser_wrapper.c 1.53 KB
一键复制 编辑 原始数据 按行查看 历史
Bo-Yuan Huang 提交于 2018-12-20 23:26 +08:00 . Move headers intp wrapped dir
/*!
@file verilog_parser_wrapper.c
@brief Contains implementations of functions declared in verilog_parser.h
*/
#include <verilogparser/verilog_ast.h>
#include <verilogparser/verilog_parser.h>
//! This is defined in the generated bison parser code.
extern int yyparse();
void verilog_parser_init()
{
if(yy_preproc == NULL)
{
//printf("Added new preprocessor context\n");
yy_preproc = verilog_new_preprocessor_context();
}
if(yy_verilog_source_tree == NULL)
{
//printf("Added new source tree\n");
yy_verilog_source_tree = verilog_new_source_tree();
}
}
/*!
@brief Perform a parsing operation on the currently selected buffer.
*/
int verilog_parse_file(FILE * to_parse)
{
YY_BUFFER_STATE new_buffer = yy_create_buffer(to_parse, YY_BUF_SIZE);
yy_switch_to_buffer(new_buffer);
yylineno = 0; // Reset the global line counter, we are in a new file!
int result = yyparse();
return result;
}
/*!
@brief Perform a parsing operation on the supplied in-memory string.
*/
int verilog_parse_string(char * to_parse, int length)
{
YY_BUFFER_STATE new_buffer = yy_scan_bytes(to_parse, length);
yy_switch_to_buffer(new_buffer);
int result = yyparse();
return result;
}
/*!
@brief Perform a parsing operation on the supplied in-memory string.
*/
int verilog_parse_buffer(char * to_parse, int length)
{
YY_BUFFER_STATE new_buffer = yy_scan_buffer(to_parse, length);
yy_switch_to_buffer(new_buffer);
int result = yyparse();
return result;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hongcez/verilog-parser.git
git@gitee.com:hongcez/verilog-parser.git
hongcez
verilog-parser
verilog-parser
master

搜索帮助