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
|
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import java.util.ArrayList;
import java.util.Collection;
/* When Node */
public class VHDLWNode extends VHDLNode
{
private static final XPathExpression XPE_FIND_NAMED_ENTITIES;
static
{
XPE_FIND_NAMED_ENTITIES =
XMLManager.compile_or_die
(
"./choice_expression//named_entity"
);
}
public VHDLWNode
(
final IDs parent_id,
final Node xml_node,
final IDs next_node,
final int depth,
final String[] attributes
)
{
super
(
parent_id,
xml_node,
next_node,
depth,
attributes
);
}
@Override
public Collection<ParsableXML> parse ()
throws XPathExpressionException
{
final Collection<ParsableXML> result;
final String xml_id;
final IDs local_id;
result = new ArrayList<ParsableXML>();
xml_id = XMLManager.get_attribute(xml_node, "id");
local_id = IDs.get_id_from_xml_id(xml_id, "node");
/** Functions ***********************************************************/
handle_function_label(local_id);
handle_function_kind(local_id);
handle_function_depth(local_id);
handle_function_expression(local_id);
/** Predicates **********************************************************/
handle_predicate_has_option(local_id);
handle_predicate_expr_reads(local_id);
/** Children ************************************************************/
//result.add(handle_body(local_id));
return result;
}
/***************************************************************************/
/** Functions **************************************************************/
/***************************************************************************/
private void handle_function_label
(
final IDs local_id
)
{
Functions.add_entry
(
"label",
local_id,
Strings.get_id_from_string("")
);
}
private void handle_function_kind
(
final IDs local_id
)
{
Functions.add_entry
(
"kind",
local_id,
Strings.get_id_from_string("when")
);
}
private void handle_function_depth
(
final IDs local_id
)
{
Functions.add_entry
(
"depth",
local_id,
Strings.get_id_from_string
(
Integer.toString(depth)
)
);
}
private void handle_function_expression
(
final IDs local_id
)
{
/* TODO */
}
/***************************************************************************/
/** Predicates *************************************************************/
/***************************************************************************/
private void handle_predicate_has_option
(
final IDs local_id
)
{
for (final String s: attributes)
{
Predicates.add_entry
(
"has_option",
local_id,
Strings.get_id_from_string(s)
);
}
}
private void handle_predicate_expr_reads
(
final IDs local_id
)
throws XPathExpressionException
{
final NodeList named_entities;
final int named_entities_count;
named_entities =
(NodeList) XPE_FIND_NAMED_ENTITIES.evaluate
(
xml_node,
XPathConstants.NODESET
);
named_entities_count = named_entities.getLength();
for (int i = 0; i < named_entities_count; ++i)
{
final String ref;
ref = XMLManager.get_attribute(named_entities.item(0), "ref");
if (!Main.node_is_function_or_literal(ref))
{
Predicates.add_entry
(
"expr_reads",
local_id,
Waveforms.get_associated_waveform_id
(
IDs.get_id_from_xml_id(ref, (String) null)
)
);
}
}
}
}
|