Merge lp:~danilovesky/workcraft/trunk-verilog-export-translate into lp:workcraft
- trunk-verilog-export-translate
- Merge into trunk
Proposed by
Danil Sokolov
Status: | Merged |
---|---|
Merged at revision: | 667 |
Proposed branch: | lp:~danilovesky/workcraft/trunk-verilog-export-translate |
Merge into: | lp:workcraft |
Diff against target: |
3388 lines (+1990/-643) 18 files modified
CircuitPlugin/src/org/workcraft/plugins/circuit/CircuitSettings.java (+23/-0) CircuitPlugin/src/org/workcraft/plugins/circuit/CircuitUtils.java (+6/-6) CircuitPlugin/src/org/workcraft/plugins/circuit/interop/GenlibImporter.java (+8/-2) CircuitPlugin/src/org/workcraft/plugins/circuit/interop/VerilogImporter.java (+24/-6) CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/ExpressionParser.java (+191/-121) CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/ExpressionParser.jj (+2/-1) CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/GenlibParser.java (+266/-171) CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/GenlibParser.jj (+3/-1) CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/SubstitutionParser.java (+315/-0) CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/SubstitutionParser.jj (+100/-0) CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/SubstitutionParserConstants.java (+35/-0) CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/SubstitutionParserTokenManager.java (+399/-0) CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/VerilogParser.java (+482/-327) CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/VerilogParser.jj (+1/-1) CircuitPlugin/src/org/workcraft/plugins/circuit/serialisation/VerilogSerialiser.java (+93/-4) CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitToStgConverter.java (+3/-3) CircuitPlugin/src/org/workcraft/plugins/circuit/verilog/SubstitutionRule.java (+16/-0) WorkcraftCore/src/org/workcraft/plugins/shared/CommonDebugSettings.java (+23/-0) |
To merge this branch: | bzr merge lp:~danilovesky/workcraft/trunk-verilog-export-translate |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Danil Sokolov | Pending | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/CircuitSettings.java' | |||
2 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/CircuitSettings.java 2015-10-29 18:40:12 +0000 | |||
3 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/CircuitSettings.java 2015-11-09 09:38:45 +0000 | |||
4 | @@ -21,6 +21,7 @@ | |||
5 | 21 | private static final String keyWireWidth = prefix + ".wireWidth"; | 21 | private static final String keyWireWidth = prefix + ".wireWidth"; |
6 | 22 | private static final String keySimplifyStg = prefix + ".simplifyStg"; | 22 | private static final String keySimplifyStg = prefix + ".simplifyStg"; |
7 | 23 | private static final String keyGateLibrary = prefix + ".gateLibrary"; | 23 | private static final String keyGateLibrary = prefix + ".gateLibrary"; |
8 | 24 | private static final String keySubstitutionLibrary = prefix + ".substitutionLibrary"; | ||
9 | 24 | private static final String keyOpenSynthesisResult = prefix + ".openSynthesisResult"; | 25 | private static final String keyOpenSynthesisResult = prefix + ".openSynthesisResult"; |
10 | 25 | 26 | ||
11 | 26 | private static final boolean defaultShowContacts = false; | 27 | private static final boolean defaultShowContacts = false; |
12 | @@ -30,6 +31,7 @@ | |||
13 | 30 | private static final Double defaultWireWidth = 0.04; | 31 | private static final Double defaultWireWidth = 0.04; |
14 | 31 | private static final boolean defaultSimplifyStg = true; | 32 | private static final boolean defaultSimplifyStg = true; |
15 | 32 | private static final String defaultGateLibrary = "tools/petrify/petrify.lib"; | 33 | private static final String defaultGateLibrary = "tools/petrify/petrify.lib"; |
16 | 34 | private static final String defaultSubstitutionLibrary = ""; | ||
17 | 33 | private static final boolean defaultOpenSynthesisResult = true; | 35 | private static final boolean defaultOpenSynthesisResult = true; |
18 | 34 | 36 | ||
19 | 35 | private static boolean showContacts = defaultShowContacts; | 37 | private static boolean showContacts = defaultShowContacts; |
20 | @@ -39,6 +41,7 @@ | |||
21 | 39 | private static Double wireWidth = defaultWireWidth; | 41 | private static Double wireWidth = defaultWireWidth; |
22 | 40 | private static boolean simplifyStg = defaultSimplifyStg; | 42 | private static boolean simplifyStg = defaultSimplifyStg; |
23 | 41 | private static String gateLibrary = defaultGateLibrary; | 43 | private static String gateLibrary = defaultGateLibrary; |
24 | 44 | private static String substitutionLibrary = defaultSubstitutionLibrary; | ||
25 | 42 | private static boolean openSynthesisResult = defaultOpenSynthesisResult; | 45 | private static boolean openSynthesisResult = defaultOpenSynthesisResult; |
26 | 43 | 46 | ||
27 | 44 | public CircuitSettings() { | 47 | public CircuitSettings() { |
28 | @@ -112,6 +115,16 @@ | |||
29 | 112 | } | 115 | } |
30 | 113 | }); | 116 | }); |
31 | 114 | 117 | ||
32 | 118 | properties.add(new PropertyDeclaration<CircuitSettings, String>( | ||
33 | 119 | this, "Substitution rules for export", String.class, true, false, false) { | ||
34 | 120 | protected void setter(CircuitSettings object, String value) { | ||
35 | 121 | setSubstitutionLibrary(value); | ||
36 | 122 | } | ||
37 | 123 | protected String getter(CircuitSettings object) { | ||
38 | 124 | return getSubstitutionLibrary(); | ||
39 | 125 | } | ||
40 | 126 | }); | ||
41 | 127 | |||
42 | 115 | properties.add(new PropertyDeclaration<CircuitSettings, Boolean>( | 128 | properties.add(new PropertyDeclaration<CircuitSettings, Boolean>( |
43 | 116 | this, "Import synthesis result", Boolean.class, true, false, false) { | 129 | this, "Import synthesis result", Boolean.class, true, false, false) { |
44 | 117 | protected void setter(CircuitSettings object, Boolean value) { | 130 | protected void setter(CircuitSettings object, Boolean value) { |
45 | @@ -147,6 +160,7 @@ | |||
46 | 147 | setWireWidth(config.getDouble(keyWireWidth, defaultWireWidth)); | 160 | setWireWidth(config.getDouble(keyWireWidth, defaultWireWidth)); |
47 | 148 | setSimplifyStg(config.getBoolean(keySimplifyStg, defaultSimplifyStg)); | 161 | setSimplifyStg(config.getBoolean(keySimplifyStg, defaultSimplifyStg)); |
48 | 149 | setGateLibrary(config.getString(keyGateLibrary, defaultGateLibrary)); | 162 | setGateLibrary(config.getString(keyGateLibrary, defaultGateLibrary)); |
49 | 163 | setSubstitutionLibrary(config.getString(keySubstitutionLibrary, defaultSubstitutionLibrary)); | ||
50 | 150 | setOpenSynthesisResult(config.getBoolean(keyOpenSynthesisResult, defaultOpenSynthesisResult)); | 164 | setOpenSynthesisResult(config.getBoolean(keyOpenSynthesisResult, defaultOpenSynthesisResult)); |
51 | 151 | } | 165 | } |
52 | 152 | 166 | ||
53 | @@ -159,6 +173,7 @@ | |||
54 | 159 | config.setDouble(keyWireWidth, getWireWidth()); | 173 | config.setDouble(keyWireWidth, getWireWidth()); |
55 | 160 | config.setBoolean(keySimplifyStg, getSimplifyStg()); | 174 | config.setBoolean(keySimplifyStg, getSimplifyStg()); |
56 | 161 | config.set(keyGateLibrary, getGateLibrary()); | 175 | config.set(keyGateLibrary, getGateLibrary()); |
57 | 176 | config.set(keySubstitutionLibrary, getSubstitutionLibrary()); | ||
58 | 162 | config.setBoolean(keyOpenSynthesisResult, getOpenSynthesisResult()); | 177 | config.setBoolean(keyOpenSynthesisResult, getOpenSynthesisResult()); |
59 | 163 | } | 178 | } |
60 | 164 | 179 | ||
61 | @@ -217,6 +232,14 @@ | |||
62 | 217 | public static void setGateLibrary(String value) { | 232 | public static void setGateLibrary(String value) { |
63 | 218 | gateLibrary = value; | 233 | gateLibrary = value; |
64 | 219 | } | 234 | } |
65 | 235 | |||
66 | 236 | public static String getSubstitutionLibrary() { | ||
67 | 237 | return substitutionLibrary; | ||
68 | 238 | } | ||
69 | 239 | |||
70 | 240 | public static void setSubstitutionLibrary(String value) { | ||
71 | 241 | substitutionLibrary = value; | ||
72 | 242 | } | ||
73 | 220 | 243 | ||
74 | 221 | public static boolean getOpenSynthesisResult() { | 244 | public static boolean getOpenSynthesisResult() { |
75 | 222 | return openSynthesisResult; | 245 | return openSynthesisResult; |
76 | 223 | 246 | ||
77 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/CircuitUtils.java' | |||
78 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/CircuitUtils.java 2015-10-30 19:09:08 +0000 | |||
79 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/CircuitUtils.java 2015-11-09 09:38:45 +0000 | |||
80 | @@ -139,14 +139,14 @@ | |||
81 | 139 | return zeroDelayOutput; | 139 | return zeroDelayOutput; |
82 | 140 | } | 140 | } |
83 | 141 | 141 | ||
85 | 142 | public static Contact findSignal(Circuit circuit, Contact contact) { | 142 | public static Contact findSignal(Circuit circuit, Contact contact, boolean transparentZeroDelayComponents) { |
86 | 143 | Contact result = contact; | 143 | Contact result = contact; |
88 | 144 | Contact driver = findDriver(circuit, contact, true); | 144 | Contact driver = findDriver(circuit, contact, transparentZeroDelayComponents); |
89 | 145 | if (driver != null) { | 145 | if (driver != null) { |
90 | 146 | result = driver; | 146 | result = driver; |
91 | 147 | for (Contact signal : Hierarchy.getDescendantsOfType(circuit.getRoot(), Contact.class)) { | 147 | for (Contact signal : Hierarchy.getDescendantsOfType(circuit.getRoot(), Contact.class)) { |
92 | 148 | if (signal.isPort() && signal.isOutput()) { | 148 | if (signal.isPort() && signal.isOutput()) { |
94 | 149 | if (driver == CircuitUtils.findDriver(circuit, signal, true)) { | 149 | if (driver == CircuitUtils.findDriver(circuit, signal, transparentZeroDelayComponents)) { |
95 | 150 | result = signal; | 150 | result = signal; |
96 | 151 | break; | 151 | break; |
97 | 152 | } | 152 | } |
98 | @@ -156,15 +156,15 @@ | |||
99 | 156 | return result; | 156 | return result; |
100 | 157 | } | 157 | } |
101 | 158 | 158 | ||
104 | 159 | public static VisualContact findSignal(VisualCircuit circuit, VisualContact contact) { | 159 | public static VisualContact findSignal(VisualCircuit circuit, VisualContact contact, boolean transparentZeroDelayComponents) { |
105 | 160 | Contact mathSignal = findSignal((Circuit)circuit.getMathModel(), contact.getReferencedContact()); | 160 | Contact mathSignal = findSignal((Circuit)circuit.getMathModel(), contact.getReferencedContact(), transparentZeroDelayComponents); |
106 | 161 | return circuit.getVisualComponent(mathSignal, VisualContact.class); | 161 | return circuit.getVisualComponent(mathSignal, VisualContact.class); |
107 | 162 | } | 162 | } |
108 | 163 | 163 | ||
109 | 164 | public static String getWireName(Circuit circuit, Contact contact) { | 164 | public static String getWireName(Circuit circuit, Contact contact) { |
110 | 165 | String result = null; | 165 | String result = null; |
111 | 166 | if (!circuit.getPreset(contact).isEmpty() || !circuit.getPostset(contact).isEmpty()) { | 166 | if (!circuit.getPreset(contact).isEmpty() || !circuit.getPostset(contact).isEmpty()) { |
113 | 167 | Contact signal = findSignal(circuit, contact); | 167 | Contact signal = findSignal(circuit, contact, false); |
114 | 168 | result = getContactName(circuit, signal); | 168 | result = getContactName(circuit, signal); |
115 | 169 | } | 169 | } |
116 | 170 | return result; | 170 | return result; |
117 | 171 | 171 | ||
118 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/interop/GenlibImporter.java' | |||
119 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/interop/GenlibImporter.java 2015-07-30 15:45:39 +0000 | |||
120 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/interop/GenlibImporter.java 2015-11-09 09:38:45 +0000 | |||
121 | @@ -33,6 +33,7 @@ | |||
122 | 33 | import org.workcraft.plugins.circuit.genlib.Library; | 33 | import org.workcraft.plugins.circuit.genlib.Library; |
123 | 34 | import org.workcraft.plugins.circuit.javacc.GenlibParser; | 34 | import org.workcraft.plugins.circuit.javacc.GenlibParser; |
124 | 35 | import org.workcraft.plugins.circuit.javacc.ParseException; | 35 | import org.workcraft.plugins.circuit.javacc.ParseException; |
125 | 36 | import org.workcraft.plugins.shared.CommonDebugSettings; | ||
126 | 36 | import org.workcraft.workspace.ModelEntry; | 37 | import org.workcraft.workspace.ModelEntry; |
127 | 37 | 38 | ||
128 | 38 | public class GenlibImporter implements Importer { | 39 | public class GenlibImporter implements Importer { |
129 | @@ -54,9 +55,14 @@ | |||
130 | 54 | 55 | ||
131 | 55 | public Circuit importGenlib(InputStream in) throws DeserialisationException { | 56 | public Circuit importGenlib(InputStream in) throws DeserialisationException { |
132 | 56 | final Circuit circuit = new Circuit(); | 57 | final Circuit circuit = new Circuit(); |
134 | 57 | GenlibParser parser = new GenlibParser(in); | 58 | GenlibParser genlibParser = new GenlibParser(in); |
135 | 59 | if (CommonDebugSettings.getParserTracing()) { | ||
136 | 60 | genlibParser.enable_tracing(); | ||
137 | 61 | } else { | ||
138 | 62 | genlibParser.disable_tracing(); | ||
139 | 63 | } | ||
140 | 58 | try { | 64 | try { |
142 | 59 | Library library = parser.parseGenlib(); | 65 | Library library = genlibParser.parseGenlib(); |
143 | 60 | for (final String name: library.getNames()) { | 66 | for (final String name: library.getNames()) { |
144 | 61 | final Gate gate = library.get(name); | 67 | final Gate gate = library.get(name); |
145 | 62 | GenlibUtils.instantiateGate(gate, null, circuit); | 68 | GenlibUtils.instantiateGate(gate, null, circuit); |
146 | 63 | 69 | ||
147 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/interop/VerilogImporter.java' | |||
148 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/interop/VerilogImporter.java 2015-11-02 12:32:29 +0000 | |||
149 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/interop/VerilogImporter.java 2015-11-09 09:38:45 +0000 | |||
150 | @@ -128,8 +128,13 @@ | |||
151 | 128 | 128 | ||
152 | 129 | public Circuit importCircuit(InputStream in) throws DeserialisationException { | 129 | public Circuit importCircuit(InputStream in) throws DeserialisationException { |
153 | 130 | try { | 130 | try { |
156 | 131 | VerilogParser parser = new VerilogParser(in); | 131 | VerilogParser verilogParser = new VerilogParser(in); |
157 | 132 | HashMap<String, Module> modules = getModuleMap(parser.parseCircuit()); | 132 | if (CommonDebugSettings.getParserTracing()) { |
158 | 133 | verilogParser.enable_tracing(); | ||
159 | 134 | } else { | ||
160 | 135 | verilogParser.disable_tracing(); | ||
161 | 136 | } | ||
162 | 137 | HashMap<String, Module> modules = getModuleMap(verilogParser.parseCircuit()); | ||
163 | 133 | HashSet<Module> topModules = getTopModule(modules); | 138 | HashSet<Module> topModules = getTopModule(modules); |
164 | 134 | if (topModules.size() == 0) { | 139 | if (topModules.size() == 0) { |
165 | 135 | throw new RuntimeException("No top module found."); | 140 | throw new RuntimeException("No top module found."); |
166 | @@ -214,6 +219,7 @@ | |||
167 | 214 | 219 | ||
168 | 215 | private Circuit createCircuit(Module topModule, HashMap<String, Module> modules) { | 220 | private Circuit createCircuit(Module topModule, HashMap<String, Module> modules) { |
169 | 216 | Circuit circuit = new Circuit(); | 221 | Circuit circuit = new Circuit(); |
170 | 222 | circuit.setTitle(topModule.name); | ||
171 | 217 | HashMap<Instance, FunctionComponent> instanceComponentMap = new HashMap<>(); | 223 | HashMap<Instance, FunctionComponent> instanceComponentMap = new HashMap<>(); |
172 | 218 | HashMap<String, Wire> wires = createPorts(circuit, topModule); | 224 | HashMap<String, Wire> wires = createPorts(circuit, topModule); |
173 | 219 | for (Assign assign: topModule.assigns) { | 225 | for (Assign assign: topModule.assigns) { |
174 | @@ -363,10 +369,15 @@ | |||
175 | 363 | 369 | ||
176 | 364 | private Expression convertStringToExpression(String formula) { | 370 | private Expression convertStringToExpression(String formula) { |
177 | 365 | InputStream expressionStream = new ByteArrayInputStream(formula.getBytes()); | 371 | InputStream expressionStream = new ByteArrayInputStream(formula.getBytes()); |
179 | 366 | ExpressionParser parser = new ExpressionParser(expressionStream); | 372 | ExpressionParser expressionParser = new ExpressionParser(expressionStream); |
180 | 373 | if (CommonDebugSettings.getParserTracing()) { | ||
181 | 374 | expressionParser.enable_tracing(); | ||
182 | 375 | } else { | ||
183 | 376 | expressionParser.disable_tracing(); | ||
184 | 377 | } | ||
185 | 367 | Expression expression = null; | 378 | Expression expression = null; |
186 | 368 | try { | 379 | try { |
188 | 369 | expression = parser.parseExpression(); | 380 | expression = expressionParser.parseExpression(); |
189 | 370 | } catch (ParseException e1) { | 381 | } catch (ParseException e1) { |
190 | 371 | System.out.println("Warning: could not parse assign expression '" + formula + "'."); | 382 | System.out.println("Warning: could not parse assign expression '" + formula + "'."); |
191 | 372 | } | 383 | } |
192 | @@ -383,8 +394,15 @@ | |||
193 | 383 | final Framework framework = Framework.getInstance(); | 394 | final Framework framework = Framework.getInstance(); |
194 | 384 | if (framework.checkFile(libraryFile, "Gate library access error")) { | 395 | if (framework.checkFile(libraryFile, "Gate library access error")) { |
195 | 385 | try { | 396 | try { |
198 | 386 | InputStream genlibInputStream = new FileInputStream(CircuitSettings.getGateLibrary()); | 397 | InputStream genlibInputStream = new FileInputStream(libraryFileName); |
199 | 387 | library = new GenlibParser(genlibInputStream).parseGenlib(); | 398 | GenlibParser genlibParser = new GenlibParser(genlibInputStream); |
200 | 399 | if (CommonDebugSettings.getParserTracing()) { | ||
201 | 400 | genlibParser.enable_tracing(); | ||
202 | 401 | } else { | ||
203 | 402 | genlibParser.disable_tracing(); | ||
204 | 403 | } | ||
205 | 404 | library = genlibParser.parseGenlib(); | ||
206 | 405 | System.out.println("Info: mapping the imported Verilog into the gate library '" + libraryFileName + "'."); | ||
207 | 388 | } catch (FileNotFoundException e) { | 406 | } catch (FileNotFoundException e) { |
208 | 389 | } catch (ParseException e) { | 407 | } catch (ParseException e) { |
209 | 390 | System.out.println("Warning: could not parse the gate library '" + libraryFileName + "'."); | 408 | System.out.println("Warning: could not parse the gate library '" + libraryFileName + "'."); |
210 | 391 | 409 | ||
211 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/ExpressionParser.java' | |||
212 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/ExpressionParser.java 2015-10-22 16:04:43 +0000 | |||
213 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/ExpressionParser.java 2015-11-09 09:38:45 +0000 | |||
214 | @@ -24,172 +24,197 @@ | |||
215 | 24 | public class ExpressionParser implements ExpressionParserConstants { | 24 | public class ExpressionParser implements ExpressionParserConstants { |
216 | 25 | 25 | ||
217 | 26 | final public Expression parseExpression() throws ParseException { | 26 | final public Expression parseExpression() throws ParseException { |
218 | 27 | trace_call("parseExpression"); | ||
219 | 28 | try { | ||
220 | 27 | Expression term; | 29 | Expression term; |
221 | 28 | List<Expression> terms = new LinkedList<Expression>(); | 30 | List<Expression> terms = new LinkedList<Expression>(); |
223 | 29 | term = parseTerm(); | 31 | term = parseTerm(); |
224 | 30 | terms.add(term); | 32 | terms.add(term); |
253 | 31 | label_1: | 33 | label_1: |
254 | 32 | while (true) { | 34 | while (true) { |
255 | 33 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 35 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
256 | 34 | case 9: | 36 | case 9: |
257 | 35 | case 10: | 37 | case 10: |
258 | 36 | case 11: | 38 | case 11: |
259 | 37 | ; | 39 | ; |
260 | 38 | break; | 40 | break; |
261 | 39 | default: | 41 | default: |
262 | 40 | jj_la1[0] = jj_gen; | 42 | jj_la1[0] = jj_gen; |
263 | 41 | break label_1; | 43 | break label_1; |
264 | 42 | } | 44 | } |
265 | 43 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 45 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
266 | 44 | case 9: | 46 | case 9: |
267 | 45 | jj_consume_token(9); | 47 | jj_consume_token(9); |
268 | 46 | break; | 48 | break; |
269 | 47 | case 10: | 49 | case 10: |
270 | 48 | jj_consume_token(10); | 50 | jj_consume_token(10); |
271 | 49 | break; | 51 | break; |
272 | 50 | case 11: | 52 | case 11: |
273 | 51 | jj_consume_token(11); | 53 | jj_consume_token(11); |
274 | 52 | break; | 54 | break; |
275 | 53 | default: | 55 | default: |
276 | 54 | jj_la1[1] = jj_gen; | 56 | jj_la1[1] = jj_gen; |
277 | 55 | jj_consume_token(-1); | 57 | jj_consume_token(-1); |
278 | 56 | throw new ParseException(); | 58 | throw new ParseException(); |
279 | 57 | } | 59 | } |
280 | 58 | term = parseTerm(); | 60 | term = parseTerm(); |
281 | 59 | terms.add(term); | 61 | terms.add(term); |
283 | 60 | } | 62 | } |
284 | 61 | if (terms.size() > 1) { | 63 | if (terms.size() > 1) { |
285 | 62 | {if (true) return new Formula(terms);} | 64 | {if (true) return new Formula(terms);} |
286 | 63 | } else { | 65 | } else { |
287 | 64 | {if (true) return term;} | 66 | {if (true) return term;} |
288 | 65 | } | 67 | } |
289 | 66 | throw new Error("Missing return statement in function"); | 68 | throw new Error("Missing return statement in function"); |
290 | 69 | } finally { | ||
291 | 70 | trace_return("parseExpression"); | ||
292 | 71 | } | ||
293 | 67 | } | 72 | } |
294 | 68 | 73 | ||
295 | 69 | final public Expression parseTerm() throws ParseException { | 74 | final public Expression parseTerm() throws ParseException { |
296 | 75 | trace_call("parseTerm"); | ||
297 | 76 | try { | ||
298 | 70 | Expression factor; | 77 | Expression factor; |
299 | 71 | List<Expression> factors = new LinkedList<Expression>(); | 78 | List<Expression> factors = new LinkedList<Expression>(); |
301 | 72 | factor = parseFactor(); | 79 | factor = parseFactor(); |
302 | 73 | factors.add(factor); | 80 | factors.add(factor); |
346 | 74 | label_2: | 81 | label_2: |
347 | 75 | while (true) { | 82 | while (true) { |
348 | 76 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 83 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
349 | 77 | case CONST0: | 84 | case CONST0: |
350 | 78 | case CONST1: | 85 | case CONST1: |
351 | 79 | case NAME: | 86 | case NAME: |
352 | 80 | case 12: | 87 | case 12: |
353 | 81 | case 13: | 88 | case 13: |
354 | 82 | case 14: | 89 | case 14: |
355 | 83 | case 15: | 90 | case 15: |
356 | 84 | case 16: | 91 | case 16: |
357 | 85 | case 17: | 92 | case 17: |
358 | 86 | ; | 93 | ; |
359 | 87 | break; | 94 | break; |
360 | 88 | default: | 95 | default: |
361 | 89 | jj_la1[2] = jj_gen; | 96 | jj_la1[2] = jj_gen; |
362 | 90 | break label_2; | 97 | break label_2; |
363 | 91 | } | 98 | } |
364 | 92 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 99 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
365 | 93 | case 12: | 100 | case 12: |
366 | 94 | case 13: | 101 | case 13: |
367 | 95 | case 14: | 102 | case 14: |
368 | 96 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 103 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
369 | 97 | case 12: | 104 | case 12: |
370 | 98 | jj_consume_token(12); | 105 | jj_consume_token(12); |
371 | 99 | break; | 106 | break; |
372 | 100 | case 13: | 107 | case 13: |
373 | 101 | jj_consume_token(13); | 108 | jj_consume_token(13); |
374 | 102 | break; | 109 | break; |
375 | 103 | case 14: | 110 | case 14: |
376 | 104 | jj_consume_token(14); | 111 | jj_consume_token(14); |
377 | 105 | break; | 112 | break; |
378 | 106 | default: | 113 | default: |
379 | 107 | jj_la1[3] = jj_gen; | 114 | jj_la1[3] = jj_gen; |
380 | 108 | jj_consume_token(-1); | 115 | jj_consume_token(-1); |
381 | 109 | throw new ParseException(); | 116 | throw new ParseException(); |
382 | 110 | } | 117 | } |
383 | 111 | break; | 118 | break; |
384 | 112 | default: | 119 | default: |
385 | 113 | jj_la1[4] = jj_gen; | 120 | jj_la1[4] = jj_gen; |
386 | 114 | ; | 121 | ; |
387 | 115 | } | 122 | } |
388 | 116 | factor = parseFactor(); | 123 | factor = parseFactor(); |
389 | 117 | factors.add(factor); | 124 | factors.add(factor); |
391 | 118 | } | 125 | } |
392 | 119 | if (factors.size() > 1) { | 126 | if (factors.size() > 1) { |
393 | 120 | {if (true) return new Term(factors);} | 127 | {if (true) return new Term(factors);} |
394 | 121 | } else { | 128 | } else { |
395 | 122 | {if (true) return factor;} | 129 | {if (true) return factor;} |
396 | 123 | } | 130 | } |
397 | 124 | throw new Error("Missing return statement in function"); | 131 | throw new Error("Missing return statement in function"); |
398 | 132 | } finally { | ||
399 | 133 | trace_return("parseTerm"); | ||
400 | 134 | } | ||
401 | 125 | } | 135 | } |
402 | 126 | 136 | ||
403 | 127 | final public Expression parseFactor() throws ParseException { | 137 | final public Expression parseFactor() throws ParseException { |
404 | 138 | trace_call("parseFactor"); | ||
405 | 139 | try { | ||
406 | 128 | Expression expression; | 140 | Expression expression; |
407 | 129 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | ||
408 | 130 | case NAME: | ||
409 | 131 | expression = parseLiteral(); | ||
410 | 132 | break; | ||
411 | 133 | case CONST0: | ||
412 | 134 | case CONST1: | ||
413 | 135 | expression = parseConstant(); | ||
414 | 136 | break; | ||
415 | 137 | case 15: | ||
416 | 138 | case 16: | ||
417 | 139 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 141 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
418 | 142 | case NAME: | ||
419 | 143 | expression = parseLiteral(); | ||
420 | 144 | break; | ||
421 | 145 | case CONST0: | ||
422 | 146 | case CONST1: | ||
423 | 147 | expression = parseConstant(); | ||
424 | 148 | break; | ||
425 | 140 | case 15: | 149 | case 15: |
426 | 141 | jj_consume_token(15); | ||
427 | 142 | break; | ||
428 | 143 | case 16: | 150 | case 16: |
437 | 144 | jj_consume_token(16); | 151 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
438 | 145 | break; | 152 | case 15: |
439 | 146 | default: | 153 | jj_consume_token(15); |
440 | 147 | jj_la1[5] = jj_gen; | 154 | break; |
441 | 148 | jj_consume_token(-1); | 155 | case 16: |
442 | 149 | throw new ParseException(); | 156 | jj_consume_token(16); |
443 | 150 | } | 157 | break; |
444 | 151 | expression = parseFactor(); | 158 | default: |
445 | 159 | jj_la1[5] = jj_gen; | ||
446 | 160 | jj_consume_token(-1); | ||
447 | 161 | throw new ParseException(); | ||
448 | 162 | } | ||
449 | 163 | expression = parseFactor(); | ||
450 | 152 | {if (true) return new Negation(expression);} | 164 | {if (true) return new Negation(expression);} |
456 | 153 | break; | 165 | break; |
457 | 154 | case 17: | 166 | case 17: |
458 | 155 | jj_consume_token(17); | 167 | jj_consume_token(17); |
459 | 156 | expression = parseExpression(); | 168 | expression = parseExpression(); |
460 | 157 | jj_consume_token(18); | 169 | jj_consume_token(18); |
461 | 158 | {if (true) return new Factor(expression);} | 170 | {if (true) return new Factor(expression);} |
468 | 159 | break; | 171 | break; |
469 | 160 | default: | 172 | default: |
470 | 161 | jj_la1[6] = jj_gen; | 173 | jj_la1[6] = jj_gen; |
471 | 162 | jj_consume_token(-1); | 174 | jj_consume_token(-1); |
472 | 163 | throw new ParseException(); | 175 | throw new ParseException(); |
473 | 164 | } | 176 | } |
474 | 165 | {if (true) return expression;} | 177 | {if (true) return expression;} |
475 | 166 | throw new Error("Missing return statement in function"); | 178 | throw new Error("Missing return statement in function"); |
476 | 179 | } finally { | ||
477 | 180 | trace_return("parseFactor"); | ||
478 | 181 | } | ||
479 | 167 | } | 182 | } |
480 | 168 | 183 | ||
481 | 169 | final public Expression parseLiteral() throws ParseException { | 184 | final public Expression parseLiteral() throws ParseException { |
482 | 185 | trace_call("parseLiteral"); | ||
483 | 186 | try { | ||
484 | 170 | Token nameToken; | 187 | Token nameToken; |
486 | 171 | nameToken = jj_consume_token(NAME); | 188 | nameToken = jj_consume_token(NAME); |
487 | 172 | String name = nameToken.image; | 189 | String name = nameToken.image; |
488 | 173 | {if (true) return new Literal(name);} | 190 | {if (true) return new Literal(name);} |
489 | 174 | throw new Error("Missing return statement in function"); | 191 | throw new Error("Missing return statement in function"); |
490 | 192 | } finally { | ||
491 | 193 | trace_return("parseLiteral"); | ||
492 | 194 | } | ||
493 | 175 | } | 195 | } |
494 | 176 | 196 | ||
495 | 177 | final public Expression parseConstant() throws ParseException { | 197 | final public Expression parseConstant() throws ParseException { |
499 | 178 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 198 | trace_call("parseConstant"); |
500 | 179 | case CONST0: | 199 | try { |
501 | 180 | jj_consume_token(CONST0); | 200 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
502 | 201 | case CONST0: | ||
503 | 202 | jj_consume_token(CONST0); | ||
504 | 181 | {if (true) return new Constant(false);} | 203 | {if (true) return new Constant(false);} |
508 | 182 | break; | 204 | break; |
509 | 183 | case CONST1: | 205 | case CONST1: |
510 | 184 | jj_consume_token(CONST1); | 206 | jj_consume_token(CONST1); |
511 | 185 | {if (true) return new Constant(true);} | 207 | {if (true) return new Constant(true);} |
517 | 186 | break; | 208 | break; |
518 | 187 | default: | 209 | default: |
519 | 188 | jj_la1[7] = jj_gen; | 210 | jj_la1[7] = jj_gen; |
520 | 189 | jj_consume_token(-1); | 211 | jj_consume_token(-1); |
521 | 190 | throw new ParseException(); | 212 | throw new ParseException(); |
522 | 213 | } | ||
523 | 214 | throw new Error("Missing return statement in function"); | ||
524 | 215 | } finally { | ||
525 | 216 | trace_return("parseConstant"); | ||
526 | 191 | } | 217 | } |
527 | 192 | throw new Error("Missing return statement in function"); | ||
528 | 193 | } | 218 | } |
529 | 194 | 219 | ||
530 | 195 | /** Generated Token Manager. */ | 220 | /** Generated Token Manager. */ |
531 | @@ -283,6 +308,7 @@ | |||
532 | 283 | jj_ntk = -1; | 308 | jj_ntk = -1; |
533 | 284 | if (token.kind == kind) { | 309 | if (token.kind == kind) { |
534 | 285 | jj_gen++; | 310 | jj_gen++; |
535 | 311 | trace_token(token, ""); | ||
536 | 286 | return token; | 312 | return token; |
537 | 287 | } | 313 | } |
538 | 288 | token = oldToken; | 314 | token = oldToken; |
539 | @@ -297,6 +323,7 @@ | |||
540 | 297 | else token = token.next = token_source.getNextToken(); | 323 | else token = token.next = token_source.getNextToken(); |
541 | 298 | jj_ntk = -1; | 324 | jj_ntk = -1; |
542 | 299 | jj_gen++; | 325 | jj_gen++; |
543 | 326 | trace_token(token, " (in getNextToken)"); | ||
544 | 300 | return token; | 327 | return token; |
545 | 301 | } | 328 | } |
546 | 302 | 329 | ||
547 | @@ -352,12 +379,55 @@ | |||
548 | 352 | return new ParseException(token, exptokseq, tokenImage); | 379 | return new ParseException(token, exptokseq, tokenImage); |
549 | 353 | } | 380 | } |
550 | 354 | 381 | ||
552 | 355 | /** Enable tracing. */ | 382 | private int trace_indent = 0; |
553 | 383 | private boolean trace_enabled = true; | ||
554 | 384 | |||
555 | 385 | /** Enable tracing. */ | ||
556 | 356 | final public void enable_tracing() { | 386 | final public void enable_tracing() { |
557 | 387 | trace_enabled = true; | ||
558 | 357 | } | 388 | } |
559 | 358 | 389 | ||
561 | 359 | /** Disable tracing. */ | 390 | /** Disable tracing. */ |
562 | 360 | final public void disable_tracing() { | 391 | final public void disable_tracing() { |
563 | 392 | trace_enabled = false; | ||
564 | 393 | } | ||
565 | 394 | |||
566 | 395 | private void trace_call(String s) { | ||
567 | 396 | if (trace_enabled) { | ||
568 | 397 | for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } | ||
569 | 398 | System.out.println("Call: " + s); | ||
570 | 399 | } | ||
571 | 400 | trace_indent = trace_indent + 2; | ||
572 | 401 | } | ||
573 | 402 | |||
574 | 403 | private void trace_return(String s) { | ||
575 | 404 | trace_indent = trace_indent - 2; | ||
576 | 405 | if (trace_enabled) { | ||
577 | 406 | for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } | ||
578 | 407 | System.out.println("Return: " + s); | ||
579 | 408 | } | ||
580 | 409 | } | ||
581 | 410 | |||
582 | 411 | private void trace_token(Token t, String where) { | ||
583 | 412 | if (trace_enabled) { | ||
584 | 413 | for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } | ||
585 | 414 | System.out.print("Consumed token: <" + tokenImage[t.kind]); | ||
586 | 415 | if (t.kind != 0 && !tokenImage[t.kind].equals("\"" + t.image + "\"")) { | ||
587 | 416 | System.out.print(": \"" + t.image + "\""); | ||
588 | 417 | } | ||
589 | 418 | System.out.println(" at line " + t.beginLine + " column " + t.beginColumn + ">" + where); | ||
590 | 419 | } | ||
591 | 420 | } | ||
592 | 421 | |||
593 | 422 | private void trace_scan(Token t1, int t2) { | ||
594 | 423 | if (trace_enabled) { | ||
595 | 424 | for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } | ||
596 | 425 | System.out.print("Visited token: <" + tokenImage[t1.kind]); | ||
597 | 426 | if (t1.kind != 0 && !tokenImage[t1.kind].equals("\"" + t1.image + "\"")) { | ||
598 | 427 | System.out.print(": \"" + t1.image + "\""); | ||
599 | 428 | } | ||
600 | 429 | System.out.println(" at line " + t1.beginLine + " column " + t1.beginColumn + ">; Expected token: <" + tokenImage[t2] + ">"); | ||
601 | 430 | } | ||
602 | 361 | } | 431 | } |
603 | 362 | 432 | ||
604 | 363 | } | 433 | } |
605 | 364 | 434 | ||
606 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/ExpressionParser.jj' | |||
607 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/ExpressionParser.jj 2015-10-22 16:04:43 +0000 | |||
608 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/ExpressionParser.jj 2015-11-09 09:38:45 +0000 | |||
609 | @@ -6,7 +6,8 @@ | |||
610 | 6 | JDK_VERSION = "1.7"; | 6 | JDK_VERSION = "1.7"; |
611 | 7 | LOOKAHEAD = 1; | 7 | LOOKAHEAD = 1; |
612 | 8 | STATIC = false; | 8 | STATIC = false; |
614 | 9 | DEBUG_PARSER = false; | 9 | DEBUG_PARSER = true; |
615 | 10 | DEBUG_LOOKAHEAD = false; | ||
616 | 10 | DEBUG_TOKEN_MANAGER = false; | 11 | DEBUG_TOKEN_MANAGER = false; |
617 | 11 | } | 12 | } |
618 | 12 | 13 | ||
619 | 13 | 14 | ||
620 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/GenlibParser.java' | |||
621 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/GenlibParser.java 2015-10-19 17:34:06 +0000 | |||
622 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/GenlibParser.java 2015-11-09 09:38:45 +0000 | |||
623 | @@ -20,241 +20,291 @@ | |||
624 | 20 | public class GenlibParser implements GenlibParserConstants { | 20 | public class GenlibParser implements GenlibParserConstants { |
625 | 21 | 21 | ||
626 | 22 | final public Library parseGenlib() throws ParseException { | 22 | final public Library parseGenlib() throws ParseException { |
627 | 23 | trace_call("parseGenlib"); | ||
628 | 24 | try { | ||
629 | 23 | List<Gate> gates; | 25 | List<Gate> gates; |
631 | 24 | gates = parseGates(); | 26 | gates = parseGates(); |
632 | 25 | {if (true) return new Library(gates);} | 27 | {if (true) return new Library(gates);} |
633 | 26 | throw new Error("Missing return statement in function"); | 28 | throw new Error("Missing return statement in function"); |
634 | 29 | } finally { | ||
635 | 30 | trace_return("parseGenlib"); | ||
636 | 31 | } | ||
637 | 27 | } | 32 | } |
638 | 28 | 33 | ||
639 | 29 | final public List<Gate> parseGates() throws ParseException { | 34 | final public List<Gate> parseGates() throws ParseException { |
640 | 35 | trace_call("parseGates"); | ||
641 | 36 | try { | ||
642 | 30 | Gate gate; | 37 | Gate gate; |
643 | 31 | List<Gate> gates = new LinkedList<Gate>(); | 38 | List<Gate> gates = new LinkedList<Gate>(); |
667 | 32 | label_1: | 39 | label_1: |
668 | 33 | while (true) { | 40 | while (true) { |
669 | 34 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 41 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
670 | 35 | case GATE: | 42 | case GATE: |
671 | 36 | case LATCH: | 43 | case LATCH: |
672 | 37 | ; | 44 | ; |
673 | 38 | break; | 45 | break; |
674 | 39 | default: | 46 | default: |
675 | 40 | jj_la1[0] = jj_gen; | 47 | jj_la1[0] = jj_gen; |
676 | 41 | break label_1; | 48 | break label_1; |
677 | 42 | } | 49 | } |
678 | 43 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 50 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
679 | 44 | case GATE: | 51 | case GATE: |
680 | 45 | gate = parseGate(); | 52 | gate = parseGate(); |
681 | 46 | break; | 53 | break; |
682 | 47 | case LATCH: | 54 | case LATCH: |
683 | 48 | gate = parseLatch(); | 55 | gate = parseLatch(); |
684 | 49 | break; | 56 | break; |
685 | 50 | default: | 57 | default: |
686 | 51 | jj_la1[1] = jj_gen; | 58 | jj_la1[1] = jj_gen; |
687 | 52 | jj_consume_token(-1); | 59 | jj_consume_token(-1); |
688 | 53 | throw new ParseException(); | 60 | throw new ParseException(); |
689 | 54 | } | 61 | } |
690 | 55 | gates.add(gate); | 62 | gates.add(gate); |
692 | 56 | } | 63 | } |
693 | 57 | {if (true) return gates;} | 64 | {if (true) return gates;} |
694 | 58 | throw new Error("Missing return statement in function"); | 65 | throw new Error("Missing return statement in function"); |
695 | 66 | } finally { | ||
696 | 67 | trace_return("parseGates"); | ||
697 | 68 | } | ||
698 | 59 | } | 69 | } |
699 | 60 | 70 | ||
700 | 61 | final public Gate parseGate() throws ParseException { | 71 | final public Gate parseGate() throws ParseException { |
701 | 72 | trace_call("parseGate"); | ||
702 | 73 | try { | ||
703 | 62 | String name; | 74 | String name; |
704 | 63 | Function function; | 75 | Function function; |
718 | 64 | jj_consume_token(GATE); | 76 | jj_consume_token(GATE); |
719 | 65 | name = parseName(); | 77 | name = parseName(); |
720 | 66 | jj_consume_token(NUMERAL); | 78 | jj_consume_token(NUMERAL); |
721 | 67 | function = parseFunction(); | 79 | function = parseFunction(); |
722 | 68 | label_2: | 80 | label_2: |
723 | 69 | while (true) { | 81 | while (true) { |
724 | 70 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 82 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
725 | 71 | case PIN: | 83 | case PIN: |
726 | 72 | ; | 84 | ; |
727 | 73 | break; | 85 | break; |
728 | 74 | default: | 86 | default: |
729 | 75 | jj_la1[2] = jj_gen; | 87 | jj_la1[2] = jj_gen; |
730 | 76 | break label_2; | 88 | break label_2; |
731 | 89 | } | ||
732 | 90 | parsePin(); | ||
733 | 77 | } | 91 | } |
734 | 78 | parsePin(); | ||
735 | 79 | } | ||
736 | 80 | {if (true) return new Gate(name, function, null, false);} | 92 | {if (true) return new Gate(name, function, null, false);} |
737 | 81 | throw new Error("Missing return statement in function"); | 93 | throw new Error("Missing return statement in function"); |
738 | 94 | } finally { | ||
739 | 95 | trace_return("parseGate"); | ||
740 | 96 | } | ||
741 | 82 | } | 97 | } |
742 | 83 | 98 | ||
743 | 84 | final public Gate parseLatch() throws ParseException { | 99 | final public Gate parseLatch() throws ParseException { |
744 | 100 | trace_call("parseLatch"); | ||
745 | 101 | try { | ||
746 | 85 | String name; | 102 | String name; |
747 | 86 | Function function; | 103 | Function function; |
748 | 87 | String next; | 104 | String next; |
782 | 88 | jj_consume_token(LATCH); | 105 | jj_consume_token(LATCH); |
783 | 89 | name = parseName(); | 106 | name = parseName(); |
784 | 90 | jj_consume_token(NUMERAL); | 107 | jj_consume_token(NUMERAL); |
785 | 91 | function = parseFunction(); | 108 | function = parseFunction(); |
786 | 92 | label_3: | 109 | label_3: |
787 | 93 | while (true) { | 110 | while (true) { |
788 | 94 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 111 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
789 | 95 | case PIN: | 112 | case PIN: |
790 | 96 | ; | 113 | ; |
791 | 97 | break; | 114 | break; |
792 | 98 | default: | 115 | default: |
793 | 99 | jj_la1[3] = jj_gen; | 116 | jj_la1[3] = jj_gen; |
794 | 100 | break label_3; | 117 | break label_3; |
795 | 101 | } | 118 | } |
796 | 102 | parsePin(); | 119 | parsePin(); |
797 | 103 | } | 120 | } |
798 | 104 | next = parseSeq(); | 121 | next = parseSeq(); |
799 | 105 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 122 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
800 | 106 | case CONTROL: | 123 | case CONTROL: |
801 | 107 | parseControl(); | 124 | parseControl(); |
802 | 108 | break; | 125 | break; |
803 | 109 | default: | 126 | default: |
804 | 110 | jj_la1[4] = jj_gen; | 127 | jj_la1[4] = jj_gen; |
805 | 111 | ; | 128 | ; |
806 | 112 | } | 129 | } |
807 | 113 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 130 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
808 | 114 | case CONSTRAINT: | 131 | case CONSTRAINT: |
809 | 115 | parseConstraint(); | 132 | parseConstraint(); |
810 | 116 | break; | 133 | break; |
811 | 117 | default: | 134 | default: |
812 | 118 | jj_la1[5] = jj_gen; | 135 | jj_la1[5] = jj_gen; |
813 | 119 | ; | 136 | ; |
814 | 120 | } | 137 | } |
815 | 121 | {if (true) return new Gate(name, function, next, false);} | 138 | {if (true) return new Gate(name, function, next, false);} |
816 | 122 | throw new Error("Missing return statement in function"); | 139 | throw new Error("Missing return statement in function"); |
817 | 140 | } finally { | ||
818 | 141 | trace_return("parseLatch"); | ||
819 | 142 | } | ||
820 | 123 | } | 143 | } |
821 | 124 | 144 | ||
822 | 125 | final public String parseName() throws ParseException { | 145 | final public String parseName() throws ParseException { |
823 | 146 | trace_call("parseName"); | ||
824 | 147 | try { | ||
825 | 126 | Token nameToken; | 148 | Token nameToken; |
829 | 127 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 149 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
830 | 128 | case NAME: | 150 | case NAME: |
831 | 129 | nameToken = jj_consume_token(NAME); | 151 | nameToken = jj_consume_token(NAME); |
832 | 130 | {if (true) return nameToken.image;} | 152 | {if (true) return nameToken.image;} |
836 | 131 | break; | 153 | break; |
837 | 132 | case STRING: | 154 | case STRING: |
838 | 133 | nameToken = jj_consume_token(STRING); | 155 | nameToken = jj_consume_token(STRING); |
839 | 134 | String s = nameToken.image; | 156 | String s = nameToken.image; |
840 | 135 | {if (true) return s.substring(1, s.length()-1);} | 157 | {if (true) return s.substring(1, s.length()-1);} |
846 | 136 | break; | 158 | break; |
847 | 137 | default: | 159 | default: |
848 | 138 | jj_la1[6] = jj_gen; | 160 | jj_la1[6] = jj_gen; |
849 | 139 | jj_consume_token(-1); | 161 | jj_consume_token(-1); |
850 | 140 | throw new ParseException(); | 162 | throw new ParseException(); |
851 | 163 | } | ||
852 | 164 | throw new Error("Missing return statement in function"); | ||
853 | 165 | } finally { | ||
854 | 166 | trace_return("parseName"); | ||
855 | 141 | } | 167 | } |
856 | 142 | throw new Error("Missing return statement in function"); | ||
857 | 143 | } | 168 | } |
858 | 144 | 169 | ||
859 | 145 | final public Function parseFunction() throws ParseException { | 170 | final public Function parseFunction() throws ParseException { |
860 | 171 | trace_call("parseFunction"); | ||
861 | 172 | try { | ||
862 | 146 | Token nameToken; | 173 | Token nameToken; |
863 | 147 | Token formulaToken; | 174 | Token formulaToken; |
866 | 148 | nameToken = jj_consume_token(NAME); | 175 | nameToken = jj_consume_token(NAME); |
867 | 149 | formulaToken = jj_consume_token(FORMULA); | 176 | formulaToken = jj_consume_token(FORMULA); |
868 | 150 | String formula = formulaToken.image.replaceAll("^=", "").replaceAll(";$", ""); | 177 | String formula = formulaToken.image.replaceAll("^=", "").replaceAll(";$", ""); |
869 | 151 | {if (true) return new Function(nameToken.image, formula);} | 178 | {if (true) return new Function(nameToken.image, formula);} |
870 | 152 | throw new Error("Missing return statement in function"); | 179 | throw new Error("Missing return statement in function"); |
871 | 180 | } finally { | ||
872 | 181 | trace_return("parseFunction"); | ||
873 | 182 | } | ||
874 | 153 | } | 183 | } |
875 | 154 | 184 | ||
876 | 155 | final public void parsePin() throws ParseException { | 185 | final public void parsePin() throws ParseException { |
894 | 156 | jj_consume_token(PIN); | 186 | trace_call("parsePin"); |
895 | 157 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 187 | try { |
896 | 158 | case NAME: | 188 | jj_consume_token(PIN); |
897 | 159 | jj_consume_token(NAME); | 189 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
898 | 160 | break; | 190 | case NAME: |
899 | 161 | case ANY_NAME: | 191 | jj_consume_token(NAME); |
900 | 162 | jj_consume_token(ANY_NAME); | 192 | break; |
901 | 163 | break; | 193 | case ANY_NAME: |
902 | 164 | default: | 194 | jj_consume_token(ANY_NAME); |
903 | 165 | jj_la1[7] = jj_gen; | 195 | break; |
904 | 166 | jj_consume_token(-1); | 196 | default: |
905 | 167 | throw new ParseException(); | 197 | jj_la1[7] = jj_gen; |
906 | 168 | } | 198 | jj_consume_token(-1); |
907 | 169 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 199 | throw new ParseException(); |
908 | 170 | case INV: | 200 | } |
892 | 171 | case NONINV: | ||
893 | 172 | case UNKNOWN: | ||
909 | 173 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 201 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
910 | 174 | case INV: | 202 | case INV: |
911 | 175 | jj_consume_token(INV); | ||
912 | 176 | break; | ||
913 | 177 | case NONINV: | 203 | case NONINV: |
914 | 178 | jj_consume_token(NONINV); | ||
915 | 179 | break; | ||
916 | 180 | case UNKNOWN: | 204 | case UNKNOWN: |
918 | 181 | jj_consume_token(UNKNOWN); | 205 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
919 | 206 | case INV: | ||
920 | 207 | jj_consume_token(INV); | ||
921 | 208 | break; | ||
922 | 209 | case NONINV: | ||
923 | 210 | jj_consume_token(NONINV); | ||
924 | 211 | break; | ||
925 | 212 | case UNKNOWN: | ||
926 | 213 | jj_consume_token(UNKNOWN); | ||
927 | 214 | break; | ||
928 | 215 | default: | ||
929 | 216 | jj_la1[8] = jj_gen; | ||
930 | 217 | jj_consume_token(-1); | ||
931 | 218 | throw new ParseException(); | ||
932 | 219 | } | ||
933 | 182 | break; | 220 | break; |
934 | 183 | default: | 221 | default: |
938 | 184 | jj_la1[8] = jj_gen; | 222 | jj_la1[9] = jj_gen; |
939 | 185 | jj_consume_token(-1); | 223 | ; |
937 | 186 | throw new ParseException(); | ||
940 | 187 | } | 224 | } |
945 | 188 | break; | 225 | jj_consume_token(NUMERAL); |
946 | 189 | default: | 226 | jj_consume_token(NUMERAL); |
947 | 190 | jj_la1[9] = jj_gen; | 227 | jj_consume_token(NUMERAL); |
948 | 191 | ; | 228 | jj_consume_token(NUMERAL); |
949 | 229 | jj_consume_token(NUMERAL); | ||
950 | 230 | jj_consume_token(NUMERAL); | ||
951 | 231 | } finally { | ||
952 | 232 | trace_return("parsePin"); | ||
953 | 192 | } | 233 | } |
954 | 193 | jj_consume_token(NUMERAL); | ||
955 | 194 | jj_consume_token(NUMERAL); | ||
956 | 195 | jj_consume_token(NUMERAL); | ||
957 | 196 | jj_consume_token(NUMERAL); | ||
958 | 197 | jj_consume_token(NUMERAL); | ||
959 | 198 | jj_consume_token(NUMERAL); | ||
960 | 199 | } | 234 | } |
961 | 200 | 235 | ||
962 | 201 | final public String parseSeq() throws ParseException { | 236 | final public String parseSeq() throws ParseException { |
963 | 237 | trace_call("parseSeq"); | ||
964 | 238 | try { | ||
965 | 202 | Token nextToken = null; | 239 | Token nextToken = null; |
1001 | 203 | jj_consume_token(SEQ); | 240 | jj_consume_token(SEQ); |
1002 | 204 | jj_consume_token(NAME); | 241 | jj_consume_token(NAME); |
1003 | 205 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 242 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
1004 | 206 | case NAME: | 243 | case NAME: |
1005 | 207 | nextToken = jj_consume_token(NAME); | 244 | nextToken = jj_consume_token(NAME); |
1006 | 208 | break; | 245 | break; |
1007 | 209 | case ANY: | 246 | case ANY: |
1008 | 210 | jj_consume_token(ANY); | 247 | jj_consume_token(ANY); |
1009 | 211 | break; | 248 | break; |
1010 | 212 | default: | 249 | default: |
1011 | 213 | jj_la1[10] = jj_gen; | 250 | jj_la1[10] = jj_gen; |
1012 | 214 | jj_consume_token(-1); | 251 | jj_consume_token(-1); |
1013 | 215 | throw new ParseException(); | 252 | throw new ParseException(); |
1014 | 216 | } | 253 | } |
1015 | 217 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 254 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
1016 | 218 | case ACTIVE_LOW: | 255 | case ACTIVE_LOW: |
1017 | 219 | jj_consume_token(ACTIVE_LOW); | 256 | jj_consume_token(ACTIVE_LOW); |
1018 | 220 | break; | 257 | break; |
1019 | 221 | case ACTIVE_HIGH: | 258 | case ACTIVE_HIGH: |
1020 | 222 | jj_consume_token(ACTIVE_HIGH); | 259 | jj_consume_token(ACTIVE_HIGH); |
1021 | 223 | break; | 260 | break; |
1022 | 224 | case RISING_EDGE: | 261 | case RISING_EDGE: |
1023 | 225 | jj_consume_token(RISING_EDGE); | 262 | jj_consume_token(RISING_EDGE); |
1024 | 226 | break; | 263 | break; |
1025 | 227 | case FALLING_EDGE: | 264 | case FALLING_EDGE: |
1026 | 228 | jj_consume_token(FALLING_EDGE); | 265 | jj_consume_token(FALLING_EDGE); |
1027 | 229 | break; | 266 | break; |
1028 | 230 | case ASYNCH: | 267 | case ASYNCH: |
1029 | 231 | jj_consume_token(ASYNCH); | 268 | jj_consume_token(ASYNCH); |
1030 | 232 | break; | 269 | break; |
1031 | 233 | default: | 270 | default: |
1032 | 234 | jj_la1[11] = jj_gen; | 271 | jj_la1[11] = jj_gen; |
1033 | 235 | jj_consume_token(-1); | 272 | jj_consume_token(-1); |
1034 | 236 | throw new ParseException(); | 273 | throw new ParseException(); |
1035 | 237 | } | 274 | } |
1036 | 238 | {if (true) return ((nextToken == null) ? null : nextToken.image);} | 275 | {if (true) return ((nextToken == null) ? null : nextToken.image);} |
1037 | 239 | throw new Error("Missing return statement in function"); | 276 | throw new Error("Missing return statement in function"); |
1038 | 277 | } finally { | ||
1039 | 278 | trace_return("parseSeq"); | ||
1040 | 279 | } | ||
1041 | 240 | } | 280 | } |
1042 | 241 | 281 | ||
1043 | 242 | final public void parseControl() throws ParseException { | 282 | final public void parseControl() throws ParseException { |
1052 | 243 | jj_consume_token(CONTROL); | 283 | trace_call("parseControl"); |
1053 | 244 | jj_consume_token(NAME); | 284 | try { |
1054 | 245 | jj_consume_token(NUMERAL); | 285 | jj_consume_token(CONTROL); |
1055 | 246 | jj_consume_token(NUMERAL); | 286 | jj_consume_token(NAME); |
1056 | 247 | jj_consume_token(NUMERAL); | 287 | jj_consume_token(NUMERAL); |
1057 | 248 | jj_consume_token(NUMERAL); | 288 | jj_consume_token(NUMERAL); |
1058 | 249 | jj_consume_token(NUMERAL); | 289 | jj_consume_token(NUMERAL); |
1059 | 250 | jj_consume_token(NUMERAL); | 290 | jj_consume_token(NUMERAL); |
1060 | 291 | jj_consume_token(NUMERAL); | ||
1061 | 292 | jj_consume_token(NUMERAL); | ||
1062 | 293 | } finally { | ||
1063 | 294 | trace_return("parseControl"); | ||
1064 | 295 | } | ||
1065 | 251 | } | 296 | } |
1066 | 252 | 297 | ||
1067 | 253 | final public void parseConstraint() throws ParseException { | 298 | final public void parseConstraint() throws ParseException { |
1072 | 254 | jj_consume_token(CONSTRAINT); | 299 | trace_call("parseConstraint"); |
1073 | 255 | jj_consume_token(NAME); | 300 | try { |
1074 | 256 | jj_consume_token(NUMERAL); | 301 | jj_consume_token(CONSTRAINT); |
1075 | 257 | jj_consume_token(NUMERAL); | 302 | jj_consume_token(NAME); |
1076 | 303 | jj_consume_token(NUMERAL); | ||
1077 | 304 | jj_consume_token(NUMERAL); | ||
1078 | 305 | } finally { | ||
1079 | 306 | trace_return("parseConstraint"); | ||
1080 | 307 | } | ||
1081 | 258 | } | 308 | } |
1082 | 259 | 309 | ||
1083 | 260 | /** Generated Token Manager. */ | 310 | /** Generated Token Manager. */ |
1084 | @@ -348,6 +398,7 @@ | |||
1085 | 348 | jj_ntk = -1; | 398 | jj_ntk = -1; |
1086 | 349 | if (token.kind == kind) { | 399 | if (token.kind == kind) { |
1087 | 350 | jj_gen++; | 400 | jj_gen++; |
1088 | 401 | trace_token(token, ""); | ||
1089 | 351 | return token; | 402 | return token; |
1090 | 352 | } | 403 | } |
1091 | 353 | token = oldToken; | 404 | token = oldToken; |
1092 | @@ -362,6 +413,7 @@ | |||
1093 | 362 | else token = token.next = token_source.getNextToken(); | 413 | else token = token.next = token_source.getNextToken(); |
1094 | 363 | jj_ntk = -1; | 414 | jj_ntk = -1; |
1095 | 364 | jj_gen++; | 415 | jj_gen++; |
1096 | 416 | trace_token(token, " (in getNextToken)"); | ||
1097 | 365 | return token; | 417 | return token; |
1098 | 366 | } | 418 | } |
1099 | 367 | 419 | ||
1100 | @@ -417,12 +469,55 @@ | |||
1101 | 417 | return new ParseException(token, exptokseq, tokenImage); | 469 | return new ParseException(token, exptokseq, tokenImage); |
1102 | 418 | } | 470 | } |
1103 | 419 | 471 | ||
1105 | 420 | /** Enable tracing. */ | 472 | private int trace_indent = 0; |
1106 | 473 | private boolean trace_enabled = true; | ||
1107 | 474 | |||
1108 | 475 | /** Enable tracing. */ | ||
1109 | 421 | final public void enable_tracing() { | 476 | final public void enable_tracing() { |
1110 | 477 | trace_enabled = true; | ||
1111 | 422 | } | 478 | } |
1112 | 423 | 479 | ||
1114 | 424 | /** Disable tracing. */ | 480 | /** Disable tracing. */ |
1115 | 425 | final public void disable_tracing() { | 481 | final public void disable_tracing() { |
1116 | 482 | trace_enabled = false; | ||
1117 | 483 | } | ||
1118 | 484 | |||
1119 | 485 | private void trace_call(String s) { | ||
1120 | 486 | if (trace_enabled) { | ||
1121 | 487 | for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } | ||
1122 | 488 | System.out.println("Call: " + s); | ||
1123 | 489 | } | ||
1124 | 490 | trace_indent = trace_indent + 2; | ||
1125 | 491 | } | ||
1126 | 492 | |||
1127 | 493 | private void trace_return(String s) { | ||
1128 | 494 | trace_indent = trace_indent - 2; | ||
1129 | 495 | if (trace_enabled) { | ||
1130 | 496 | for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } | ||
1131 | 497 | System.out.println("Return: " + s); | ||
1132 | 498 | } | ||
1133 | 499 | } | ||
1134 | 500 | |||
1135 | 501 | private void trace_token(Token t, String where) { | ||
1136 | 502 | if (trace_enabled) { | ||
1137 | 503 | for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } | ||
1138 | 504 | System.out.print("Consumed token: <" + tokenImage[t.kind]); | ||
1139 | 505 | if (t.kind != 0 && !tokenImage[t.kind].equals("\"" + t.image + "\"")) { | ||
1140 | 506 | System.out.print(": \"" + t.image + "\""); | ||
1141 | 507 | } | ||
1142 | 508 | System.out.println(" at line " + t.beginLine + " column " + t.beginColumn + ">" + where); | ||
1143 | 509 | } | ||
1144 | 510 | } | ||
1145 | 511 | |||
1146 | 512 | private void trace_scan(Token t1, int t2) { | ||
1147 | 513 | if (trace_enabled) { | ||
1148 | 514 | for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } | ||
1149 | 515 | System.out.print("Visited token: <" + tokenImage[t1.kind]); | ||
1150 | 516 | if (t1.kind != 0 && !tokenImage[t1.kind].equals("\"" + t1.image + "\"")) { | ||
1151 | 517 | System.out.print(": \"" + t1.image + "\""); | ||
1152 | 518 | } | ||
1153 | 519 | System.out.println(" at line " + t1.beginLine + " column " + t1.beginColumn + ">; Expected token: <" + tokenImage[t2] + ">"); | ||
1154 | 520 | } | ||
1155 | 426 | } | 521 | } |
1156 | 427 | 522 | ||
1157 | 428 | } | 523 | } |
1158 | 429 | 524 | ||
1159 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/GenlibParser.jj' | |||
1160 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/GenlibParser.jj 2015-10-19 17:34:06 +0000 | |||
1161 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/GenlibParser.jj 2015-11-09 09:38:45 +0000 | |||
1162 | @@ -6,7 +6,9 @@ | |||
1163 | 6 | JDK_VERSION = "1.7"; | 6 | JDK_VERSION = "1.7"; |
1164 | 7 | LOOKAHEAD = 1; | 7 | LOOKAHEAD = 1; |
1165 | 8 | STATIC = false; | 8 | STATIC = false; |
1167 | 9 | DEBUG_PARSER = false; | 9 | DEBUG_PARSER = true; |
1168 | 10 | DEBUG_LOOKAHEAD = false; | ||
1169 | 11 | DEBUG_TOKEN_MANAGER = false; | ||
1170 | 10 | } | 12 | } |
1171 | 11 | 13 | ||
1172 | 12 | PARSER_BEGIN(GenlibParser) | 14 | PARSER_BEGIN(GenlibParser) |
1173 | 13 | 15 | ||
1174 | === added file 'CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/SubstitutionParser.java' | |||
1175 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/SubstitutionParser.java 1970-01-01 00:00:00 +0000 | |||
1176 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/SubstitutionParser.java 2015-11-09 09:38:45 +0000 | |||
1177 | @@ -0,0 +1,315 @@ | |||
1178 | 1 | /* Generated By:JavaCC: Do not edit this line. SubstitutionParser.java */ | ||
1179 | 2 | package org.workcraft.plugins.circuit.javacc; | ||
1180 | 3 | |||
1181 | 4 | import java.util.List; | ||
1182 | 5 | import java.util.LinkedList; | ||
1183 | 6 | import java.util.Map; | ||
1184 | 7 | import java.util.HashMap; | ||
1185 | 8 | |||
1186 | 9 | import org.workcraft.util.Pair; | ||
1187 | 10 | import org.workcraft.plugins.circuit.verilog.SubstitutionRule; | ||
1188 | 11 | |||
1189 | 12 | public class SubstitutionParser implements SubstitutionParserConstants { | ||
1190 | 13 | |||
1191 | 14 | final public List<SubstitutionRule> parseSubstitutionRules() throws ParseException { | ||
1192 | 15 | trace_call("parseSubstitutionRules"); | ||
1193 | 16 | try { | ||
1194 | 17 | SubstitutionRule rule; | ||
1195 | 18 | List<SubstitutionRule> rules = new LinkedList<SubstitutionRule>(); | ||
1196 | 19 | label_1: | ||
1197 | 20 | while (true) { | ||
1198 | 21 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | ||
1199 | 22 | case EXTENDED_NAME: | ||
1200 | 23 | ; | ||
1201 | 24 | break; | ||
1202 | 25 | default: | ||
1203 | 26 | jj_la1[0] = jj_gen; | ||
1204 | 27 | break label_1; | ||
1205 | 28 | } | ||
1206 | 29 | rule = parseSubstitutionRule(); | ||
1207 | 30 | rules.add(rule); | ||
1208 | 31 | } | ||
1209 | 32 | {if (true) return rules;} | ||
1210 | 33 | throw new Error("Missing return statement in function"); | ||
1211 | 34 | } finally { | ||
1212 | 35 | trace_return("parseSubstitutionRules"); | ||
1213 | 36 | } | ||
1214 | 37 | } | ||
1215 | 38 | |||
1216 | 39 | final public SubstitutionRule parseSubstitutionRule() throws ParseException { | ||
1217 | 40 | trace_call("parseSubstitutionRule"); | ||
1218 | 41 | try { | ||
1219 | 42 | Pair<String, String> gateSubstitution; | ||
1220 | 43 | Pair<String, String> portSubstitution; | ||
1221 | 44 | Map<String, String> portSubstitutions = new HashMap<String, String>(); | ||
1222 | 45 | gateSubstitution = parseSubstitution(); | ||
1223 | 46 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | ||
1224 | 47 | case 8: | ||
1225 | 48 | jj_consume_token(8); | ||
1226 | 49 | label_2: | ||
1227 | 50 | while (true) { | ||
1228 | 51 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | ||
1229 | 52 | case EXTENDED_NAME: | ||
1230 | 53 | ; | ||
1231 | 54 | break; | ||
1232 | 55 | default: | ||
1233 | 56 | jj_la1[1] = jj_gen; | ||
1234 | 57 | break label_2; | ||
1235 | 58 | } | ||
1236 | 59 | portSubstitution = parseSubstitution(); | ||
1237 | 60 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | ||
1238 | 61 | case 10: | ||
1239 | 62 | jj_consume_token(10); | ||
1240 | 63 | break; | ||
1241 | 64 | default: | ||
1242 | 65 | jj_la1[2] = jj_gen; | ||
1243 | 66 | ; | ||
1244 | 67 | } | ||
1245 | 68 | String oldPortName = portSubstitution.getFirst(); | ||
1246 | 69 | String newPortName = portSubstitution.getSecond(); | ||
1247 | 70 | portSubstitutions.put(oldPortName, newPortName); | ||
1248 | 71 | } | ||
1249 | 72 | jj_consume_token(9); | ||
1250 | 73 | break; | ||
1251 | 74 | default: | ||
1252 | 75 | jj_la1[3] = jj_gen; | ||
1253 | 76 | ; | ||
1254 | 77 | } | ||
1255 | 78 | String oldGateName = gateSubstitution.getFirst(); | ||
1256 | 79 | String newGateName = gateSubstitution.getSecond(); | ||
1257 | 80 | {if (true) return new SubstitutionRule(oldGateName, newGateName, portSubstitutions);} | ||
1258 | 81 | throw new Error("Missing return statement in function"); | ||
1259 | 82 | } finally { | ||
1260 | 83 | trace_return("parseSubstitutionRule"); | ||
1261 | 84 | } | ||
1262 | 85 | } | ||
1263 | 86 | |||
1264 | 87 | final public Pair<String, String> parseSubstitution() throws ParseException { | ||
1265 | 88 | trace_call("parseSubstitution"); | ||
1266 | 89 | try { | ||
1267 | 90 | Token oldName; | ||
1268 | 91 | Token newName; | ||
1269 | 92 | oldName = jj_consume_token(EXTENDED_NAME); | ||
1270 | 93 | jj_consume_token(11); | ||
1271 | 94 | newName = jj_consume_token(EXTENDED_NAME); | ||
1272 | 95 | {if (true) return new Pair(oldName.image, newName.image);} | ||
1273 | 96 | throw new Error("Missing return statement in function"); | ||
1274 | 97 | } finally { | ||
1275 | 98 | trace_return("parseSubstitution"); | ||
1276 | 99 | } | ||
1277 | 100 | } | ||
1278 | 101 | |||
1279 | 102 | /** Generated Token Manager. */ | ||
1280 | 103 | public SubstitutionParserTokenManager token_source; | ||
1281 | 104 | SimpleCharStream jj_input_stream; | ||
1282 | 105 | /** Current token. */ | ||
1283 | 106 | public Token token; | ||
1284 | 107 | /** Next token. */ | ||
1285 | 108 | public Token jj_nt; | ||
1286 | 109 | private int jj_ntk; | ||
1287 | 110 | private int jj_gen; | ||
1288 | 111 | final private int[] jj_la1 = new int[4]; | ||
1289 | 112 | static private int[] jj_la1_0; | ||
1290 | 113 | static { | ||
1291 | 114 | jj_la1_init_0(); | ||
1292 | 115 | } | ||
1293 | 116 | private static void jj_la1_init_0() { | ||
1294 | 117 | jj_la1_0 = new int[] {0x80,0x80,0x400,0x100,}; | ||
1295 | 118 | } | ||
1296 | 119 | |||
1297 | 120 | /** Constructor with InputStream. */ | ||
1298 | 121 | public SubstitutionParser(java.io.InputStream stream) { | ||
1299 | 122 | this(stream, null); | ||
1300 | 123 | } | ||
1301 | 124 | /** Constructor with InputStream and supplied encoding */ | ||
1302 | 125 | public SubstitutionParser(java.io.InputStream stream, String encoding) { | ||
1303 | 126 | try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } | ||
1304 | 127 | token_source = new SubstitutionParserTokenManager(jj_input_stream); | ||
1305 | 128 | token = new Token(); | ||
1306 | 129 | jj_ntk = -1; | ||
1307 | 130 | jj_gen = 0; | ||
1308 | 131 | for (int i = 0; i < 4; i++) jj_la1[i] = -1; | ||
1309 | 132 | } | ||
1310 | 133 | |||
1311 | 134 | /** Reinitialise. */ | ||
1312 | 135 | public void ReInit(java.io.InputStream stream) { | ||
1313 | 136 | ReInit(stream, null); | ||
1314 | 137 | } | ||
1315 | 138 | /** Reinitialise. */ | ||
1316 | 139 | public void ReInit(java.io.InputStream stream, String encoding) { | ||
1317 | 140 | try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } | ||
1318 | 141 | token_source.ReInit(jj_input_stream); | ||
1319 | 142 | token = new Token(); | ||
1320 | 143 | jj_ntk = -1; | ||
1321 | 144 | jj_gen = 0; | ||
1322 | 145 | for (int i = 0; i < 4; i++) jj_la1[i] = -1; | ||
1323 | 146 | } | ||
1324 | 147 | |||
1325 | 148 | /** Constructor. */ | ||
1326 | 149 | public SubstitutionParser(java.io.Reader stream) { | ||
1327 | 150 | jj_input_stream = new SimpleCharStream(stream, 1, 1); | ||
1328 | 151 | token_source = new SubstitutionParserTokenManager(jj_input_stream); | ||
1329 | 152 | token = new Token(); | ||
1330 | 153 | jj_ntk = -1; | ||
1331 | 154 | jj_gen = 0; | ||
1332 | 155 | for (int i = 0; i < 4; i++) jj_la1[i] = -1; | ||
1333 | 156 | } | ||
1334 | 157 | |||
1335 | 158 | /** Reinitialise. */ | ||
1336 | 159 | public void ReInit(java.io.Reader stream) { | ||
1337 | 160 | jj_input_stream.ReInit(stream, 1, 1); | ||
1338 | 161 | token_source.ReInit(jj_input_stream); | ||
1339 | 162 | token = new Token(); | ||
1340 | 163 | jj_ntk = -1; | ||
1341 | 164 | jj_gen = 0; | ||
1342 | 165 | for (int i = 0; i < 4; i++) jj_la1[i] = -1; | ||
1343 | 166 | } | ||
1344 | 167 | |||
1345 | 168 | /** Constructor with generated Token Manager. */ | ||
1346 | 169 | public SubstitutionParser(SubstitutionParserTokenManager tm) { | ||
1347 | 170 | token_source = tm; | ||
1348 | 171 | token = new Token(); | ||
1349 | 172 | jj_ntk = -1; | ||
1350 | 173 | jj_gen = 0; | ||
1351 | 174 | for (int i = 0; i < 4; i++) jj_la1[i] = -1; | ||
1352 | 175 | } | ||
1353 | 176 | |||
1354 | 177 | /** Reinitialise. */ | ||
1355 | 178 | public void ReInit(SubstitutionParserTokenManager tm) { | ||
1356 | 179 | token_source = tm; | ||
1357 | 180 | token = new Token(); | ||
1358 | 181 | jj_ntk = -1; | ||
1359 | 182 | jj_gen = 0; | ||
1360 | 183 | for (int i = 0; i < 4; i++) jj_la1[i] = -1; | ||
1361 | 184 | } | ||
1362 | 185 | |||
1363 | 186 | private Token jj_consume_token(int kind) throws ParseException { | ||
1364 | 187 | Token oldToken; | ||
1365 | 188 | if ((oldToken = token).next != null) token = token.next; | ||
1366 | 189 | else token = token.next = token_source.getNextToken(); | ||
1367 | 190 | jj_ntk = -1; | ||
1368 | 191 | if (token.kind == kind) { | ||
1369 | 192 | jj_gen++; | ||
1370 | 193 | trace_token(token, ""); | ||
1371 | 194 | return token; | ||
1372 | 195 | } | ||
1373 | 196 | token = oldToken; | ||
1374 | 197 | jj_kind = kind; | ||
1375 | 198 | throw generateParseException(); | ||
1376 | 199 | } | ||
1377 | 200 | |||
1378 | 201 | |||
1379 | 202 | /** Get the next Token. */ | ||
1380 | 203 | final public Token getNextToken() { | ||
1381 | 204 | if (token.next != null) token = token.next; | ||
1382 | 205 | else token = token.next = token_source.getNextToken(); | ||
1383 | 206 | jj_ntk = -1; | ||
1384 | 207 | jj_gen++; | ||
1385 | 208 | trace_token(token, " (in getNextToken)"); | ||
1386 | 209 | return token; | ||
1387 | 210 | } | ||
1388 | 211 | |||
1389 | 212 | /** Get the specific Token. */ | ||
1390 | 213 | final public Token getToken(int index) { | ||
1391 | 214 | Token t = token; | ||
1392 | 215 | for (int i = 0; i < index; i++) { | ||
1393 | 216 | if (t.next != null) t = t.next; | ||
1394 | 217 | else t = t.next = token_source.getNextToken(); | ||
1395 | 218 | } | ||
1396 | 219 | return t; | ||
1397 | 220 | } | ||
1398 | 221 | |||
1399 | 222 | private int jj_ntk() { | ||
1400 | 223 | if ((jj_nt=token.next) == null) | ||
1401 | 224 | return (jj_ntk = (token.next=token_source.getNextToken()).kind); | ||
1402 | 225 | else | ||
1403 | 226 | return (jj_ntk = jj_nt.kind); | ||
1404 | 227 | } | ||
1405 | 228 | |||
1406 | 229 | private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>(); | ||
1407 | 230 | private int[] jj_expentry; | ||
1408 | 231 | private int jj_kind = -1; | ||
1409 | 232 | |||
1410 | 233 | /** Generate ParseException. */ | ||
1411 | 234 | public ParseException generateParseException() { | ||
1412 | 235 | jj_expentries.clear(); | ||
1413 | 236 | boolean[] la1tokens = new boolean[12]; | ||
1414 | 237 | if (jj_kind >= 0) { | ||
1415 | 238 | la1tokens[jj_kind] = true; | ||
1416 | 239 | jj_kind = -1; | ||
1417 | 240 | } | ||
1418 | 241 | for (int i = 0; i < 4; i++) { | ||
1419 | 242 | if (jj_la1[i] == jj_gen) { | ||
1420 | 243 | for (int j = 0; j < 32; j++) { | ||
1421 | 244 | if ((jj_la1_0[i] & (1<<j)) != 0) { | ||
1422 | 245 | la1tokens[j] = true; | ||
1423 | 246 | } | ||
1424 | 247 | } | ||
1425 | 248 | } | ||
1426 | 249 | } | ||
1427 | 250 | for (int i = 0; i < 12; i++) { | ||
1428 | 251 | if (la1tokens[i]) { | ||
1429 | 252 | jj_expentry = new int[1]; | ||
1430 | 253 | jj_expentry[0] = i; | ||
1431 | 254 | jj_expentries.add(jj_expentry); | ||
1432 | 255 | } | ||
1433 | 256 | } | ||
1434 | 257 | int[][] exptokseq = new int[jj_expentries.size()][]; | ||
1435 | 258 | for (int i = 0; i < jj_expentries.size(); i++) { | ||
1436 | 259 | exptokseq[i] = jj_expentries.get(i); | ||
1437 | 260 | } | ||
1438 | 261 | return new ParseException(token, exptokseq, tokenImage); | ||
1439 | 262 | } | ||
1440 | 263 | |||
1441 | 264 | private int trace_indent = 0; | ||
1442 | 265 | private boolean trace_enabled = true; | ||
1443 | 266 | |||
1444 | 267 | /** Enable tracing. */ | ||
1445 | 268 | final public void enable_tracing() { | ||
1446 | 269 | trace_enabled = true; | ||
1447 | 270 | } | ||
1448 | 271 | |||
1449 | 272 | /** Disable tracing. */ | ||
1450 | 273 | final public void disable_tracing() { | ||
1451 | 274 | trace_enabled = false; | ||
1452 | 275 | } | ||
1453 | 276 | |||
1454 | 277 | private void trace_call(String s) { | ||
1455 | 278 | if (trace_enabled) { | ||
1456 | 279 | for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } | ||
1457 | 280 | System.out.println("Call: " + s); | ||
1458 | 281 | } | ||
1459 | 282 | trace_indent = trace_indent + 2; | ||
1460 | 283 | } | ||
1461 | 284 | |||
1462 | 285 | private void trace_return(String s) { | ||
1463 | 286 | trace_indent = trace_indent - 2; | ||
1464 | 287 | if (trace_enabled) { | ||
1465 | 288 | for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } | ||
1466 | 289 | System.out.println("Return: " + s); | ||
1467 | 290 | } | ||
1468 | 291 | } | ||
1469 | 292 | |||
1470 | 293 | private void trace_token(Token t, String where) { | ||
1471 | 294 | if (trace_enabled) { | ||
1472 | 295 | for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } | ||
1473 | 296 | System.out.print("Consumed token: <" + tokenImage[t.kind]); | ||
1474 | 297 | if (t.kind != 0 && !tokenImage[t.kind].equals("\"" + t.image + "\"")) { | ||
1475 | 298 | System.out.print(": \"" + t.image + "\""); | ||
1476 | 299 | } | ||
1477 | 300 | System.out.println(" at line " + t.beginLine + " column " + t.beginColumn + ">" + where); | ||
1478 | 301 | } | ||
1479 | 302 | } | ||
1480 | 303 | |||
1481 | 304 | private void trace_scan(Token t1, int t2) { | ||
1482 | 305 | if (trace_enabled) { | ||
1483 | 306 | for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } | ||
1484 | 307 | System.out.print("Visited token: <" + tokenImage[t1.kind]); | ||
1485 | 308 | if (t1.kind != 0 && !tokenImage[t1.kind].equals("\"" + t1.image + "\"")) { | ||
1486 | 309 | System.out.print(": \"" + t1.image + "\""); | ||
1487 | 310 | } | ||
1488 | 311 | System.out.println(" at line " + t1.beginLine + " column " + t1.beginColumn + ">; Expected token: <" + tokenImage[t2] + ">"); | ||
1489 | 312 | } | ||
1490 | 313 | } | ||
1491 | 314 | |||
1492 | 315 | } | ||
1493 | 0 | 316 | ||
1494 | === added file 'CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/SubstitutionParser.jj' | |||
1495 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/SubstitutionParser.jj 1970-01-01 00:00:00 +0000 | |||
1496 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/SubstitutionParser.jj 2015-11-09 09:38:45 +0000 | |||
1497 | @@ -0,0 +1,100 @@ | |||
1498 | 1 | /** | ||
1499 | 2 | * JavaCC file | ||
1500 | 3 | */ | ||
1501 | 4 | |||
1502 | 5 | options { | ||
1503 | 6 | JDK_VERSION = "1.7"; | ||
1504 | 7 | LOOKAHEAD = 1; | ||
1505 | 8 | STATIC = false; | ||
1506 | 9 | DEBUG_PARSER = true; | ||
1507 | 10 | DEBUG_LOOKAHEAD = false; | ||
1508 | 11 | DEBUG_TOKEN_MANAGER = false; | ||
1509 | 12 | } | ||
1510 | 13 | |||
1511 | 14 | PARSER_BEGIN(SubstitutionParser) | ||
1512 | 15 | package org.workcraft.plugins.circuit.javacc; | ||
1513 | 16 | |||
1514 | 17 | import java.util.List; | ||
1515 | 18 | import java.util.LinkedList; | ||
1516 | 19 | import java.util.Map; | ||
1517 | 20 | import java.util.HashMap; | ||
1518 | 21 | |||
1519 | 22 | import org.workcraft.util.Pair; | ||
1520 | 23 | import org.workcraft.plugins.circuit.verilog.SubstitutionRule; | ||
1521 | 24 | |||
1522 | 25 | public class SubstitutionParser { | ||
1523 | 26 | } | ||
1524 | 27 | PARSER_END(SubstitutionParser) | ||
1525 | 28 | |||
1526 | 29 | SKIP: | ||
1527 | 30 | { | ||
1528 | 31 | " " | ||
1529 | 32 | | "\t" | ||
1530 | 33 | | "\r" | ||
1531 | 34 | | "\n" | ||
1532 | 35 | | <"//" (~["\r", "\n"])*> | ||
1533 | 36 | | < "`" (~["\r", "\n"])*> | ||
1534 | 37 | } | ||
1535 | 38 | |||
1536 | 39 | TOKEN : | ||
1537 | 40 | { | ||
1538 | 41 | <EXTENDED_NAME : ["A"-"Z", "a"-"z", "_", "/" ] ([ "A"-"Z", "a"-"z", "_", "0"-"9", ":", "/", "\\", "-"])*> | ||
1539 | 42 | | "(" | ||
1540 | 43 | | ")" | ||
1541 | 44 | | "," | ||
1542 | 45 | } | ||
1543 | 46 | |||
1544 | 47 | List<SubstitutionRule> parseSubstitutionRules() : | ||
1545 | 48 | { | ||
1546 | 49 | SubstitutionRule rule; | ||
1547 | 50 | List<SubstitutionRule> rules = new LinkedList<SubstitutionRule>(); | ||
1548 | 51 | } | ||
1549 | 52 | { | ||
1550 | 53 | ( | ||
1551 | 54 | rule = parseSubstitutionRule() | ||
1552 | 55 | { | ||
1553 | 56 | rules.add(rule); | ||
1554 | 57 | } | ||
1555 | 58 | )* | ||
1556 | 59 | { | ||
1557 | 60 | return rules; | ||
1558 | 61 | } | ||
1559 | 62 | } | ||
1560 | 63 | |||
1561 | 64 | SubstitutionRule parseSubstitutionRule() : | ||
1562 | 65 | { | ||
1563 | 66 | Pair<String, String> gateSubstitution; | ||
1564 | 67 | Pair<String, String> portSubstitution; | ||
1565 | 68 | Map<String, String> portSubstitutions = new HashMap<String, String>(); | ||
1566 | 69 | } | ||
1567 | 70 | { | ||
1568 | 71 | gateSubstitution = parseSubstitution() | ||
1569 | 72 | [ "(" | ||
1570 | 73 | ( | ||
1571 | 74 | portSubstitution = parseSubstitution() [","] | ||
1572 | 75 | { | ||
1573 | 76 | String oldPortName = portSubstitution.getFirst(); | ||
1574 | 77 | String newPortName = portSubstitution.getSecond(); | ||
1575 | 78 | portSubstitutions.put(oldPortName, newPortName); | ||
1576 | 79 | } | ||
1577 | 80 | )* | ||
1578 | 81 | ")" | ||
1579 | 82 | ] | ||
1580 | 83 | { | ||
1581 | 84 | String oldGateName = gateSubstitution.getFirst(); | ||
1582 | 85 | String newGateName = gateSubstitution.getSecond(); | ||
1583 | 86 | return new SubstitutionRule(oldGateName, newGateName, portSubstitutions); | ||
1584 | 87 | } | ||
1585 | 88 | } | ||
1586 | 89 | |||
1587 | 90 | Pair<String, String> parseSubstitution(): | ||
1588 | 91 | { | ||
1589 | 92 | Token oldName; | ||
1590 | 93 | Token newName; | ||
1591 | 94 | } | ||
1592 | 95 | { | ||
1593 | 96 | oldName = <EXTENDED_NAME> "=" newName = <EXTENDED_NAME> | ||
1594 | 97 | { | ||
1595 | 98 | return new Pair(oldName.image, newName.image); | ||
1596 | 99 | } | ||
1597 | 100 | } | ||
1598 | 0 | 101 | ||
1599 | === added file 'CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/SubstitutionParserConstants.java' | |||
1600 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/SubstitutionParserConstants.java 1970-01-01 00:00:00 +0000 | |||
1601 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/SubstitutionParserConstants.java 2015-11-09 09:38:45 +0000 | |||
1602 | @@ -0,0 +1,35 @@ | |||
1603 | 1 | /* Generated By:JavaCC: Do not edit this line. SubstitutionParserConstants.java */ | ||
1604 | 2 | package org.workcraft.plugins.circuit.javacc; | ||
1605 | 3 | |||
1606 | 4 | |||
1607 | 5 | /** | ||
1608 | 6 | * Token literal values and constants. | ||
1609 | 7 | * Generated by org.javacc.parser.OtherFilesGen#start() | ||
1610 | 8 | */ | ||
1611 | 9 | public interface SubstitutionParserConstants { | ||
1612 | 10 | |||
1613 | 11 | /** End of File. */ | ||
1614 | 12 | int EOF = 0; | ||
1615 | 13 | /** RegularExpression Id. */ | ||
1616 | 14 | int EXTENDED_NAME = 7; | ||
1617 | 15 | |||
1618 | 16 | /** Lexical state. */ | ||
1619 | 17 | int DEFAULT = 0; | ||
1620 | 18 | |||
1621 | 19 | /** Literal token values. */ | ||
1622 | 20 | String[] tokenImage = { | ||
1623 | 21 | "<EOF>", | ||
1624 | 22 | "\" \"", | ||
1625 | 23 | "\"\\t\"", | ||
1626 | 24 | "\"\\r\"", | ||
1627 | 25 | "\"\\n\"", | ||
1628 | 26 | "<token of kind 5>", | ||
1629 | 27 | "<token of kind 6>", | ||
1630 | 28 | "<EXTENDED_NAME>", | ||
1631 | 29 | "\"(\"", | ||
1632 | 30 | "\")\"", | ||
1633 | 31 | "\",\"", | ||
1634 | 32 | "\"=\"", | ||
1635 | 33 | }; | ||
1636 | 34 | |||
1637 | 35 | } | ||
1638 | 0 | 36 | ||
1639 | === added file 'CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/SubstitutionParserTokenManager.java' | |||
1640 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/SubstitutionParserTokenManager.java 1970-01-01 00:00:00 +0000 | |||
1641 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/SubstitutionParserTokenManager.java 2015-11-09 09:38:45 +0000 | |||
1642 | @@ -0,0 +1,399 @@ | |||
1643 | 1 | /* Generated By:JavaCC: Do not edit this line. SubstitutionParserTokenManager.java */ | ||
1644 | 2 | package org.workcraft.plugins.circuit.javacc; | ||
1645 | 3 | import java.util.List; | ||
1646 | 4 | import java.util.LinkedList; | ||
1647 | 5 | import java.util.Map; | ||
1648 | 6 | import java.util.HashMap; | ||
1649 | 7 | import org.workcraft.util.Pair; | ||
1650 | 8 | import org.workcraft.plugins.circuit.verilog.SubstitutionRule; | ||
1651 | 9 | |||
1652 | 10 | /** Token Manager. */ | ||
1653 | 11 | public class SubstitutionParserTokenManager implements SubstitutionParserConstants | ||
1654 | 12 | { | ||
1655 | 13 | |||
1656 | 14 | /** Debug output. */ | ||
1657 | 15 | public java.io.PrintStream debugStream = System.out; | ||
1658 | 16 | /** Set debug output. */ | ||
1659 | 17 | public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } | ||
1660 | 18 | private final int jjStopStringLiteralDfa_0(int pos, long active0) | ||
1661 | 19 | { | ||
1662 | 20 | switch (pos) | ||
1663 | 21 | { | ||
1664 | 22 | default : | ||
1665 | 23 | return -1; | ||
1666 | 24 | } | ||
1667 | 25 | } | ||
1668 | 26 | private final int jjStartNfa_0(int pos, long active0) | ||
1669 | 27 | { | ||
1670 | 28 | return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); | ||
1671 | 29 | } | ||
1672 | 30 | private int jjStopAtPos(int pos, int kind) | ||
1673 | 31 | { | ||
1674 | 32 | jjmatchedKind = kind; | ||
1675 | 33 | jjmatchedPos = pos; | ||
1676 | 34 | return pos + 1; | ||
1677 | 35 | } | ||
1678 | 36 | private int jjMoveStringLiteralDfa0_0() | ||
1679 | 37 | { | ||
1680 | 38 | switch(curChar) | ||
1681 | 39 | { | ||
1682 | 40 | case 40: | ||
1683 | 41 | return jjStopAtPos(0, 8); | ||
1684 | 42 | case 41: | ||
1685 | 43 | return jjStopAtPos(0, 9); | ||
1686 | 44 | case 44: | ||
1687 | 45 | return jjStopAtPos(0, 10); | ||
1688 | 46 | case 61: | ||
1689 | 47 | return jjStopAtPos(0, 11); | ||
1690 | 48 | default : | ||
1691 | 49 | return jjMoveNfa_0(2, 0); | ||
1692 | 50 | } | ||
1693 | 51 | } | ||
1694 | 52 | static final long[] jjbitVec0 = { | ||
1695 | 53 | 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL | ||
1696 | 54 | }; | ||
1697 | 55 | private int jjMoveNfa_0(int startState, int curPos) | ||
1698 | 56 | { | ||
1699 | 57 | int startsAt = 0; | ||
1700 | 58 | jjnewStateCnt = 7; | ||
1701 | 59 | int i = 1; | ||
1702 | 60 | jjstateSet[0] = startState; | ||
1703 | 61 | int kind = 0x7fffffff; | ||
1704 | 62 | for (;;) | ||
1705 | 63 | { | ||
1706 | 64 | if (++jjround == 0x7fffffff) | ||
1707 | 65 | ReInitRounds(); | ||
1708 | 66 | if (curChar < 64) | ||
1709 | 67 | { | ||
1710 | 68 | long l = 1L << curChar; | ||
1711 | 69 | do | ||
1712 | 70 | { | ||
1713 | 71 | switch(jjstateSet[--i]) | ||
1714 | 72 | { | ||
1715 | 73 | case 2: | ||
1716 | 74 | if (curChar == 47) | ||
1717 | 75 | { | ||
1718 | 76 | if (kind > 7) | ||
1719 | 77 | kind = 7; | ||
1720 | 78 | jjCheckNAdd(6); | ||
1721 | 79 | } | ||
1722 | 80 | if (curChar == 47) | ||
1723 | 81 | jjstateSet[jjnewStateCnt++] = 0; | ||
1724 | 82 | break; | ||
1725 | 83 | case 0: | ||
1726 | 84 | if (curChar != 47) | ||
1727 | 85 | break; | ||
1728 | 86 | if (kind > 5) | ||
1729 | 87 | kind = 5; | ||
1730 | 88 | jjCheckNAdd(1); | ||
1731 | 89 | break; | ||
1732 | 90 | case 1: | ||
1733 | 91 | if ((0xffffffffffffdbffL & l) == 0L) | ||
1734 | 92 | break; | ||
1735 | 93 | if (kind > 5) | ||
1736 | 94 | kind = 5; | ||
1737 | 95 | jjCheckNAdd(1); | ||
1738 | 96 | break; | ||
1739 | 97 | case 4: | ||
1740 | 98 | if ((0xffffffffffffdbffL & l) == 0L) | ||
1741 | 99 | break; | ||
1742 | 100 | if (kind > 6) | ||
1743 | 101 | kind = 6; | ||
1744 | 102 | jjstateSet[jjnewStateCnt++] = 4; | ||
1745 | 103 | break; | ||
1746 | 104 | case 5: | ||
1747 | 105 | if (curChar != 47) | ||
1748 | 106 | break; | ||
1749 | 107 | if (kind > 7) | ||
1750 | 108 | kind = 7; | ||
1751 | 109 | jjCheckNAdd(6); | ||
1752 | 110 | break; | ||
1753 | 111 | case 6: | ||
1754 | 112 | if ((0x7ffa00000000000L & l) == 0L) | ||
1755 | 113 | break; | ||
1756 | 114 | if (kind > 7) | ||
1757 | 115 | kind = 7; | ||
1758 | 116 | jjCheckNAdd(6); | ||
1759 | 117 | break; | ||
1760 | 118 | default : break; | ||
1761 | 119 | } | ||
1762 | 120 | } while(i != startsAt); | ||
1763 | 121 | } | ||
1764 | 122 | else if (curChar < 128) | ||
1765 | 123 | { | ||
1766 | 124 | long l = 1L << (curChar & 077); | ||
1767 | 125 | do | ||
1768 | 126 | { | ||
1769 | 127 | switch(jjstateSet[--i]) | ||
1770 | 128 | { | ||
1771 | 129 | case 2: | ||
1772 | 130 | if ((0x7fffffe87fffffeL & l) != 0L) | ||
1773 | 131 | { | ||
1774 | 132 | if (kind > 7) | ||
1775 | 133 | kind = 7; | ||
1776 | 134 | jjCheckNAdd(6); | ||
1777 | 135 | } | ||
1778 | 136 | else if (curChar == 96) | ||
1779 | 137 | { | ||
1780 | 138 | if (kind > 6) | ||
1781 | 139 | kind = 6; | ||
1782 | 140 | jjCheckNAdd(4); | ||
1783 | 141 | } | ||
1784 | 142 | break; | ||
1785 | 143 | case 1: | ||
1786 | 144 | if (kind > 5) | ||
1787 | 145 | kind = 5; | ||
1788 | 146 | jjstateSet[jjnewStateCnt++] = 1; | ||
1789 | 147 | break; | ||
1790 | 148 | case 3: | ||
1791 | 149 | if (curChar != 96) | ||
1792 | 150 | break; | ||
1793 | 151 | if (kind > 6) | ||
1794 | 152 | kind = 6; | ||
1795 | 153 | jjCheckNAdd(4); | ||
1796 | 154 | break; | ||
1797 | 155 | case 4: | ||
1798 | 156 | if (kind > 6) | ||
1799 | 157 | kind = 6; | ||
1800 | 158 | jjCheckNAdd(4); | ||
1801 | 159 | break; | ||
1802 | 160 | case 5: | ||
1803 | 161 | if ((0x7fffffe87fffffeL & l) == 0L) | ||
1804 | 162 | break; | ||
1805 | 163 | if (kind > 7) | ||
1806 | 164 | kind = 7; | ||
1807 | 165 | jjCheckNAdd(6); | ||
1808 | 166 | break; | ||
1809 | 167 | case 6: | ||
1810 | 168 | if ((0x7fffffe97fffffeL & l) == 0L) | ||
1811 | 169 | break; | ||
1812 | 170 | if (kind > 7) | ||
1813 | 171 | kind = 7; | ||
1814 | 172 | jjCheckNAdd(6); | ||
1815 | 173 | break; | ||
1816 | 174 | default : break; | ||
1817 | 175 | } | ||
1818 | 176 | } while(i != startsAt); | ||
1819 | 177 | } | ||
1820 | 178 | else | ||
1821 | 179 | { | ||
1822 | 180 | int i2 = (curChar & 0xff) >> 6; | ||
1823 | 181 | long l2 = 1L << (curChar & 077); | ||
1824 | 182 | do | ||
1825 | 183 | { | ||
1826 | 184 | switch(jjstateSet[--i]) | ||
1827 | 185 | { | ||
1828 | 186 | case 1: | ||
1829 | 187 | if ((jjbitVec0[i2] & l2) == 0L) | ||
1830 | 188 | break; | ||
1831 | 189 | if (kind > 5) | ||
1832 | 190 | kind = 5; | ||
1833 | 191 | jjstateSet[jjnewStateCnt++] = 1; | ||
1834 | 192 | break; | ||
1835 | 193 | case 4: | ||
1836 | 194 | if ((jjbitVec0[i2] & l2) == 0L) | ||
1837 | 195 | break; | ||
1838 | 196 | if (kind > 6) | ||
1839 | 197 | kind = 6; | ||
1840 | 198 | jjstateSet[jjnewStateCnt++] = 4; | ||
1841 | 199 | break; | ||
1842 | 200 | default : break; | ||
1843 | 201 | } | ||
1844 | 202 | } while(i != startsAt); | ||
1845 | 203 | } | ||
1846 | 204 | if (kind != 0x7fffffff) | ||
1847 | 205 | { | ||
1848 | 206 | jjmatchedKind = kind; | ||
1849 | 207 | jjmatchedPos = curPos; | ||
1850 | 208 | kind = 0x7fffffff; | ||
1851 | 209 | } | ||
1852 | 210 | ++curPos; | ||
1853 | 211 | if ((i = jjnewStateCnt) == (startsAt = 7 - (jjnewStateCnt = startsAt))) | ||
1854 | 212 | return curPos; | ||
1855 | 213 | try { curChar = input_stream.readChar(); } | ||
1856 | 214 | catch(java.io.IOException e) { return curPos; } | ||
1857 | 215 | } | ||
1858 | 216 | } | ||
1859 | 217 | static final int[] jjnextStates = { | ||
1860 | 218 | }; | ||
1861 | 219 | |||
1862 | 220 | /** Token literal values. */ | ||
1863 | 221 | public static final String[] jjstrLiteralImages = { | ||
1864 | 222 | "", null, null, null, null, null, null, null, "\50", "\51", "\54", "\75", }; | ||
1865 | 223 | |||
1866 | 224 | /** Lexer state names. */ | ||
1867 | 225 | public static final String[] lexStateNames = { | ||
1868 | 226 | "DEFAULT", | ||
1869 | 227 | }; | ||
1870 | 228 | static final long[] jjtoToken = { | ||
1871 | 229 | 0xf81L, | ||
1872 | 230 | }; | ||
1873 | 231 | static final long[] jjtoSkip = { | ||
1874 | 232 | 0x7eL, | ||
1875 | 233 | }; | ||
1876 | 234 | protected SimpleCharStream input_stream; | ||
1877 | 235 | private final int[] jjrounds = new int[7]; | ||
1878 | 236 | private final int[] jjstateSet = new int[14]; | ||
1879 | 237 | protected char curChar; | ||
1880 | 238 | /** Constructor. */ | ||
1881 | 239 | public SubstitutionParserTokenManager(SimpleCharStream stream){ | ||
1882 | 240 | if (SimpleCharStream.staticFlag) | ||
1883 | 241 | throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); | ||
1884 | 242 | input_stream = stream; | ||
1885 | 243 | } | ||
1886 | 244 | |||
1887 | 245 | /** Constructor. */ | ||
1888 | 246 | public SubstitutionParserTokenManager(SimpleCharStream stream, int lexState){ | ||
1889 | 247 | this(stream); | ||
1890 | 248 | SwitchTo(lexState); | ||
1891 | 249 | } | ||
1892 | 250 | |||
1893 | 251 | /** Reinitialise parser. */ | ||
1894 | 252 | public void ReInit(SimpleCharStream stream) | ||
1895 | 253 | { | ||
1896 | 254 | jjmatchedPos = jjnewStateCnt = 0; | ||
1897 | 255 | curLexState = defaultLexState; | ||
1898 | 256 | input_stream = stream; | ||
1899 | 257 | ReInitRounds(); | ||
1900 | 258 | } | ||
1901 | 259 | private void ReInitRounds() | ||
1902 | 260 | { | ||
1903 | 261 | int i; | ||
1904 | 262 | jjround = 0x80000001; | ||
1905 | 263 | for (i = 7; i-- > 0;) | ||
1906 | 264 | jjrounds[i] = 0x80000000; | ||
1907 | 265 | } | ||
1908 | 266 | |||
1909 | 267 | /** Reinitialise parser. */ | ||
1910 | 268 | public void ReInit(SimpleCharStream stream, int lexState) | ||
1911 | 269 | { | ||
1912 | 270 | ReInit(stream); | ||
1913 | 271 | SwitchTo(lexState); | ||
1914 | 272 | } | ||
1915 | 273 | |||
1916 | 274 | /** Switch to specified lex state. */ | ||
1917 | 275 | public void SwitchTo(int lexState) | ||
1918 | 276 | { | ||
1919 | 277 | if (lexState >= 1 || lexState < 0) | ||
1920 | 278 | throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); | ||
1921 | 279 | else | ||
1922 | 280 | curLexState = lexState; | ||
1923 | 281 | } | ||
1924 | 282 | |||
1925 | 283 | protected Token jjFillToken() | ||
1926 | 284 | { | ||
1927 | 285 | final Token t; | ||
1928 | 286 | final String curTokenImage; | ||
1929 | 287 | final int beginLine; | ||
1930 | 288 | final int endLine; | ||
1931 | 289 | final int beginColumn; | ||
1932 | 290 | final int endColumn; | ||
1933 | 291 | String im = jjstrLiteralImages[jjmatchedKind]; | ||
1934 | 292 | curTokenImage = (im == null) ? input_stream.GetImage() : im; | ||
1935 | 293 | beginLine = input_stream.getBeginLine(); | ||
1936 | 294 | beginColumn = input_stream.getBeginColumn(); | ||
1937 | 295 | endLine = input_stream.getEndLine(); | ||
1938 | 296 | endColumn = input_stream.getEndColumn(); | ||
1939 | 297 | t = Token.newToken(jjmatchedKind, curTokenImage); | ||
1940 | 298 | |||
1941 | 299 | t.beginLine = beginLine; | ||
1942 | 300 | t.endLine = endLine; | ||
1943 | 301 | t.beginColumn = beginColumn; | ||
1944 | 302 | t.endColumn = endColumn; | ||
1945 | 303 | |||
1946 | 304 | return t; | ||
1947 | 305 | } | ||
1948 | 306 | |||
1949 | 307 | int curLexState = 0; | ||
1950 | 308 | int defaultLexState = 0; | ||
1951 | 309 | int jjnewStateCnt; | ||
1952 | 310 | int jjround; | ||
1953 | 311 | int jjmatchedPos; | ||
1954 | 312 | int jjmatchedKind; | ||
1955 | 313 | |||
1956 | 314 | /** Get the next Token. */ | ||
1957 | 315 | public Token getNextToken() | ||
1958 | 316 | { | ||
1959 | 317 | Token matchedToken; | ||
1960 | 318 | int curPos = 0; | ||
1961 | 319 | |||
1962 | 320 | EOFLoop : | ||
1963 | 321 | for (;;) | ||
1964 | 322 | { | ||
1965 | 323 | try | ||
1966 | 324 | { | ||
1967 | 325 | curChar = input_stream.BeginToken(); | ||
1968 | 326 | } | ||
1969 | 327 | catch(java.io.IOException e) | ||
1970 | 328 | { | ||
1971 | 329 | jjmatchedKind = 0; | ||
1972 | 330 | matchedToken = jjFillToken(); | ||
1973 | 331 | return matchedToken; | ||
1974 | 332 | } | ||
1975 | 333 | |||
1976 | 334 | try { input_stream.backup(0); | ||
1977 | 335 | while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L) | ||
1978 | 336 | curChar = input_stream.BeginToken(); | ||
1979 | 337 | } | ||
1980 | 338 | catch (java.io.IOException e1) { continue EOFLoop; } | ||
1981 | 339 | jjmatchedKind = 0x7fffffff; | ||
1982 | 340 | jjmatchedPos = 0; | ||
1983 | 341 | curPos = jjMoveStringLiteralDfa0_0(); | ||
1984 | 342 | if (jjmatchedKind != 0x7fffffff) | ||
1985 | 343 | { | ||
1986 | 344 | if (jjmatchedPos + 1 < curPos) | ||
1987 | 345 | input_stream.backup(curPos - jjmatchedPos - 1); | ||
1988 | 346 | if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) | ||
1989 | 347 | { | ||
1990 | 348 | matchedToken = jjFillToken(); | ||
1991 | 349 | return matchedToken; | ||
1992 | 350 | } | ||
1993 | 351 | else | ||
1994 | 352 | { | ||
1995 | 353 | continue EOFLoop; | ||
1996 | 354 | } | ||
1997 | 355 | } | ||
1998 | 356 | int error_line = input_stream.getEndLine(); | ||
1999 | 357 | int error_column = input_stream.getEndColumn(); | ||
2000 | 358 | String error_after = null; | ||
2001 | 359 | boolean EOFSeen = false; | ||
2002 | 360 | try { input_stream.readChar(); input_stream.backup(1); } | ||
2003 | 361 | catch (java.io.IOException e1) { | ||
2004 | 362 | EOFSeen = true; | ||
2005 | 363 | error_after = curPos <= 1 ? "" : input_stream.GetImage(); | ||
2006 | 364 | if (curChar == '\n' || curChar == '\r') { | ||
2007 | 365 | error_line++; | ||
2008 | 366 | error_column = 0; | ||
2009 | 367 | } | ||
2010 | 368 | else | ||
2011 | 369 | error_column++; | ||
2012 | 370 | } | ||
2013 | 371 | if (!EOFSeen) { | ||
2014 | 372 | input_stream.backup(1); | ||
2015 | 373 | error_after = curPos <= 1 ? "" : input_stream.GetImage(); | ||
2016 | 374 | } | ||
2017 | 375 | throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); | ||
2018 | 376 | } | ||
2019 | 377 | } | ||
2020 | 378 | |||
2021 | 379 | private void jjCheckNAdd(int state) | ||
2022 | 380 | { | ||
2023 | 381 | if (jjrounds[state] != jjround) | ||
2024 | 382 | { | ||
2025 | 383 | jjstateSet[jjnewStateCnt++] = state; | ||
2026 | 384 | jjrounds[state] = jjround; | ||
2027 | 385 | } | ||
2028 | 386 | } | ||
2029 | 387 | private void jjAddStates(int start, int end) | ||
2030 | 388 | { | ||
2031 | 389 | do { | ||
2032 | 390 | jjstateSet[jjnewStateCnt++] = jjnextStates[start]; | ||
2033 | 391 | } while (start++ != end); | ||
2034 | 392 | } | ||
2035 | 393 | private void jjCheckNAddTwoStates(int state1, int state2) | ||
2036 | 394 | { | ||
2037 | 395 | jjCheckNAdd(state1); | ||
2038 | 396 | jjCheckNAdd(state2); | ||
2039 | 397 | } | ||
2040 | 398 | |||
2041 | 399 | } | ||
2042 | 0 | 400 | ||
2043 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/VerilogParser.java' | |||
2044 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/VerilogParser.java 2015-11-02 12:32:29 +0000 | |||
2045 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/VerilogParser.java 2015-11-09 09:38:45 +0000 | |||
2046 | @@ -17,33 +17,45 @@ | |||
2047 | 17 | public class VerilogParser implements VerilogParserConstants { | 17 | public class VerilogParser implements VerilogParserConstants { |
2048 | 18 | 18 | ||
2049 | 19 | final public List<Module> parseCircuit() throws ParseException { | 19 | final public List<Module> parseCircuit() throws ParseException { |
2050 | 20 | trace_call("parseCircuit"); | ||
2051 | 21 | try { | ||
2052 | 20 | List<Module> modules; | 22 | List<Module> modules; |
2054 | 21 | modules = parseModules(); | 23 | modules = parseModules(); |
2055 | 22 | {if (true) return modules;} | 24 | {if (true) return modules;} |
2056 | 23 | throw new Error("Missing return statement in function"); | 25 | throw new Error("Missing return statement in function"); |
2057 | 26 | } finally { | ||
2058 | 27 | trace_return("parseCircuit"); | ||
2059 | 28 | } | ||
2060 | 24 | } | 29 | } |
2061 | 25 | 30 | ||
2062 | 26 | final public List<Module> parseModules() throws ParseException { | 31 | final public List<Module> parseModules() throws ParseException { |
2063 | 32 | trace_call("parseModules"); | ||
2064 | 33 | try { | ||
2065 | 27 | Module module; | 34 | Module module; |
2066 | 28 | List<Module> modules = new LinkedList<Module>(); | 35 | List<Module> modules = new LinkedList<Module>(); |
2078 | 29 | label_1: | 36 | label_1: |
2079 | 30 | while (true) { | 37 | while (true) { |
2080 | 31 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 38 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2081 | 32 | case MODULE: | 39 | case MODULE: |
2082 | 33 | ; | 40 | ; |
2083 | 34 | break; | 41 | break; |
2084 | 35 | default: | 42 | default: |
2085 | 36 | jj_la1[0] = jj_gen; | 43 | jj_la1[0] = jj_gen; |
2086 | 37 | break label_1; | 44 | break label_1; |
2087 | 38 | } | 45 | } |
2088 | 39 | module = parseModule(); | 46 | module = parseModule(); |
2089 | 40 | modules.add(module); | 47 | modules.add(module); |
2091 | 41 | } | 48 | } |
2092 | 42 | {if (true) return modules;} | 49 | {if (true) return modules;} |
2093 | 43 | throw new Error("Missing return statement in function"); | 50 | throw new Error("Missing return statement in function"); |
2094 | 51 | } finally { | ||
2095 | 52 | trace_return("parseModules"); | ||
2096 | 53 | } | ||
2097 | 44 | } | 54 | } |
2098 | 45 | 55 | ||
2099 | 46 | final public Module parseModule() throws ParseException { | 56 | final public Module parseModule() throws ParseException { |
2100 | 57 | trace_call("parseModule"); | ||
2101 | 58 | try { | ||
2102 | 47 | String name; | 59 | String name; |
2103 | 48 | List<Port> ports; | 60 | List<Port> ports; |
2104 | 49 | List<Assign> assigns; | 61 | List<Assign> assigns; |
2105 | @@ -51,169 +63,199 @@ | |||
2106 | 51 | List<Instance> group; | 63 | List<Instance> group; |
2107 | 52 | Set<List<Instance>> groups = new HashSet<List<Instance>>(); | 64 | Set<List<Instance>> groups = new HashSet<List<Instance>>(); |
2108 | 53 | Map<String, Boolean> signalStates = null; | 65 | Map<String, Boolean> signalStates = null; |
2129 | 54 | jj_consume_token(MODULE); | 66 | jj_consume_token(MODULE); |
2130 | 55 | name = parseModuleName(); | 67 | name = parseModuleName(); |
2131 | 56 | ports = parsePorts(); | 68 | ports = parsePorts(); |
2132 | 57 | assigns = parseAssigns(); | 69 | assigns = parseAssigns(); |
2133 | 58 | instances = parseInstances(); | 70 | instances = parseInstances(); |
2134 | 59 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 71 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2135 | 60 | case PETRIFY_UNMAPPED: | 72 | case PETRIFY_UNMAPPED: |
2136 | 61 | jj_consume_token(PETRIFY_UNMAPPED); | 73 | jj_consume_token(PETRIFY_UNMAPPED); |
2137 | 62 | label_2: | 74 | label_2: |
2138 | 63 | while (true) { | 75 | while (true) { |
2139 | 64 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 76 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2140 | 65 | case PETRIFY_EQUATION: | 77 | case PETRIFY_EQUATION: |
2141 | 66 | ; | 78 | ; |
2142 | 67 | break; | 79 | break; |
2143 | 68 | default: | 80 | default: |
2144 | 69 | jj_la1[1] = jj_gen; | 81 | jj_la1[1] = jj_gen; |
2145 | 70 | break label_2; | 82 | break label_2; |
2146 | 71 | } | 83 | } |
2147 | 72 | jj_consume_token(PETRIFY_EQUATION); | 84 | jj_consume_token(PETRIFY_EQUATION); |
2148 | 73 | group = parseInstances(); | 85 | group = parseInstances(); |
2149 | 74 | instances.addAll(group); | 86 | instances.addAll(group); |
2150 | 75 | groups.add(group); | 87 | groups.add(group); |
2151 | 88 | } | ||
2152 | 89 | break; | ||
2153 | 90 | default: | ||
2154 | 91 | jj_la1[2] = jj_gen; | ||
2155 | 92 | ; | ||
2156 | 76 | } | 93 | } |
2157 | 77 | break; | ||
2158 | 78 | default: | ||
2159 | 79 | jj_la1[2] = jj_gen; | ||
2160 | 80 | ; | ||
2161 | 81 | } | ||
2162 | 82 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | ||
2163 | 83 | case PETRIFY_INIT_STATE: | ||
2164 | 84 | case MPSAT_INIT_STATE: | ||
2165 | 85 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 94 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2166 | 86 | case PETRIFY_INIT_STATE: | 95 | case PETRIFY_INIT_STATE: |
2167 | 87 | jj_consume_token(PETRIFY_INIT_STATE); | ||
2168 | 88 | break; | ||
2169 | 89 | case MPSAT_INIT_STATE: | 96 | case MPSAT_INIT_STATE: |
2171 | 90 | jj_consume_token(MPSAT_INIT_STATE); | 97 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2172 | 98 | case PETRIFY_INIT_STATE: | ||
2173 | 99 | jj_consume_token(PETRIFY_INIT_STATE); | ||
2174 | 100 | break; | ||
2175 | 101 | case MPSAT_INIT_STATE: | ||
2176 | 102 | jj_consume_token(MPSAT_INIT_STATE); | ||
2177 | 103 | break; | ||
2178 | 104 | default: | ||
2179 | 105 | jj_la1[3] = jj_gen; | ||
2180 | 106 | jj_consume_token(-1); | ||
2181 | 107 | throw new ParseException(); | ||
2182 | 108 | } | ||
2183 | 109 | signalStates = parseInitialState(); | ||
2184 | 91 | break; | 110 | break; |
2185 | 92 | default: | 111 | default: |
2189 | 93 | jj_la1[3] = jj_gen; | 112 | jj_la1[4] = jj_gen; |
2190 | 94 | jj_consume_token(-1); | 113 | ; |
2188 | 95 | throw new ParseException(); | ||
2191 | 96 | } | 114 | } |
2199 | 97 | signalStates = parseInitialState(); | 115 | jj_consume_token(ENDMODULE); |
2193 | 98 | break; | ||
2194 | 99 | default: | ||
2195 | 100 | jj_la1[4] = jj_gen; | ||
2196 | 101 | ; | ||
2197 | 102 | } | ||
2198 | 103 | jj_consume_token(ENDMODULE); | ||
2200 | 104 | {if (true) return new Module(name, ports, assigns, instances, signalStates, groups);} | 116 | {if (true) return new Module(name, ports, assigns, instances, signalStates, groups);} |
2201 | 105 | throw new Error("Missing return statement in function"); | 117 | throw new Error("Missing return statement in function"); |
2202 | 118 | } finally { | ||
2203 | 119 | trace_return("parseModule"); | ||
2204 | 120 | } | ||
2205 | 106 | } | 121 | } |
2206 | 107 | 122 | ||
2207 | 108 | final public String parseModuleName() throws ParseException { | 123 | final public String parseModuleName() throws ParseException { |
2208 | 124 | trace_call("parseModuleName"); | ||
2209 | 125 | try { | ||
2210 | 109 | Token nameToken; | 126 | Token nameToken; |
2223 | 110 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 127 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2224 | 111 | case NAME: | 128 | case NAME: |
2225 | 112 | nameToken = jj_consume_token(NAME); | 129 | nameToken = jj_consume_token(NAME); |
2226 | 113 | break; | 130 | break; |
2227 | 114 | case PETRIFY_NAME: | 131 | case PETRIFY_NAME: |
2228 | 115 | nameToken = jj_consume_token(PETRIFY_NAME); | 132 | nameToken = jj_consume_token(PETRIFY_NAME); |
2229 | 116 | break; | 133 | break; |
2230 | 117 | default: | 134 | default: |
2231 | 118 | jj_la1[5] = jj_gen; | 135 | jj_la1[5] = jj_gen; |
2232 | 119 | jj_consume_token(-1); | 136 | jj_consume_token(-1); |
2233 | 120 | throw new ParseException(); | 137 | throw new ParseException(); |
2234 | 121 | } | 138 | } |
2235 | 122 | {if (true) return nameToken.image;} | 139 | {if (true) return nameToken.image;} |
2236 | 123 | throw new Error("Missing return statement in function"); | 140 | throw new Error("Missing return statement in function"); |
2237 | 141 | } finally { | ||
2238 | 142 | trace_return("parseModuleName"); | ||
2239 | 143 | } | ||
2240 | 124 | } | 144 | } |
2241 | 125 | 145 | ||
2242 | 126 | final public List<Port> parsePorts() throws ParseException { | 146 | final public List<Port> parsePorts() throws ParseException { |
2243 | 147 | trace_call("parsePorts"); | ||
2244 | 148 | try { | ||
2245 | 127 | List<Port> ports; | 149 | List<Port> ports; |
2258 | 128 | if (jj_2_1(2147483647)) { | 150 | if (jj_2_1(2147483647)) { |
2259 | 129 | ports = parseCompactPorts(); | 151 | ports = parseCompactPorts(); |
2260 | 130 | } else { | 152 | } else { |
2261 | 131 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 153 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2262 | 132 | case 38: | 154 | case 38: |
2263 | 133 | case 44: | 155 | case 44: |
2264 | 134 | ports = parseComplexPorts(); | 156 | ports = parseComplexPorts(); |
2265 | 135 | break; | 157 | break; |
2266 | 136 | default: | 158 | default: |
2267 | 137 | jj_la1[6] = jj_gen; | 159 | jj_la1[6] = jj_gen; |
2268 | 138 | jj_consume_token(-1); | 160 | jj_consume_token(-1); |
2269 | 139 | throw new ParseException(); | 161 | throw new ParseException(); |
2270 | 162 | } | ||
2271 | 140 | } | 163 | } |
2272 | 141 | } | ||
2273 | 142 | {if (true) return ports;} | 164 | {if (true) return ports;} |
2274 | 143 | throw new Error("Missing return statement in function"); | 165 | throw new Error("Missing return statement in function"); |
2275 | 166 | } finally { | ||
2276 | 167 | trace_return("parsePorts"); | ||
2277 | 168 | } | ||
2278 | 144 | } | 169 | } |
2279 | 145 | 170 | ||
2280 | 146 | final public List<Port> parseCompactPorts() throws ParseException { | 171 | final public List<Port> parseCompactPorts() throws ParseException { |
2281 | 172 | trace_call("parseCompactPorts"); | ||
2282 | 173 | try { | ||
2283 | 147 | Port port; | 174 | Port port; |
2284 | 148 | List<Port> ports = new LinkedList<Port>(); | 175 | List<Port> ports = new LinkedList<Port>(); |
2308 | 149 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 176 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2309 | 150 | case 38: | 177 | case 38: |
2310 | 151 | jj_consume_token(38); | 178 | jj_consume_token(38); |
2311 | 152 | label_3: | 179 | label_3: |
2312 | 153 | while (true) { | 180 | while (true) { |
2313 | 154 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 181 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2314 | 155 | case INPUT: | 182 | case INPUT: |
2315 | 156 | case OUTPUT: | 183 | case OUTPUT: |
2316 | 157 | ; | 184 | ; |
2317 | 158 | break; | 185 | break; |
2318 | 159 | default: | 186 | default: |
2319 | 160 | jj_la1[7] = jj_gen; | 187 | jj_la1[7] = jj_gen; |
2320 | 161 | break label_3; | 188 | break label_3; |
2321 | 162 | } | 189 | } |
2322 | 163 | port = parseCompactPort(); | 190 | port = parseCompactPort(); |
2323 | 164 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 191 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2324 | 165 | case 42: | 192 | case 42: |
2325 | 166 | jj_consume_token(42); | 193 | jj_consume_token(42); |
2326 | 167 | break; | 194 | break; |
2327 | 168 | default: | 195 | default: |
2328 | 169 | jj_la1[8] = jj_gen; | 196 | jj_la1[8] = jj_gen; |
2329 | 170 | ; | 197 | ; |
2330 | 171 | } | 198 | } |
2331 | 172 | ports.add(port); | 199 | ports.add(port); |
2332 | 200 | } | ||
2333 | 201 | jj_consume_token(39); | ||
2334 | 202 | break; | ||
2335 | 203 | default: | ||
2336 | 204 | jj_la1[9] = jj_gen; | ||
2337 | 205 | ; | ||
2338 | 173 | } | 206 | } |
2346 | 174 | jj_consume_token(39); | 207 | jj_consume_token(44); |
2340 | 175 | break; | ||
2341 | 176 | default: | ||
2342 | 177 | jj_la1[9] = jj_gen; | ||
2343 | 178 | ; | ||
2344 | 179 | } | ||
2345 | 180 | jj_consume_token(44); | ||
2347 | 181 | {if (true) return ports;} | 208 | {if (true) return ports;} |
2348 | 182 | throw new Error("Missing return statement in function"); | 209 | throw new Error("Missing return statement in function"); |
2349 | 210 | } finally { | ||
2350 | 211 | trace_return("parseCompactPorts"); | ||
2351 | 212 | } | ||
2352 | 183 | } | 213 | } |
2353 | 184 | 214 | ||
2354 | 185 | final public Port parseCompactPort() throws ParseException { | 215 | final public Port parseCompactPort() throws ParseException { |
2355 | 216 | trace_call("parseCompactPort"); | ||
2356 | 217 | try { | ||
2357 | 186 | Port.Type type; | 218 | Port.Type type; |
2358 | 187 | Token nameToken; | 219 | Token nameToken; |
2361 | 188 | type = parsePortType(); | 220 | type = parsePortType(); |
2362 | 189 | nameToken = jj_consume_token(NAME); | 221 | nameToken = jj_consume_token(NAME); |
2363 | 190 | {if (true) return new Port(nameToken.image, type);} | 222 | {if (true) return new Port(nameToken.image, type);} |
2364 | 191 | throw new Error("Missing return statement in function"); | 223 | throw new Error("Missing return statement in function"); |
2365 | 224 | } finally { | ||
2366 | 225 | trace_return("parseCompactPort"); | ||
2367 | 226 | } | ||
2368 | 192 | } | 227 | } |
2369 | 193 | 228 | ||
2370 | 194 | final public Port.Type parsePortType() throws ParseException { | 229 | final public Port.Type parsePortType() throws ParseException { |
2374 | 195 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 230 | trace_call("parsePortType"); |
2375 | 196 | case INPUT: | 231 | try { |
2376 | 197 | jj_consume_token(INPUT); | 232 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2377 | 233 | case INPUT: | ||
2378 | 234 | jj_consume_token(INPUT); | ||
2379 | 198 | {if (true) return Port.Type.INPUT;} | 235 | {if (true) return Port.Type.INPUT;} |
2383 | 199 | break; | 236 | break; |
2384 | 200 | case OUTPUT: | 237 | case OUTPUT: |
2385 | 201 | jj_consume_token(OUTPUT); | 238 | jj_consume_token(OUTPUT); |
2386 | 202 | {if (true) return Port.Type.OUTPUT;} | 239 | {if (true) return Port.Type.OUTPUT;} |
2392 | 203 | break; | 240 | break; |
2393 | 204 | default: | 241 | default: |
2394 | 205 | jj_la1[10] = jj_gen; | 242 | jj_la1[10] = jj_gen; |
2395 | 206 | jj_consume_token(-1); | 243 | jj_consume_token(-1); |
2396 | 207 | throw new ParseException(); | 244 | throw new ParseException(); |
2397 | 245 | } | ||
2398 | 246 | throw new Error("Missing return statement in function"); | ||
2399 | 247 | } finally { | ||
2400 | 248 | trace_return("parsePortType"); | ||
2401 | 208 | } | 249 | } |
2402 | 209 | throw new Error("Missing return statement in function"); | ||
2403 | 210 | } | 250 | } |
2404 | 211 | 251 | ||
2405 | 212 | final public List<Port> parseComplexPorts() throws ParseException { | 252 | final public List<Port> parseComplexPorts() throws ParseException { |
2406 | 253 | trace_call("parseComplexPorts"); | ||
2407 | 254 | try { | ||
2408 | 213 | List<String> declarations; | 255 | List<String> declarations; |
2409 | 214 | List<Port> definitions; | 256 | List<Port> definitions; |
2412 | 215 | declarations = parsePortsDeclaration(); | 257 | declarations = parsePortsDeclaration(); |
2413 | 216 | definitions = parsePortsDefinitions(); | 258 | definitions = parsePortsDefinitions(); |
2414 | 217 | HashMap<String, Port.Type> nameToType = new HashMap<String, Port.Type>(); | 259 | HashMap<String, Port.Type> nameToType = new HashMap<String, Port.Type>(); |
2415 | 218 | for (Port port: definitions) { | 260 | for (Port port: definitions) { |
2416 | 219 | nameToType.put(port.name, port.type); | 261 | nameToType.put(port.name, port.type); |
2417 | @@ -225,335 +267,403 @@ | |||
2418 | 225 | } | 267 | } |
2419 | 226 | {if (true) return ports;} | 268 | {if (true) return ports;} |
2420 | 227 | throw new Error("Missing return statement in function"); | 269 | throw new Error("Missing return statement in function"); |
2421 | 270 | } finally { | ||
2422 | 271 | trace_return("parseComplexPorts"); | ||
2423 | 272 | } | ||
2424 | 228 | } | 273 | } |
2425 | 229 | 274 | ||
2426 | 230 | final public List<String> parsePortsDeclaration() throws ParseException { | 275 | final public List<String> parsePortsDeclaration() throws ParseException { |
2427 | 276 | trace_call("parsePortsDeclaration"); | ||
2428 | 277 | try { | ||
2429 | 231 | List<String> names = null; | 278 | List<String> names = null; |
2441 | 232 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 279 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2442 | 233 | case 38: | 280 | case 38: |
2443 | 234 | jj_consume_token(38); | 281 | jj_consume_token(38); |
2444 | 235 | names = parseNames(); | 282 | names = parseNames(); |
2445 | 236 | jj_consume_token(39); | 283 | jj_consume_token(39); |
2446 | 237 | break; | 284 | break; |
2447 | 238 | default: | 285 | default: |
2448 | 239 | jj_la1[11] = jj_gen; | 286 | jj_la1[11] = jj_gen; |
2449 | 240 | ; | 287 | ; |
2450 | 241 | } | 288 | } |
2451 | 242 | jj_consume_token(44); | 289 | jj_consume_token(44); |
2452 | 243 | List<String> ports = new LinkedList<String>(); | 290 | List<String> ports = new LinkedList<String>(); |
2453 | 244 | if (names != null) { | 291 | if (names != null) { |
2454 | 245 | ports.addAll(names); | 292 | ports.addAll(names); |
2455 | 246 | } | 293 | } |
2456 | 247 | {if (true) return ports;} | 294 | {if (true) return ports;} |
2457 | 248 | throw new Error("Missing return statement in function"); | 295 | throw new Error("Missing return statement in function"); |
2458 | 296 | } finally { | ||
2459 | 297 | trace_return("parsePortsDeclaration"); | ||
2460 | 298 | } | ||
2461 | 249 | } | 299 | } |
2462 | 250 | 300 | ||
2463 | 251 | final public List<Port> parsePortsDefinitions() throws ParseException { | 301 | final public List<Port> parsePortsDefinitions() throws ParseException { |
2464 | 302 | trace_call("parsePortsDefinitions"); | ||
2465 | 303 | try { | ||
2466 | 252 | List<Port> ports; | 304 | List<Port> ports; |
2467 | 253 | List<Port> allPorts = new LinkedList<Port>(); | 305 | List<Port> allPorts = new LinkedList<Port>(); |
2483 | 254 | label_4: | 306 | label_4: |
2484 | 255 | while (true) { | 307 | while (true) { |
2485 | 256 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 308 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2486 | 257 | case INPUT: | 309 | case INPUT: |
2487 | 258 | case OUTPUT: | 310 | case OUTPUT: |
2488 | 259 | case INOUT: | 311 | case INOUT: |
2489 | 260 | case REG: | 312 | case REG: |
2490 | 261 | case WIRE: | 313 | case WIRE: |
2491 | 262 | ; | 314 | ; |
2492 | 263 | break; | 315 | break; |
2493 | 264 | default: | 316 | default: |
2494 | 265 | jj_la1[12] = jj_gen; | 317 | jj_la1[12] = jj_gen; |
2495 | 266 | break label_4; | 318 | break label_4; |
2496 | 267 | } | 319 | } |
2497 | 268 | ports = parsePortsDefinition(); | 320 | ports = parsePortsDefinition(); |
2498 | 269 | if (ports != null) { | 321 | if (ports != null) { |
2499 | 270 | allPorts.addAll(ports); | 322 | allPorts.addAll(ports); |
2500 | 271 | } | 323 | } |
2502 | 272 | } | 324 | } |
2503 | 273 | {if (true) return allPorts;} | 325 | {if (true) return allPorts;} |
2504 | 274 | throw new Error("Missing return statement in function"); | 326 | throw new Error("Missing return statement in function"); |
2505 | 327 | } finally { | ||
2506 | 328 | trace_return("parsePortsDefinitions"); | ||
2507 | 329 | } | ||
2508 | 275 | } | 330 | } |
2509 | 276 | 331 | ||
2510 | 277 | final public List<Port> parsePortsDefinition() throws ParseException { | 332 | final public List<Port> parsePortsDefinition() throws ParseException { |
2511 | 333 | trace_call("parsePortsDefinition"); | ||
2512 | 334 | try { | ||
2513 | 278 | List<String> names; | 335 | List<String> names; |
2514 | 279 | Port.Type type; | 336 | Port.Type type; |
2521 | 280 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 337 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2522 | 281 | case INPUT: | 338 | case INPUT: |
2523 | 282 | case OUTPUT: | 339 | case OUTPUT: |
2524 | 283 | type = parsePortType(); | 340 | type = parsePortType(); |
2525 | 284 | names = parseNames(); | 341 | names = parseNames(); |
2526 | 285 | jj_consume_token(44); | 342 | jj_consume_token(44); |
2527 | 286 | List<Port> ports = new LinkedList<Port>(); | 343 | List<Port> ports = new LinkedList<Port>(); |
2528 | 287 | for (String name: names) { | 344 | for (String name: names) { |
2529 | 288 | Port port = new Port(name, type); | 345 | Port port = new Port(name, type); |
2530 | 289 | ports.add(port); | 346 | ports.add(port); |
2531 | 290 | } | 347 | } |
2532 | 291 | {if (true) return ports;} | 348 | {if (true) return ports;} |
2533 | 292 | break; | ||
2534 | 293 | case INOUT: | ||
2535 | 294 | case REG: | ||
2536 | 295 | case WIRE: | ||
2537 | 296 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | ||
2538 | 297 | case WIRE: | ||
2539 | 298 | jj_consume_token(WIRE); | ||
2540 | 299 | break; | 349 | break; |
2541 | 300 | case INOUT: | 350 | case INOUT: |
2542 | 301 | jj_consume_token(INOUT); | ||
2543 | 302 | break; | ||
2544 | 303 | case REG: | 351 | case REG: |
2554 | 304 | jj_consume_token(REG); | 352 | case WIRE: |
2555 | 305 | break; | 353 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2556 | 306 | default: | 354 | case WIRE: |
2557 | 307 | jj_la1[13] = jj_gen; | 355 | jj_consume_token(WIRE); |
2558 | 308 | jj_consume_token(-1); | 356 | break; |
2559 | 309 | throw new ParseException(); | 357 | case INOUT: |
2560 | 310 | } | 358 | jj_consume_token(INOUT); |
2561 | 311 | parseNames(); | 359 | break; |
2562 | 312 | jj_consume_token(44); | 360 | case REG: |
2563 | 361 | jj_consume_token(REG); | ||
2564 | 362 | break; | ||
2565 | 363 | default: | ||
2566 | 364 | jj_la1[13] = jj_gen; | ||
2567 | 365 | jj_consume_token(-1); | ||
2568 | 366 | throw new ParseException(); | ||
2569 | 367 | } | ||
2570 | 368 | parseNames(); | ||
2571 | 369 | jj_consume_token(44); | ||
2572 | 313 | {if (true) return null;} | 370 | {if (true) return null;} |
2578 | 314 | break; | 371 | break; |
2579 | 315 | default: | 372 | default: |
2580 | 316 | jj_la1[14] = jj_gen; | 373 | jj_la1[14] = jj_gen; |
2581 | 317 | jj_consume_token(-1); | 374 | jj_consume_token(-1); |
2582 | 318 | throw new ParseException(); | 375 | throw new ParseException(); |
2583 | 376 | } | ||
2584 | 377 | throw new Error("Missing return statement in function"); | ||
2585 | 378 | } finally { | ||
2586 | 379 | trace_return("parsePortsDefinition"); | ||
2587 | 319 | } | 380 | } |
2588 | 320 | throw new Error("Missing return statement in function"); | ||
2589 | 321 | } | 381 | } |
2590 | 322 | 382 | ||
2591 | 323 | final public List<String> parseNames() throws ParseException { | 383 | final public List<String> parseNames() throws ParseException { |
2592 | 384 | trace_call("parseNames"); | ||
2593 | 385 | try { | ||
2594 | 324 | Token nameToken; | 386 | Token nameToken; |
2595 | 325 | List<String> names = new LinkedList<String>(); | 387 | List<String> names = new LinkedList<String>(); |
2615 | 326 | label_5: | 388 | label_5: |
2616 | 327 | while (true) { | 389 | while (true) { |
2617 | 328 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 390 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2618 | 329 | case NAME: | 391 | case NAME: |
2619 | 330 | ; | 392 | ; |
2620 | 331 | break; | 393 | break; |
2621 | 332 | default: | 394 | default: |
2622 | 333 | jj_la1[15] = jj_gen; | 395 | jj_la1[15] = jj_gen; |
2623 | 334 | break label_5; | 396 | break label_5; |
2624 | 335 | } | 397 | } |
2625 | 336 | nameToken = jj_consume_token(NAME); | 398 | nameToken = jj_consume_token(NAME); |
2626 | 337 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 399 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2627 | 338 | case 42: | 400 | case 42: |
2628 | 339 | jj_consume_token(42); | 401 | jj_consume_token(42); |
2629 | 340 | break; | 402 | break; |
2630 | 341 | default: | 403 | default: |
2631 | 342 | jj_la1[16] = jj_gen; | 404 | jj_la1[16] = jj_gen; |
2632 | 343 | ; | 405 | ; |
2633 | 344 | } | 406 | } |
2634 | 345 | String name = nameToken.image; | 407 | String name = nameToken.image; |
2635 | 346 | names.add(name); | 408 | names.add(name); |
2637 | 347 | } | 409 | } |
2638 | 348 | {if (true) return names;} | 410 | {if (true) return names;} |
2639 | 349 | throw new Error("Missing return statement in function"); | 411 | throw new Error("Missing return statement in function"); |
2640 | 412 | } finally { | ||
2641 | 413 | trace_return("parseNames"); | ||
2642 | 414 | } | ||
2643 | 350 | } | 415 | } |
2644 | 351 | 416 | ||
2645 | 352 | final public Map<String, Boolean> parseInitialState() throws ParseException { | 417 | final public Map<String, Boolean> parseInitialState() throws ParseException { |
2646 | 418 | trace_call("parseInitialState"); | ||
2647 | 419 | try { | ||
2648 | 353 | Boolean state; | 420 | Boolean state; |
2649 | 354 | Token nameToken; | 421 | Token nameToken; |
2650 | 355 | Map<String, Boolean> signalStates = new HashMap<String, Boolean>(); | 422 | Map<String, Boolean> signalStates = new HashMap<String, Boolean>(); |
2666 | 356 | label_6: | 423 | label_6: |
2667 | 357 | while (true) { | 424 | while (true) { |
2668 | 358 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 425 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2669 | 359 | case NAME: | 426 | case NAME: |
2670 | 360 | case 43: | 427 | case 43: |
2671 | 361 | ; | 428 | ; |
2672 | 362 | break; | 429 | break; |
2673 | 363 | default: | 430 | default: |
2674 | 364 | jj_la1[17] = jj_gen; | 431 | jj_la1[17] = jj_gen; |
2675 | 365 | break label_6; | 432 | break label_6; |
2676 | 366 | } | 433 | } |
2677 | 367 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 434 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2678 | 368 | case 43: | 435 | case 43: |
2679 | 369 | jj_consume_token(43); | 436 | jj_consume_token(43); |
2680 | 370 | nameToken = jj_consume_token(NAME); | 437 | nameToken = jj_consume_token(NAME); |
2681 | 371 | state = false; | 438 | state = false; |
2685 | 372 | break; | 439 | break; |
2686 | 373 | case NAME: | 440 | case NAME: |
2687 | 374 | nameToken = jj_consume_token(NAME); | 441 | nameToken = jj_consume_token(NAME); |
2688 | 375 | state = true; | 442 | state = true; |
2703 | 376 | break; | 443 | break; |
2704 | 377 | default: | 444 | default: |
2705 | 378 | jj_la1[18] = jj_gen; | 445 | jj_la1[18] = jj_gen; |
2706 | 379 | jj_consume_token(-1); | 446 | jj_consume_token(-1); |
2707 | 380 | throw new ParseException(); | 447 | throw new ParseException(); |
2708 | 381 | } | 448 | } |
2709 | 382 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 449 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2710 | 383 | case 42: | 450 | case 42: |
2711 | 384 | jj_consume_token(42); | 451 | jj_consume_token(42); |
2712 | 385 | break; | 452 | break; |
2713 | 386 | default: | 453 | default: |
2714 | 387 | jj_la1[19] = jj_gen; | 454 | jj_la1[19] = jj_gen; |
2715 | 388 | ; | 455 | ; |
2716 | 389 | } | 456 | } |
2717 | 390 | String name = nameToken.image; | 457 | String name = nameToken.image; |
2718 | 391 | signalStates.put(name, state); | 458 | signalStates.put(name, state); |
2720 | 392 | } | 459 | } |
2721 | 393 | {if (true) return signalStates;} | 460 | {if (true) return signalStates;} |
2722 | 394 | throw new Error("Missing return statement in function"); | 461 | throw new Error("Missing return statement in function"); |
2723 | 462 | } finally { | ||
2724 | 463 | trace_return("parseInitialState"); | ||
2725 | 464 | } | ||
2726 | 395 | } | 465 | } |
2727 | 396 | 466 | ||
2728 | 397 | final public List<Assign> parseAssigns() throws ParseException { | 467 | final public List<Assign> parseAssigns() throws ParseException { |
2729 | 468 | trace_call("parseAssigns"); | ||
2730 | 469 | try { | ||
2731 | 398 | Assign assign; | 470 | Assign assign; |
2732 | 399 | List<Assign> assigns = new LinkedList<Assign>(); | 471 | List<Assign> assigns = new LinkedList<Assign>(); |
2744 | 400 | label_7: | 472 | label_7: |
2745 | 401 | while (true) { | 473 | while (true) { |
2746 | 402 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 474 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2747 | 403 | case ASSIGN: | 475 | case ASSIGN: |
2748 | 404 | ; | 476 | ; |
2749 | 405 | break; | 477 | break; |
2750 | 406 | default: | 478 | default: |
2751 | 407 | jj_la1[20] = jj_gen; | 479 | jj_la1[20] = jj_gen; |
2752 | 408 | break label_7; | 480 | break label_7; |
2753 | 409 | } | 481 | } |
2754 | 410 | assign = parseAssign(); | 482 | assign = parseAssign(); |
2755 | 411 | assigns.add(assign); | 483 | assigns.add(assign); |
2757 | 412 | } | 484 | } |
2758 | 413 | {if (true) return assigns;} | 485 | {if (true) return assigns;} |
2759 | 414 | throw new Error("Missing return statement in function"); | 486 | throw new Error("Missing return statement in function"); |
2760 | 487 | } finally { | ||
2761 | 488 | trace_return("parseAssigns"); | ||
2762 | 489 | } | ||
2763 | 415 | } | 490 | } |
2764 | 416 | 491 | ||
2765 | 417 | final public Assign parseAssign() throws ParseException { | 492 | final public Assign parseAssign() throws ParseException { |
2766 | 493 | trace_call("parseAssign"); | ||
2767 | 494 | try { | ||
2768 | 418 | Token nameToken; | 495 | Token nameToken; |
2769 | 419 | Token formulaToken; | 496 | Token formulaToken; |
2773 | 420 | jj_consume_token(ASSIGN); | 497 | jj_consume_token(ASSIGN); |
2774 | 421 | nameToken = jj_consume_token(NAME); | 498 | nameToken = jj_consume_token(NAME); |
2775 | 422 | formulaToken = jj_consume_token(FORMULA); | 499 | formulaToken = jj_consume_token(FORMULA); |
2776 | 423 | String formula = formulaToken.image.replaceAll("^=", "").replaceAll(";$", ""); | 500 | String formula = formulaToken.image.replaceAll("^=", "").replaceAll(";$", ""); |
2777 | 424 | {if (true) return new Assign(nameToken.image, formula);} | 501 | {if (true) return new Assign(nameToken.image, formula);} |
2778 | 425 | throw new Error("Missing return statement in function"); | 502 | throw new Error("Missing return statement in function"); |
2779 | 503 | } finally { | ||
2780 | 504 | trace_return("parseAssign"); | ||
2781 | 505 | } | ||
2782 | 426 | } | 506 | } |
2783 | 427 | 507 | ||
2784 | 428 | final public List<Instance> parseInstances() throws ParseException { | 508 | final public List<Instance> parseInstances() throws ParseException { |
2785 | 509 | trace_call("parseInstances"); | ||
2786 | 510 | try { | ||
2787 | 429 | Instance instance; | 511 | Instance instance; |
2788 | 430 | List<Instance> instances = new LinkedList<Instance>(); | 512 | List<Instance> instances = new LinkedList<Instance>(); |
2803 | 431 | label_8: | 513 | label_8: |
2804 | 432 | while (true) { | 514 | while (true) { |
2805 | 433 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 515 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2806 | 434 | case NAME: | 516 | case NAME: |
2807 | 435 | case PETRIFY_NAME: | 517 | case PETRIFY_NAME: |
2808 | 436 | case PETRIFY_ZERO_DELAY: | 518 | case PETRIFY_ZERO_DELAY: |
2809 | 437 | case MPSAT_ZERO_DELAY: | 519 | case MPSAT_ZERO_DELAY: |
2810 | 438 | ; | 520 | ; |
2811 | 439 | break; | 521 | break; |
2812 | 440 | default: | 522 | default: |
2813 | 441 | jj_la1[21] = jj_gen; | 523 | jj_la1[21] = jj_gen; |
2814 | 442 | break label_8; | 524 | break label_8; |
2815 | 443 | } | 525 | } |
2816 | 444 | instance = parseInstance(); | 526 | instance = parseInstance(); |
2817 | 445 | instances.add(instance); | 527 | instances.add(instance); |
2819 | 446 | } | 528 | } |
2820 | 447 | {if (true) return instances;} | 529 | {if (true) return instances;} |
2821 | 448 | throw new Error("Missing return statement in function"); | 530 | throw new Error("Missing return statement in function"); |
2822 | 531 | } finally { | ||
2823 | 532 | trace_return("parseInstances"); | ||
2824 | 533 | } | ||
2825 | 449 | } | 534 | } |
2826 | 450 | 535 | ||
2827 | 451 | final public Instance parseInstance() throws ParseException { | 536 | final public Instance parseInstance() throws ParseException { |
2828 | 537 | trace_call("parseInstance"); | ||
2829 | 538 | try { | ||
2830 | 452 | boolean zeroDelay = false; | 539 | boolean zeroDelay = false; |
2831 | 453 | String moduleName; | 540 | String moduleName; |
2832 | 454 | Token nameToken = null; | 541 | Token nameToken = null; |
2833 | 455 | List<String> parameters; | 542 | List<String> parameters; |
2834 | 456 | List<Pin> pins; | 543 | List<Pin> pins; |
2835 | 457 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | ||
2836 | 458 | case PETRIFY_ZERO_DELAY: | ||
2837 | 459 | case MPSAT_ZERO_DELAY: | ||
2838 | 460 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 544 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2839 | 461 | case PETRIFY_ZERO_DELAY: | 545 | case PETRIFY_ZERO_DELAY: |
2840 | 462 | jj_consume_token(PETRIFY_ZERO_DELAY); | ||
2841 | 463 | break; | ||
2842 | 464 | case MPSAT_ZERO_DELAY: | 546 | case MPSAT_ZERO_DELAY: |
2850 | 465 | jj_consume_token(MPSAT_ZERO_DELAY); | 547 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2851 | 466 | break; | 548 | case PETRIFY_ZERO_DELAY: |
2852 | 467 | default: | 549 | jj_consume_token(PETRIFY_ZERO_DELAY); |
2853 | 468 | jj_la1[22] = jj_gen; | 550 | break; |
2854 | 469 | jj_consume_token(-1); | 551 | case MPSAT_ZERO_DELAY: |
2855 | 470 | throw new ParseException(); | 552 | jj_consume_token(MPSAT_ZERO_DELAY); |
2856 | 471 | } | 553 | break; |
2857 | 554 | default: | ||
2858 | 555 | jj_la1[22] = jj_gen; | ||
2859 | 556 | jj_consume_token(-1); | ||
2860 | 557 | throw new ParseException(); | ||
2861 | 558 | } | ||
2862 | 472 | zeroDelay = true; | 559 | zeroDelay = true; |
2881 | 473 | break; | 560 | break; |
2882 | 474 | default: | 561 | default: |
2883 | 475 | jj_la1[23] = jj_gen; | 562 | jj_la1[23] = jj_gen; |
2884 | 476 | ; | 563 | ; |
2885 | 477 | } | 564 | } |
2886 | 478 | moduleName = parseModuleName(); | 565 | moduleName = parseModuleName(); |
2887 | 479 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 566 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2888 | 480 | case NAME: | 567 | case NAME: |
2889 | 481 | nameToken = jj_consume_token(NAME); | 568 | nameToken = jj_consume_token(NAME); |
2890 | 482 | break; | 569 | break; |
2891 | 483 | default: | 570 | default: |
2892 | 484 | jj_la1[24] = jj_gen; | 571 | jj_la1[24] = jj_gen; |
2893 | 485 | ; | 572 | ; |
2894 | 486 | } | 573 | } |
2895 | 487 | jj_consume_token(38); | 574 | jj_consume_token(38); |
2896 | 488 | pins = parsePins(); | 575 | pins = parsePins(); |
2897 | 489 | jj_consume_token(39); | 576 | jj_consume_token(39); |
2898 | 490 | jj_consume_token(44); | 577 | jj_consume_token(44); |
2899 | 491 | String name = (nameToken == null ? null : nameToken.image); | 578 | String name = (nameToken == null ? null : nameToken.image); |
2900 | 492 | {if (true) return new Instance(name, moduleName, pins, zeroDelay);} | 579 | {if (true) return new Instance(name, moduleName, pins, zeroDelay);} |
2901 | 493 | throw new Error("Missing return statement in function"); | 580 | throw new Error("Missing return statement in function"); |
2902 | 581 | } finally { | ||
2903 | 582 | trace_return("parseInstance"); | ||
2904 | 583 | } | ||
2905 | 494 | } | 584 | } |
2906 | 495 | 585 | ||
2907 | 496 | final public List<Pin> parsePins() throws ParseException { | 586 | final public List<Pin> parsePins() throws ParseException { |
2908 | 587 | trace_call("parsePins"); | ||
2909 | 588 | try { | ||
2910 | 497 | List<Pin> pins; | 589 | List<Pin> pins; |
2916 | 498 | if (jj_2_2(2147483647)) { | 590 | if (jj_2_2(2147483647)) { |
2917 | 499 | pins = parseNamedPins(); | 591 | pins = parseNamedPins(); |
2918 | 500 | } else { | 592 | } else { |
2919 | 501 | pins = parseOrderedPins(); | 593 | pins = parseOrderedPins(); |
2920 | 502 | } | 594 | } |
2921 | 503 | {if (true) return pins;} | 595 | {if (true) return pins;} |
2922 | 504 | throw new Error("Missing return statement in function"); | 596 | throw new Error("Missing return statement in function"); |
2923 | 597 | } finally { | ||
2924 | 598 | trace_return("parsePins"); | ||
2925 | 599 | } | ||
2926 | 505 | } | 600 | } |
2927 | 506 | 601 | ||
2928 | 507 | final public List<Pin> parseNamedPins() throws ParseException { | 602 | final public List<Pin> parseNamedPins() throws ParseException { |
2929 | 603 | trace_call("parseNamedPins"); | ||
2930 | 604 | try { | ||
2931 | 508 | Pin pin; | 605 | Pin pin; |
2932 | 509 | List<Pin> pins = new LinkedList<Pin>(); | 606 | List<Pin> pins = new LinkedList<Pin>(); |
2936 | 510 | label_9: | 607 | label_9: |
2937 | 511 | while (true) { | 608 | while (true) { |
2938 | 512 | pin = parseNamedPin(); | 609 | pin = parseNamedPin(); |
2939 | 513 | pins.add(pin); | 610 | pins.add(pin); |
2947 | 514 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 611 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2948 | 515 | case 45: | 612 | case 45: |
2949 | 516 | ; | 613 | ; |
2950 | 517 | break; | 614 | break; |
2951 | 518 | default: | 615 | default: |
2952 | 519 | jj_la1[25] = jj_gen; | 616 | jj_la1[25] = jj_gen; |
2953 | 520 | break label_9; | 617 | break label_9; |
2954 | 618 | } | ||
2955 | 521 | } | 619 | } |
2956 | 522 | } | ||
2957 | 523 | {if (true) return pins;} | 620 | {if (true) return pins;} |
2958 | 524 | throw new Error("Missing return statement in function"); | 621 | throw new Error("Missing return statement in function"); |
2959 | 622 | } finally { | ||
2960 | 623 | trace_return("parseNamedPins"); | ||
2961 | 624 | } | ||
2962 | 525 | } | 625 | } |
2963 | 526 | 626 | ||
2964 | 527 | final public Pin parseNamedPin() throws ParseException { | 627 | final public Pin parseNamedPin() throws ParseException { |
2965 | 628 | trace_call("parseNamedPin"); | ||
2966 | 629 | try { | ||
2967 | 528 | Token portName; | 630 | Token portName; |
2968 | 529 | Token netName; | 631 | Token netName; |
2982 | 530 | jj_consume_token(45); | 632 | jj_consume_token(45); |
2983 | 531 | portName = jj_consume_token(NAME); | 633 | portName = jj_consume_token(NAME); |
2984 | 532 | jj_consume_token(38); | 634 | jj_consume_token(38); |
2985 | 533 | netName = jj_consume_token(NAME); | 635 | netName = jj_consume_token(NAME); |
2986 | 534 | jj_consume_token(39); | 636 | jj_consume_token(39); |
2987 | 535 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { | 637 | switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
2988 | 536 | case 42: | 638 | case 42: |
2989 | 537 | jj_consume_token(42); | 639 | jj_consume_token(42); |
2990 | 538 | break; | 640 | break; |
2991 | 539 | default: | 641 | default: |
2992 | 540 | jj_la1[26] = jj_gen; | 642 | jj_la1[26] = jj_gen; |
2993 | 541 | ; | 643 | ; |
2994 | 542 | } | 644 | } |
2995 | 543 | {if (true) return new Pin(portName.image, netName.image);} | 645 | {if (true) return new Pin(portName.image, netName.image);} |
2996 | 544 | throw new Error("Missing return statement in function"); | 646 | throw new Error("Missing return statement in function"); |
2997 | 647 | } finally { | ||
2998 | 648 | trace_return("parseNamedPin"); | ||
2999 | 649 | } | ||
3000 | 545 | } | 650 | } |
3001 | 546 | 651 | ||
3002 | 547 | final public List<Pin> parseOrderedPins() throws ParseException { | 652 | final public List<Pin> parseOrderedPins() throws ParseException { |
3003 | 653 | trace_call("parseOrderedPins"); | ||
3004 | 654 | try { | ||
3005 | 548 | List<String> wires; | 655 | List<String> wires; |
3006 | 549 | List<Pin> pins = new LinkedList<Pin>(); | 656 | List<Pin> pins = new LinkedList<Pin>(); |
3008 | 550 | wires = parseNames(); | 657 | wires = parseNames(); |
3009 | 551 | for (String wire: wires) { | 658 | for (String wire: wires) { |
3010 | 552 | Pin pin = new Pin(null, wire); | 659 | Pin pin = new Pin(null, wire); |
3011 | 553 | pins.add(pin); | 660 | pins.add(pin); |
3012 | 554 | } | 661 | } |
3013 | 555 | {if (true) return pins;} | 662 | {if (true) return pins;} |
3014 | 556 | throw new Error("Missing return statement in function"); | 663 | throw new Error("Missing return statement in function"); |
3015 | 664 | } finally { | ||
3016 | 665 | trace_return("parseOrderedPins"); | ||
3017 | 666 | } | ||
3018 | 557 | } | 667 | } |
3019 | 558 | 668 | ||
3020 | 559 | private boolean jj_2_1(int xla) { | 669 | private boolean jj_2_1(int xla) { |
3021 | @@ -777,6 +887,7 @@ | |||
3022 | 777 | } | 887 | } |
3023 | 778 | } | 888 | } |
3024 | 779 | } | 889 | } |
3025 | 890 | trace_token(token, ""); | ||
3026 | 780 | return token; | 891 | return token; |
3027 | 781 | } | 892 | } |
3028 | 782 | token = oldToken; | 893 | token = oldToken; |
3029 | @@ -814,6 +925,7 @@ | |||
3030 | 814 | else token = token.next = token_source.getNextToken(); | 925 | else token = token.next = token_source.getNextToken(); |
3031 | 815 | jj_ntk = -1; | 926 | jj_ntk = -1; |
3032 | 816 | jj_gen++; | 927 | jj_gen++; |
3033 | 928 | trace_token(token, " (in getNextToken)"); | ||
3034 | 817 | return token; | 929 | return token; |
3035 | 818 | } | 930 | } |
3036 | 819 | 931 | ||
3037 | @@ -902,12 +1014,55 @@ | |||
3038 | 902 | return new ParseException(token, exptokseq, tokenImage); | 1014 | return new ParseException(token, exptokseq, tokenImage); |
3039 | 903 | } | 1015 | } |
3040 | 904 | 1016 | ||
3042 | 905 | /** Enable tracing. */ | 1017 | private int trace_indent = 0; |
3043 | 1018 | private boolean trace_enabled = true; | ||
3044 | 1019 | |||
3045 | 1020 | /** Enable tracing. */ | ||
3046 | 906 | final public void enable_tracing() { | 1021 | final public void enable_tracing() { |
3047 | 1022 | trace_enabled = true; | ||
3048 | 907 | } | 1023 | } |
3049 | 908 | 1024 | ||
3051 | 909 | /** Disable tracing. */ | 1025 | /** Disable tracing. */ |
3052 | 910 | final public void disable_tracing() { | 1026 | final public void disable_tracing() { |
3053 | 1027 | trace_enabled = false; | ||
3054 | 1028 | } | ||
3055 | 1029 | |||
3056 | 1030 | private void trace_call(String s) { | ||
3057 | 1031 | if (trace_enabled) { | ||
3058 | 1032 | for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } | ||
3059 | 1033 | System.out.println("Call: " + s); | ||
3060 | 1034 | } | ||
3061 | 1035 | trace_indent = trace_indent + 2; | ||
3062 | 1036 | } | ||
3063 | 1037 | |||
3064 | 1038 | private void trace_return(String s) { | ||
3065 | 1039 | trace_indent = trace_indent - 2; | ||
3066 | 1040 | if (trace_enabled) { | ||
3067 | 1041 | for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } | ||
3068 | 1042 | System.out.println("Return: " + s); | ||
3069 | 1043 | } | ||
3070 | 1044 | } | ||
3071 | 1045 | |||
3072 | 1046 | private void trace_token(Token t, String where) { | ||
3073 | 1047 | if (trace_enabled) { | ||
3074 | 1048 | for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } | ||
3075 | 1049 | System.out.print("Consumed token: <" + tokenImage[t.kind]); | ||
3076 | 1050 | if (t.kind != 0 && !tokenImage[t.kind].equals("\"" + t.image + "\"")) { | ||
3077 | 1051 | System.out.print(": \"" + t.image + "\""); | ||
3078 | 1052 | } | ||
3079 | 1053 | System.out.println(" at line " + t.beginLine + " column " + t.beginColumn + ">" + where); | ||
3080 | 1054 | } | ||
3081 | 1055 | } | ||
3082 | 1056 | |||
3083 | 1057 | private void trace_scan(Token t1, int t2) { | ||
3084 | 1058 | if (trace_enabled) { | ||
3085 | 1059 | for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } | ||
3086 | 1060 | System.out.print("Visited token: <" + tokenImage[t1.kind]); | ||
3087 | 1061 | if (t1.kind != 0 && !tokenImage[t1.kind].equals("\"" + t1.image + "\"")) { | ||
3088 | 1062 | System.out.print(": \"" + t1.image + "\""); | ||
3089 | 1063 | } | ||
3090 | 1064 | System.out.println(" at line " + t1.beginLine + " column " + t1.beginColumn + ">; Expected token: <" + tokenImage[t2] + ">"); | ||
3091 | 1065 | } | ||
3092 | 911 | } | 1066 | } |
3093 | 912 | 1067 | ||
3094 | 913 | private void jj_rescan_token() { | 1068 | private void jj_rescan_token() { |
3095 | 914 | 1069 | ||
3096 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/VerilogParser.jj' | |||
3097 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/VerilogParser.jj 2015-11-03 23:05:25 +0000 | |||
3098 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/javacc/VerilogParser.jj 2015-11-09 09:38:45 +0000 | |||
3099 | @@ -6,7 +6,7 @@ | |||
3100 | 6 | JDK_VERSION = "1.7"; | 6 | JDK_VERSION = "1.7"; |
3101 | 7 | LOOKAHEAD = 1; | 7 | LOOKAHEAD = 1; |
3102 | 8 | STATIC = false; | 8 | STATIC = false; |
3104 | 9 | DEBUG_PARSER = false; | 9 | DEBUG_PARSER = true; |
3105 | 10 | DEBUG_LOOKAHEAD = false; | 10 | DEBUG_LOOKAHEAD = false; |
3106 | 11 | DEBUG_TOKEN_MANAGER = false; | 11 | DEBUG_TOKEN_MANAGER = false; |
3107 | 12 | } | 12 | } |
3108 | 13 | 13 | ||
3109 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/serialisation/VerilogSerialiser.java' | |||
3110 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/serialisation/VerilogSerialiser.java 2015-07-30 13:49:01 +0000 | |||
3111 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/serialisation/VerilogSerialiser.java 2015-11-09 09:38:45 +0000 | |||
3112 | @@ -21,18 +21,30 @@ | |||
3113 | 21 | 21 | ||
3114 | 22 | package org.workcraft.plugins.circuit.serialisation; | 22 | package org.workcraft.plugins.circuit.serialisation; |
3115 | 23 | 23 | ||
3116 | 24 | import java.io.File; | ||
3117 | 25 | import java.io.FileInputStream; | ||
3118 | 26 | import java.io.FileNotFoundException; | ||
3119 | 27 | import java.io.InputStream; | ||
3120 | 24 | import java.io.OutputStream; | 28 | import java.io.OutputStream; |
3121 | 25 | import java.io.PrintWriter; | 29 | import java.io.PrintWriter; |
3122 | 26 | import java.util.HashMap; | 30 | import java.util.HashMap; |
3123 | 31 | import java.util.HashSet; | ||
3124 | 32 | import java.util.List; | ||
3125 | 27 | import java.util.UUID; | 33 | import java.util.UUID; |
3126 | 28 | 34 | ||
3127 | 35 | import org.workcraft.Framework; | ||
3128 | 29 | import org.workcraft.dom.Model; | 36 | import org.workcraft.dom.Model; |
3129 | 30 | import org.workcraft.dom.hierarchy.NamespaceHelper; | 37 | import org.workcraft.dom.hierarchy.NamespaceHelper; |
3130 | 31 | import org.workcraft.exceptions.ArgumentException; | 38 | import org.workcraft.exceptions.ArgumentException; |
3131 | 32 | import org.workcraft.plugins.circuit.Circuit; | 39 | import org.workcraft.plugins.circuit.Circuit; |
3133 | 33 | import org.workcraft.plugins.circuit.CircuitComponent; | 40 | import org.workcraft.plugins.circuit.CircuitSettings; |
3134 | 34 | import org.workcraft.plugins.circuit.CircuitUtils; | 41 | import org.workcraft.plugins.circuit.CircuitUtils; |
3135 | 35 | import org.workcraft.plugins.circuit.Contact; | 42 | import org.workcraft.plugins.circuit.Contact; |
3136 | 43 | import org.workcraft.plugins.circuit.FunctionComponent; | ||
3137 | 44 | import org.workcraft.plugins.circuit.javacc.ParseException; | ||
3138 | 45 | import org.workcraft.plugins.circuit.javacc.SubstitutionParser; | ||
3139 | 46 | import org.workcraft.plugins.circuit.verilog.SubstitutionRule; | ||
3140 | 47 | import org.workcraft.plugins.shared.CommonDebugSettings; | ||
3141 | 36 | import org.workcraft.serialisation.Format; | 48 | import org.workcraft.serialisation.Format; |
3142 | 37 | import org.workcraft.serialisation.ModelSerialiser; | 49 | import org.workcraft.serialisation.ModelSerialiser; |
3143 | 38 | import org.workcraft.serialisation.ReferenceProducer; | 50 | import org.workcraft.serialisation.ReferenceProducer; |
3144 | @@ -45,7 +57,7 @@ | |||
3145 | 45 | private static final String KEYWORD_INPUT = "input"; | 57 | private static final String KEYWORD_INPUT = "input"; |
3146 | 46 | private static final String KEYWORD_MODULE = "module "; | 58 | private static final String KEYWORD_MODULE = "module "; |
3147 | 47 | private static final String KEYWORD_ENDMODULE = "endmodule"; | 59 | private static final String KEYWORD_ENDMODULE = "endmodule"; |
3149 | 48 | 60 | ||
3150 | 49 | class ReferenceResolver implements ReferenceProducer { | 61 | class ReferenceResolver implements ReferenceProducer { |
3151 | 50 | HashMap<Object, String> refMap = new HashMap<Object, String>(); | 62 | HashMap<Object, String> refMap = new HashMap<Object, String>(); |
3152 | 51 | 63 | ||
3153 | @@ -94,6 +106,7 @@ | |||
3154 | 94 | private void writeCircuit(PrintWriter out, Circuit circuit) { | 106 | private void writeCircuit(PrintWriter out, Circuit circuit) { |
3155 | 95 | writeHeader(out, circuit); | 107 | writeHeader(out, circuit); |
3156 | 96 | writeInstances(out, circuit); | 108 | writeInstances(out, circuit); |
3157 | 109 | writeInitialState(out, circuit); | ||
3158 | 97 | out.println(KEYWORD_ENDMODULE); | 110 | out.println(KEYWORD_ENDMODULE); |
3159 | 98 | } | 111 | } |
3160 | 99 | 112 | ||
3161 | @@ -130,7 +143,8 @@ | |||
3162 | 130 | } | 143 | } |
3163 | 131 | 144 | ||
3164 | 132 | private void writeInstances(PrintWriter out, Circuit circuit) { | 145 | private void writeInstances(PrintWriter out, Circuit circuit) { |
3166 | 133 | for (CircuitComponent component: Hierarchy.getDescendantsOfType(circuit.getRoot(), CircuitComponent.class)) { | 146 | HashMap<String, SubstitutionRule> substitutionRules = readSubsritutionRules(); |
3167 | 147 | for (FunctionComponent component: Hierarchy.getDescendantsOfType(circuit.getRoot(), FunctionComponent.class)) { | ||
3168 | 134 | String moduleName = component.getModule(); | 148 | String moduleName = component.getModule(); |
3169 | 135 | String instanceRef = circuit.getNodeReference(component); | 149 | String instanceRef = circuit.getNodeReference(component); |
3170 | 136 | String instanceFlatName = NamespaceHelper.hierarchicalToFlatName(instanceRef); | 150 | String instanceFlatName = NamespaceHelper.hierarchicalToFlatName(instanceRef); |
3171 | @@ -138,6 +152,17 @@ | |||
3172 | 138 | System.out.println(" Warning: component '" + instanceFlatName + "' is not associated to a module."); | 152 | System.out.println(" Warning: component '" + instanceFlatName + "' is not associated to a module."); |
3173 | 139 | moduleName = ""; | 153 | moduleName = ""; |
3174 | 140 | } | 154 | } |
3175 | 155 | SubstitutionRule substitutionRule = substitutionRules.get(moduleName); | ||
3176 | 156 | if (substitutionRule != null) { | ||
3177 | 157 | String newModuleName = substitutionRule.newName; | ||
3178 | 158 | if (newModuleName != null) { | ||
3179 | 159 | System.out.println("Info: in component '" + instanceFlatName + "' renaming module '" + moduleName + "' to '" + newModuleName + "'."); | ||
3180 | 160 | moduleName = newModuleName; | ||
3181 | 161 | } | ||
3182 | 162 | } | ||
3183 | 163 | if (component.getIsZeroDelay() && (component.isBuffer() || component.isInverter())) { | ||
3184 | 164 | out.println(" // This inverter should have a short delay"); | ||
3185 | 165 | } | ||
3186 | 141 | out.print(" " + moduleName + " " + instanceFlatName + " ("); | 166 | out.print(" " + moduleName + " " + instanceFlatName + " ("); |
3187 | 142 | boolean first = true; | 167 | boolean first = true; |
3188 | 143 | for (Contact contact: component.getContacts()) { | 168 | for (Contact contact: component.getContacts()) { |
3189 | @@ -149,13 +174,77 @@ | |||
3190 | 149 | String contactName = contact.getName(); | 174 | String contactName = contact.getName(); |
3191 | 150 | String wireName = CircuitUtils.getWireName(circuit, contact); | 175 | String wireName = CircuitUtils.getWireName(circuit, contact); |
3192 | 151 | if ((wireName == null) || wireName.isEmpty()) { | 176 | if ((wireName == null) || wireName.isEmpty()) { |
3194 | 152 | System.out.println(" Warning: contact '" + contactName + "' of component '"+ instanceFlatName + "' is disconnected."); | 177 | System.out.println(" Warning: in component '" + instanceFlatName + "' contact '" + contactName + "' is disconnected."); |
3195 | 153 | wireName = ""; | 178 | wireName = ""; |
3196 | 154 | } | 179 | } |
3197 | 180 | if (substitutionRule != null) { | ||
3198 | 181 | String newContactName = substitutionRule.substitutions.get(contactName); | ||
3199 | 182 | if (newContactName != null) { | ||
3200 | 183 | System.out.println("Info: in component '" + instanceFlatName + "' renaming contact '" + contactName + "' to '" + newContactName + "'."); | ||
3201 | 184 | contactName = newContactName; | ||
3202 | 185 | } | ||
3203 | 186 | } | ||
3204 | 155 | out.print("." + contactName + "(" + wireName + ")"); | 187 | out.print("." + contactName + "(" + wireName + ")"); |
3205 | 156 | } | 188 | } |
3206 | 157 | out.print(");\n"); | 189 | out.print(");\n"); |
3207 | 158 | } | 190 | } |
3208 | 159 | } | 191 | } |
3209 | 160 | 192 | ||
3210 | 193 | private HashMap<String, SubstitutionRule> readSubsritutionRules() { | ||
3211 | 194 | HashMap<String, SubstitutionRule> result = new HashMap<>(); | ||
3212 | 195 | String substitutionsFileName = CircuitSettings.getSubstitutionLibrary(); | ||
3213 | 196 | if ((substitutionsFileName == null) || substitutionsFileName.isEmpty()) { | ||
3214 | 197 | System.out.println("Warning: file of substitutions is not specified."); | ||
3215 | 198 | } else { | ||
3216 | 199 | File libraryFile = new File(substitutionsFileName); | ||
3217 | 200 | final Framework framework = Framework.getInstance(); | ||
3218 | 201 | if (framework.checkFile(libraryFile, "Access error for the file of substitutions")) { | ||
3219 | 202 | try { | ||
3220 | 203 | InputStream genlibInputStream = new FileInputStream(substitutionsFileName); | ||
3221 | 204 | SubstitutionParser substitutionParser = new SubstitutionParser(genlibInputStream); | ||
3222 | 205 | if (CommonDebugSettings.getParserTracing()) { | ||
3223 | 206 | substitutionParser.enable_tracing(); | ||
3224 | 207 | } else { | ||
3225 | 208 | substitutionParser.disable_tracing(); | ||
3226 | 209 | } | ||
3227 | 210 | List<SubstitutionRule> rules = substitutionParser.parseSubstitutionRules(); | ||
3228 | 211 | for (SubstitutionRule rule: rules) { | ||
3229 | 212 | result.put(rule.oldName, rule); | ||
3230 | 213 | } | ||
3231 | 214 | System.out.println("Info: renaming gates and pins using the file of substitutions '" + substitutionsFileName + "'."); | ||
3232 | 215 | } catch (FileNotFoundException e) { | ||
3233 | 216 | } catch (ParseException e) { | ||
3234 | 217 | System.out.println("Warning: could not parse the file of substitutions '" + substitutionsFileName + "'."); | ||
3235 | 218 | } | ||
3236 | 219 | } | ||
3237 | 220 | } | ||
3238 | 221 | return result; | ||
3239 | 222 | } | ||
3240 | 223 | |||
3241 | 224 | private void writeInitialState(PrintWriter out, Circuit circuit) { | ||
3242 | 225 | HashSet<Contact> contacts = new HashSet<>(); | ||
3243 | 226 | for (Contact contact: Hierarchy.getDescendantsOfType(circuit.getRoot(), Contact.class, new Func<Contact, Boolean>() { | ||
3244 | 227 | @Override | ||
3245 | 228 | public Boolean eval(Contact arg) { | ||
3246 | 229 | return (arg.isPort() != arg.isOutput()); | ||
3247 | 230 | } | ||
3248 | 231 | })) { | ||
3249 | 232 | contacts.add(contact); | ||
3250 | 233 | } | ||
3251 | 234 | out.println(); | ||
3252 | 235 | out.println(" // signal values at the initial state:"); | ||
3253 | 236 | out.print(" //"); | ||
3254 | 237 | for (Contact contact: contacts) { | ||
3255 | 238 | String wireName = CircuitUtils.getWireName(circuit, contact); | ||
3256 | 239 | if ((wireName != null) && !wireName.isEmpty()) { | ||
3257 | 240 | out.print(" "); | ||
3258 | 241 | if ( !contact.getInitToOne() ) { | ||
3259 | 242 | out.print("!"); | ||
3260 | 243 | } | ||
3261 | 244 | out.print(wireName); | ||
3262 | 245 | } | ||
3263 | 246 | } | ||
3264 | 247 | out.println(); | ||
3265 | 248 | } | ||
3266 | 249 | |||
3267 | 161 | } | 250 | } |
3268 | 162 | 251 | ||
3269 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitToStgConverter.java' | |||
3270 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitToStgConverter.java 2015-11-02 12:32:29 +0000 | |||
3271 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitToStgConverter.java 2015-11-09 09:38:45 +0000 | |||
3272 | @@ -212,7 +212,7 @@ | |||
3273 | 212 | private TwoWayMap<VisualContact, SignalStg> convertDriversToStgs(HashSet<VisualContact> drivers) { | 212 | private TwoWayMap<VisualContact, SignalStg> convertDriversToStgs(HashSet<VisualContact> drivers) { |
3274 | 213 | TwoWayMap<VisualContact, SignalStg> result = new TwoWayMap<>(); | 213 | TwoWayMap<VisualContact, SignalStg> result = new TwoWayMap<>(); |
3275 | 214 | for (VisualContact driver: drivers) { | 214 | for (VisualContact driver: drivers) { |
3277 | 215 | VisualContact signal = CircuitUtils.findSignal(circuit, driver); | 215 | VisualContact signal = CircuitUtils.findSignal(circuit, driver, true); |
3278 | 216 | Container container = getContainer(signal); | 216 | Container container = getContainer(signal); |
3279 | 217 | String signalName = CircuitUtils.getSignalName(circuit, signal); | 217 | String signalName = CircuitUtils.getSignalName(circuit, signal); |
3280 | 218 | 218 | ||
3281 | @@ -276,7 +276,7 @@ | |||
3282 | 276 | 276 | ||
3283 | 277 | clauses.addAll(dnf.getClauses()); | 277 | clauses.addAll(dnf.getClauses()); |
3284 | 278 | 278 | ||
3286 | 279 | VisualContact signal = CircuitUtils.findSignal(circuit, driver); | 279 | VisualContact signal = CircuitUtils.findSignal(circuit, driver, true); |
3287 | 280 | Container container = getContainer(signal); | 280 | Container container = getContainer(signal); |
3288 | 281 | String signalName = CircuitUtils.getSignalName(circuit, signal); | 281 | String signalName = CircuitUtils.getSignalName(circuit, signal); |
3289 | 282 | SignalTransition.Type signalType = CircuitUtils.getSignalType(circuit, signal); | 282 | SignalTransition.Type signalType = CircuitUtils.getSignalType(circuit, signal); |
3290 | @@ -459,7 +459,7 @@ | |||
3291 | 459 | for (VisualContact driver: drivers) { | 459 | for (VisualContact driver: drivers) { |
3292 | 460 | SignalStg signalStg = driverToStgMap.getValue(driver); | 460 | SignalStg signalStg = driverToStgMap.getValue(driver); |
3293 | 461 | if (signalStg != null) { | 461 | if (signalStg != null) { |
3295 | 462 | VisualContact signal = CircuitUtils.findSignal(circuit, driver); | 462 | VisualContact signal = CircuitUtils.findSignal(circuit, driver, true); |
3296 | 463 | Point2D centerPosition = getPosition(signal); | 463 | Point2D centerPosition = getPosition(signal); |
3297 | 464 | setPosition(signalStg.zero, Geometry.add(centerPosition, OFFSET_P0)); | 464 | setPosition(signalStg.zero, Geometry.add(centerPosition, OFFSET_P0)); |
3298 | 465 | setPosition(signalStg.one, Geometry.add(centerPosition, OFFSET_P1)); | 465 | setPosition(signalStg.one, Geometry.add(centerPosition, OFFSET_P1)); |
3299 | 466 | 466 | ||
3300 | === added file 'CircuitPlugin/src/org/workcraft/plugins/circuit/verilog/SubstitutionRule.java' | |||
3301 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/verilog/SubstitutionRule.java 1970-01-01 00:00:00 +0000 | |||
3302 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/verilog/SubstitutionRule.java 2015-11-09 09:38:45 +0000 | |||
3303 | @@ -0,0 +1,16 @@ | |||
3304 | 1 | package org.workcraft.plugins.circuit.verilog; | ||
3305 | 2 | |||
3306 | 3 | import java.util.Map; | ||
3307 | 4 | |||
3308 | 5 | public class SubstitutionRule { | ||
3309 | 6 | public final String oldName; | ||
3310 | 7 | public final String newName; | ||
3311 | 8 | public final Map<String, String> substitutions; | ||
3312 | 9 | |||
3313 | 10 | public SubstitutionRule(String oldName, String newName, Map<String, String> substitutions) { | ||
3314 | 11 | this.oldName = oldName; | ||
3315 | 12 | this.newName = newName; | ||
3316 | 13 | this.substitutions = substitutions; | ||
3317 | 14 | } | ||
3318 | 15 | |||
3319 | 16 | } | ||
3320 | 0 | 17 | ||
3321 | === modified file 'WorkcraftCore/src/org/workcraft/plugins/shared/CommonDebugSettings.java' | |||
3322 | --- WorkcraftCore/src/org/workcraft/plugins/shared/CommonDebugSettings.java 2015-10-13 17:22:00 +0000 | |||
3323 | +++ WorkcraftCore/src/org/workcraft/plugins/shared/CommonDebugSettings.java 2015-11-09 09:38:45 +0000 | |||
3324 | @@ -35,14 +35,17 @@ | |||
3325 | 35 | private static final String keyCopyModelOnChange = prefix + ".copyModelOnChange"; | 35 | private static final String keyCopyModelOnChange = prefix + ".copyModelOnChange"; |
3326 | 36 | private static final String keyKeepTemporaryFiles = prefix + ".keepTemporaryFiles"; | 36 | private static final String keyKeepTemporaryFiles = prefix + ".keepTemporaryFiles"; |
3327 | 37 | private static final String keyVerboseImport = prefix + ".verboseImport"; | 37 | private static final String keyVerboseImport = prefix + ".verboseImport"; |
3328 | 38 | private static final String keyParserTracing = prefix + ".parserTracing"; | ||
3329 | 38 | 39 | ||
3330 | 39 | private static final boolean defaultCopyModelOnChange = false; | 40 | private static final boolean defaultCopyModelOnChange = false; |
3331 | 40 | private static final Boolean defaultKeepTemporaryFiles = true; | 41 | private static final Boolean defaultKeepTemporaryFiles = true; |
3332 | 41 | private static final Boolean defaultVerboseImport = false; | 42 | private static final Boolean defaultVerboseImport = false; |
3333 | 43 | private static final Boolean defaultParserTracing = false; | ||
3334 | 42 | 44 | ||
3335 | 43 | private static boolean copyModelOnChange = defaultCopyModelOnChange; | 45 | private static boolean copyModelOnChange = defaultCopyModelOnChange; |
3336 | 44 | private static Boolean keepTemporaryFiles = defaultKeepTemporaryFiles; | 46 | private static Boolean keepTemporaryFiles = defaultKeepTemporaryFiles; |
3337 | 45 | private static Boolean verboseImport = defaultVerboseImport; | 47 | private static Boolean verboseImport = defaultVerboseImport; |
3338 | 48 | private static Boolean parserTracing = defaultParserTracing; | ||
3339 | 46 | 49 | ||
3340 | 47 | public CommonDebugSettings() { | 50 | public CommonDebugSettings() { |
3341 | 48 | properties.add(new PropertyDeclaration<CommonDebugSettings, Boolean>( | 51 | properties.add(new PropertyDeclaration<CommonDebugSettings, Boolean>( |
3342 | @@ -74,6 +77,16 @@ | |||
3343 | 74 | return getVerboseImport(); | 77 | return getVerboseImport(); |
3344 | 75 | } | 78 | } |
3345 | 76 | }); | 79 | }); |
3346 | 80 | |||
3347 | 81 | properties.add(new PropertyDeclaration<CommonDebugSettings, Boolean>( | ||
3348 | 82 | this, "Log tracing information from parsers", Boolean.class, true, false, false) { | ||
3349 | 83 | protected void setter(CommonDebugSettings object, Boolean value) { | ||
3350 | 84 | setParserTracing(value); | ||
3351 | 85 | } | ||
3352 | 86 | protected Boolean getter(CommonDebugSettings object) { | ||
3353 | 87 | return getParserTracing(); | ||
3354 | 88 | } | ||
3355 | 89 | }); | ||
3356 | 77 | } | 90 | } |
3357 | 78 | 91 | ||
3358 | 79 | @Override | 92 | @Override |
3359 | @@ -86,6 +99,7 @@ | |||
3360 | 86 | setCopyModelOnChange(config.getBoolean(keyCopyModelOnChange, defaultCopyModelOnChange)); | 99 | setCopyModelOnChange(config.getBoolean(keyCopyModelOnChange, defaultCopyModelOnChange)); |
3361 | 87 | setKeepTemporaryFiles(config.getBoolean(keyKeepTemporaryFiles, defaultKeepTemporaryFiles)); | 100 | setKeepTemporaryFiles(config.getBoolean(keyKeepTemporaryFiles, defaultKeepTemporaryFiles)); |
3362 | 88 | setVerboseImport(config.getBoolean(keyVerboseImport, defaultVerboseImport)); | 101 | setVerboseImport(config.getBoolean(keyVerboseImport, defaultVerboseImport)); |
3363 | 102 | setParserTracing(config.getBoolean(keyParserTracing, defaultParserTracing)); | ||
3364 | 89 | } | 103 | } |
3365 | 90 | 104 | ||
3366 | 91 | @Override | 105 | @Override |
3367 | @@ -93,6 +107,7 @@ | |||
3368 | 93 | config.setBoolean(keyCopyModelOnChange, getCopyModelOnChange()); | 107 | config.setBoolean(keyCopyModelOnChange, getCopyModelOnChange()); |
3369 | 94 | config.setBoolean(keyKeepTemporaryFiles, getKeepTemporaryFiles()); | 108 | config.setBoolean(keyKeepTemporaryFiles, getKeepTemporaryFiles()); |
3370 | 95 | config.setBoolean(keyVerboseImport, getVerboseImport()); | 109 | config.setBoolean(keyVerboseImport, getVerboseImport()); |
3371 | 110 | config.setBoolean(keyParserTracing, getParserTracing()); | ||
3372 | 96 | } | 111 | } |
3373 | 97 | 112 | ||
3374 | 98 | @Override | 113 | @Override |
3375 | @@ -128,5 +143,13 @@ | |||
3376 | 128 | public static void setVerboseImport(Boolean value) { | 143 | public static void setVerboseImport(Boolean value) { |
3377 | 129 | verboseImport = value; | 144 | verboseImport = value; |
3378 | 130 | } | 145 | } |
3379 | 146 | |||
3380 | 147 | public static Boolean getParserTracing() { | ||
3381 | 148 | return parserTracing; | ||
3382 | 149 | } | ||
3383 | 150 | |||
3384 | 151 | public static void setParserTracing(Boolean value) { | ||
3385 | 152 | parserTracing = value; | ||
3386 | 153 | } | ||
3387 | 131 | 154 | ||
3388 | 132 | } | 155 | } |