-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathverilog_parser.cpp
102 lines (68 loc) · 1.99 KB
/
verilog_parser.cpp
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
/*******************************************************************\
Module:
Author: Daniel Kroening, [email protected]
\*******************************************************************/
#include "verilog_parser.h"
#include <util/cout_message.h>
#include <util/unicode.h>
#include "verilog_expr.h"
#include <fstream>
#include <iostream>
#include <stdio.h>
verilog_parsert verilog_parser;
/*******************************************************************\
Function:
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool parse_verilog_file(const std::string &filename)
{
std::ifstream in(widen_if_needed(filename));
console_message_handlert console_message_handler;
verilog_parser.set_file(filename);
verilog_parser.log.set_message_handler(console_message_handler);
if(filename=="")
verilog_parser.in=&std::cin;
else
{
if(!in)
{
std::cerr << "failed to open " << filename << std::endl;
return true;
}
verilog_parser.in=∈
}
return verilog_parser.parse();
}
/*******************************************************************\
Function: verilog_parsert::lookup
Inputs:
Outputs:
Purpose:
\*******************************************************************/
const verilog_parsert::scopet *verilog_parsert::lookup(irep_idt name) const
{
// we start from the current scope, and walk upwards to the root
auto scope = current_scope;
while(scope != nullptr)
{
auto name_it = scope->scope_map.find(name);
if(name_it == scope->scope_map.end())
scope = scope->parent;
else
return &name_it->second; // found it
}
// not found, give up
return nullptr;
}
/*******************************************************************\
Function: verilog_parsert::scopet::import_item
Inputs:
Outputs:
Purpose:
\*******************************************************************/
void verilog_parsert::scopet::import_item(
const verilog_import_itemt &import_item)
{
}