summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-07-20 21:02:32 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-07-20 21:02:32 +0200
commitb4935b361bd16648044526efba818fb6839e0ca9 (patch)
treeac4a2db1be97aa503683fbaec6a7884da829c8b3
parent45b091f8a44c422d89f9d3bcaf25e5df91da31a7 (diff)
Still missing: Components, When Nodes, Outputs.
-rw-r--r--ast-to-instr/src/Functions.java9
-rw-r--r--ast-to-instr/src/IDs.java15
-rw-r--r--ast-to-instr/src/Main.java9
-rw-r--r--ast-to-instr/src/Predicates.java9
-rw-r--r--ast-to-instr/src/Strings.java10
-rw-r--r--ast-to-instr/src/VHDLCSNode.java30
-rw-r--r--ast-to-instr/src/VHDLEntity.java15
-rw-r--r--ast-to-instr/src/VHDLFile.java4
-rw-r--r--ast-to-instr/src/VHDLGeneric.java21
-rw-r--r--ast-to-instr/src/VHDLISNode.java60
-rw-r--r--ast-to-instr/src/VHDLPort.java2
-rw-r--r--ast-to-instr/src/VHDLSSASNode.java11
-rw-r--r--ast-to-instr/src/VHDLSignal.java2
-rw-r--r--ast-to-instr/src/VHDLWNode.java20
-rw-r--r--ast-to-instr/src/Waveforms.java10
15 files changed, 140 insertions, 87 deletions
diff --git a/ast-to-instr/src/Functions.java b/ast-to-instr/src/Functions.java
index 602c798..b500f21 100644
--- a/ast-to-instr/src/Functions.java
+++ b/ast-to-instr/src/Functions.java
@@ -6,6 +6,15 @@ public class Functions
final IDs... params
)
{
+ System.out.print("[FUN] (");
+ System.out.print(function_name);
+
+ for (final IDs param: params)
+ {
+ System.out.print(" " + param.get_value());
+ }
+
+ System.out.println(")");
/* TODO */
}
}
diff --git a/ast-to-instr/src/IDs.java b/ast-to-instr/src/IDs.java
index 00c0f49..ed37917 100644
--- a/ast-to-instr/src/IDs.java
+++ b/ast-to-instr/src/IDs.java
@@ -31,7 +31,7 @@ public class IDs
if (result == null)
{
- result = new IDs(type);
+ result = generate_new_id(type);
FROM_XML.put(xml_id, result);
}
@@ -56,6 +56,19 @@ public class IDs
ALL_IDS.add(result);
+ /* TODO: remove, it's for debug. */
+ if (type != null)
+ {
+ System.out.println
+ (
+ "[ID] ("
+ + result.get_type()
+ + " "
+ + result.get_value()
+ + ")"
+ );
+ }
+
return result;
}
diff --git a/ast-to-instr/src/Main.java b/ast-to-instr/src/Main.java
index 6455e19..104c4f7 100644
--- a/ast-to-instr/src/Main.java
+++ b/ast-to-instr/src/Main.java
@@ -20,8 +20,9 @@ public class Main
XPE_FIND_ALL_VHDL_FILES =
XMLManager.compile_or_die
(
- "./*/*/el[@kind=\"design_file\"][@file]"
- );
+ //"./*/*/el[@kind=\"design_file\"][@file]"
+ "//el[@kind=\"design_file\"][@file]"
+ );
}
public static void main (final String... args)
@@ -76,6 +77,8 @@ public class Main
return;
}
+
+ parse_content(vhdl_files);
}
private static void parse_content (final Collection<Node> vhdl_files)
@@ -87,6 +90,7 @@ public class Main
for (final Node f: vhdl_files)
{
+ System.out.println("New VHDL file in the waiting list.");
waiting_list.push(new VHDLFile(null, f));
}
@@ -96,6 +100,7 @@ public class Main
try
{
+ System.out.println("Parsing XML...");
children = waiting_list.pop().parse();
}
catch (final XPathExpressionException xpee)
diff --git a/ast-to-instr/src/Predicates.java b/ast-to-instr/src/Predicates.java
index 9e45cac..9d4c308 100644
--- a/ast-to-instr/src/Predicates.java
+++ b/ast-to-instr/src/Predicates.java
@@ -6,6 +6,15 @@ public class Predicates
final IDs... params
)
{
+ System.out.print("[PRE] (");
+ System.out.print(predicate_name);
+
+ for (final IDs param: params)
+ {
+ System.out.print(" " + param.get_value());
+ }
+
+ System.out.println(")");
/* TODO */
}
}
diff --git a/ast-to-instr/src/Strings.java b/ast-to-instr/src/Strings.java
index 2c81b70..5657cac 100644
--- a/ast-to-instr/src/Strings.java
+++ b/ast-to-instr/src/Strings.java
@@ -24,6 +24,16 @@ public class Strings
result = IDs.generate_new_id("string");
TO_ID.put(string, result);
+
+ /* TODO: remove, it's for debug. */
+ System.out.println
+ (
+ "[STR] (\""
+ + string
+ + "\"->"
+ + result.get_value()
+ + ")"
+ );
}
return result;
diff --git a/ast-to-instr/src/VHDLCSNode.java b/ast-to-instr/src/VHDLCSNode.java
index 8c30795..7ed0ff5 100644
--- a/ast-to-instr/src/VHDLCSNode.java
+++ b/ast-to-instr/src/VHDLCSNode.java
@@ -8,7 +8,7 @@ import javax.xml.xpath.XPathExpressionException;
import java.util.ArrayList;
import java.util.Collection;
-/* If Statement Node */
+/* Case Statement Node */
public class VHDLCSNode extends VHDLNode
{
private static final XPathExpression XPE_FIND_SOURCES;
@@ -17,20 +17,24 @@ public class VHDLCSNode extends VHDLNode
static
{
- XPE_FIND_SOURCES = XMLManager.compile_or_die
- (
- "./expression//named_entity"
- );
+ XPE_FIND_SOURCES =
+ XMLManager.compile_or_die
+ (
+ "./expression//named_entity"
+ );
- XPE_FIND_OTHERS_BRANCH = XMLManager.compile_or_die
- (
- "./case_statement_alternative_chain/el[@kind=\"choice_by_others\"]"
- );
+ XPE_FIND_OTHERS_BRANCH =
+ XMLManager.compile_or_die
+ (
+ "./case_statement_alternative_chain/el[@kind=\"choice_by_others\"]"
+ );
- XPE_FIND_WHEN_BRANCHES = XMLManager.compile_or_die
- (
- "./case_statement_alternative_chain/el[@kind=\"choice_by_expression\"]"
- );
+ XPE_FIND_WHEN_BRANCHES =
+ XMLManager.compile_or_die
+ (
+ "./case_statement_alternative_chain/el"
+ + "[@kind=\"choice_by_expression\"]"
+ );
}
public VHDLCSNode
diff --git a/ast-to-instr/src/VHDLEntity.java b/ast-to-instr/src/VHDLEntity.java
index f552d69..9ece7e0 100644
--- a/ast-to-instr/src/VHDLEntity.java
+++ b/ast-to-instr/src/VHDLEntity.java
@@ -15,8 +15,17 @@ public class VHDLEntity extends ParsableXML
static
{
- XPE_FIND_PORTS = null; /* TODO */
- XPE_FIND_GENERICS = null; /* TODO */
+ XPE_FIND_PORTS =
+ XMLManager.compile_or_die
+ (
+ "./port_chain/el[@kind=\"interface_signal_declaration\"]"
+ );
+
+ XPE_FIND_GENERICS =
+ XMLManager.compile_or_die
+ (
+ "./generic_chain/el[@kind=\"interface_constant_declaration\"]"
+ );
}
public VHDLEntity
@@ -265,7 +274,7 @@ public class VHDLEntity extends ParsableXML
result = new ArrayList<ParsableXML>();
generics =
- (NodeList) XPE_FIND_PORTS.evaluate
+ (NodeList) XPE_FIND_GENERICS.evaluate
(
xml_node,
XPathConstants.NODESET
diff --git a/ast-to-instr/src/VHDLFile.java b/ast-to-instr/src/VHDLFile.java
index 991e54e..c619a1b 100644
--- a/ast-to-instr/src/VHDLFile.java
+++ b/ast-to-instr/src/VHDLFile.java
@@ -24,7 +24,7 @@ public class VHDLFile extends ParsableXML
XPE_FIND_ARCHITECTURES =
XMLManager.compile_or_die
(
- "./*/*/library_unit[@kind=\"entity_declaration\"]"
+ "./*/*/library_unit[@kind=\"architecture_body\"]"
);
}
@@ -127,7 +127,7 @@ public class VHDLFile extends ParsableXML
result = new ArrayList<ParsableXML>();
architectures =
- (NodeList) XPE_FIND_ENTITIES.evaluate
+ (NodeList) XPE_FIND_ARCHITECTURES.evaluate
(
xml_node,
XPathConstants.NODESET
diff --git a/ast-to-instr/src/VHDLGeneric.java b/ast-to-instr/src/VHDLGeneric.java
index e080841..866ae95 100644
--- a/ast-to-instr/src/VHDLGeneric.java
+++ b/ast-to-instr/src/VHDLGeneric.java
@@ -48,12 +48,11 @@ public class VHDLGeneric extends ParsableXML
handle_predicate_has_visible_flag(local_id);
handle_predicate_has_after_drivers_flag(local_id);
handle_predicate_has_use_flag(local_id);
- handle_predicate_has_guarded_signal_flag(local_id);
/** Children ************************************************************/
handle_child_waveform(local_id);
- return null;
+ return result;
}
/***************************************************************************/
@@ -230,24 +229,6 @@ public class VHDLGeneric extends ParsableXML
}
}
- private void handle_predicate_has_guarded_signal_flag
- (
- final IDs local_id
- )
- {
- if
- (
- XMLManager.get_attribute
- (
- xml_node,
- "guarded_signal_flag"
- ).equals("true")
- )
- {
- Predicates.add_entry("has_guarded_signal_flag", local_id);
- }
- }
-
/***************************************************************************/
/** Children ***************************************************************/
/***************************************************************************/
diff --git a/ast-to-instr/src/VHDLISNode.java b/ast-to-instr/src/VHDLISNode.java
index 9bf7810..f38dcf3 100644
--- a/ast-to-instr/src/VHDLISNode.java
+++ b/ast-to-instr/src/VHDLISNode.java
@@ -17,20 +17,23 @@ public class VHDLISNode extends VHDLNode
static
{
- XPE_FIND_NAMED_ENTITIES = XMLManager.compile_or_die
- (
- "./condition//named_entity"
- );
+ XPE_FIND_NAMED_ENTITIES =
+ XMLManager.compile_or_die
+ (
+ "./condition//named_entity"
+ );
- XPE_FIND_TRUE_BRANCH = XMLManager.compile_or_die
- (
- "./sequential_statement_chain"
- );
+ XPE_FIND_TRUE_BRANCH =
+ XMLManager.compile_or_die
+ (
+ "./sequential_statement_chain"
+ );
- XPE_FIND_ELSE_BRANCH = XMLManager.compile_or_die
- (
- "./else_clause/sequential_statement_chain"
- );
+ XPE_FIND_ELSE_BRANCH =
+ XMLManager.compile_or_die
+ (
+ "./else_clause/sequential_statement_chain"
+ );
}
public VHDLISNode
@@ -77,7 +80,7 @@ public class VHDLISNode extends VHDLNode
handle_predicate_expr_reads(local_id);
/** Children ************************************************************/
- result.addAll(handle_true_branch(local_id));
+ result.add(handle_true_branch(local_id));
result.addAll(handle_else_branch(local_id));
return result;
@@ -200,17 +203,14 @@ public class VHDLISNode extends VHDLNode
/***************************************************************************/
/** Children ***************************************************************/
/***************************************************************************/
- private Collection<ParsableXML> handle_true_branch
+ private ParsableXML handle_true_branch
(
final IDs local_id
)
throws XPathExpressionException
{
- final Collection<ParsableXML> result;
final Node true_branch;
- result = new ArrayList<ParsableXML>();
-
true_branch =
(Node) XPE_FIND_TRUE_BRANCH.evaluate
(
@@ -218,21 +218,19 @@ public class VHDLISNode extends VHDLNode
XPathConstants.NODE
);
-
- result.add
- (
- new VHDLSSCNode
+ return
(
- parent_id,
- true_branch,
- local_id,
- next_node,
- (depth + 1),
- new String[] {"COND_WAS_TRUE"}
- )
- );
+ new VHDLSSCNode
+ (
+ parent_id,
+ true_branch,
+ local_id,
+ next_node,
+ (depth + 1),
+ new String[] {"COND_WAS_TRUE"}
+ )
+ );
- return result;
}
private Collection<ParsableXML> handle_else_branch
@@ -247,7 +245,7 @@ public class VHDLISNode extends VHDLNode
result = new ArrayList<ParsableXML>();
else_branch =
- (Node) XPE_FIND_TRUE_BRANCH.evaluate
+ (Node) XPE_FIND_ELSE_BRANCH.evaluate
(
xml_node,
XPathConstants.NODE
diff --git a/ast-to-instr/src/VHDLPort.java b/ast-to-instr/src/VHDLPort.java
index f343126..3670605 100644
--- a/ast-to-instr/src/VHDLPort.java
+++ b/ast-to-instr/src/VHDLPort.java
@@ -58,7 +58,7 @@ public class VHDLPort extends ParsableXML
/** Children ************************************************************/
handle_child_waveform(local_id);
- return null;
+ return result;
}
/***************************************************************************/
diff --git a/ast-to-instr/src/VHDLSSASNode.java b/ast-to-instr/src/VHDLSSASNode.java
index dd7d9cd..8c84e96 100644
--- a/ast-to-instr/src/VHDLSSASNode.java
+++ b/ast-to-instr/src/VHDLSSASNode.java
@@ -8,7 +8,7 @@ import javax.xml.xpath.XPathExpressionException;
import java.util.ArrayList;
import java.util.Collection;
-/* If Statement Node */
+/* Simple Signal Assignment Statement Node */
public class VHDLSSASNode extends VHDLNode
{
private static final XPathExpression XPE_FIND_TARGET;
@@ -20,10 +20,11 @@ public class VHDLSSASNode extends VHDLNode
{
XPE_FIND_TARGET = XMLManager.compile_or_die("./target");
- XPE_FIND_SOURCES = XMLManager.compile_or_die
- (
- "./waveform_chain//named_entity"
- );
+ XPE_FIND_SOURCES =
+ XMLManager.compile_or_die
+ (
+ "./waveform_chain//named_entity"
+ );
XPE_FIND_PREFIXED_NE = XMLManager.compile_or_die("./prefix/named_entity");
XPE_FIND_NE = XMLManager.compile_or_die("./named_entity");
diff --git a/ast-to-instr/src/VHDLSignal.java b/ast-to-instr/src/VHDLSignal.java
index 72a95ee..e171576 100644
--- a/ast-to-instr/src/VHDLSignal.java
+++ b/ast-to-instr/src/VHDLSignal.java
@@ -56,7 +56,7 @@ public class VHDLSignal extends ParsableXML
/** Children ************************************************************/
handle_child_waveform(local_id);
- return null;
+ return result;
}
/***************************************************************************/
diff --git a/ast-to-instr/src/VHDLWNode.java b/ast-to-instr/src/VHDLWNode.java
index ac23be8..eda4836 100644
--- a/ast-to-instr/src/VHDLWNode.java
+++ b/ast-to-instr/src/VHDLWNode.java
@@ -8,14 +8,18 @@ import javax.xml.xpath.XPathExpressionException;
import java.util.ArrayList;
import java.util.Collection;
-/* If Statement Node */
+/* When Node */
public class VHDLWNode extends VHDLNode
{
- private static final XPathExpression XPE_FIND_SUB_NODES;
+ private static final XPathExpression XPE_FIND_NAMED_ENTITIES;
static
{
- XPE_FIND_SUB_NODES = XMLManager.compile_or_die("./el");
+ XPE_FIND_NAMED_ENTITIES =
+ XMLManager.compile_or_die
+ (
+ "./choice_expression//named_entity"
+ );
}
public VHDLWNode
@@ -61,6 +65,9 @@ public class VHDLWNode extends VHDLNode
handle_predicate_has_option(local_id);
handle_predicate_expr_reads(local_id);
+ /** Children ************************************************************/
+ //result.add(handle_body(local_id));
+
return result;
}
@@ -76,10 +83,7 @@ public class VHDLWNode extends VHDLNode
(
"label",
local_id,
- Strings.get_id_from_string
- (
- XMLManager.get_attribute(xml_node, "label")
- )
+ Strings.get_id_from_string("")
);
}
@@ -149,7 +153,7 @@ public class VHDLWNode extends VHDLNode
final int named_entities_count;
named_entities =
- (NodeList) XPE_FIND_SOURCES.evaluate
+ (NodeList) XPE_FIND_NAMED_ENTITIES.evaluate
(
xml_node,
XPathConstants.NODESET
diff --git a/ast-to-instr/src/Waveforms.java b/ast-to-instr/src/Waveforms.java
index 753bae3..7e86904 100644
--- a/ast-to-instr/src/Waveforms.java
+++ b/ast-to-instr/src/Waveforms.java
@@ -23,6 +23,16 @@ public class Waveforms
result = IDs.generate_new_id("waveform");
TO_WAVEFORM.put(source, result);
+
+ /* TODO: remove, it's for debug. */
+ System.out.println
+ (
+ "[WFM] ("
+ + source.get_value()
+ + "->"
+ + result.get_value()
+ + ")"
+ );
}
return result;