summaryrefslogtreecommitdiffstats
path: root/src/syntaxParser/List.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/syntaxParser/List.java')
-rw-r--r--src/syntaxParser/List.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/syntaxParser/List.java b/src/syntaxParser/List.java
new file mode 100644
index 0000000..685c504
--- /dev/null
+++ b/src/syntaxParser/List.java
@@ -0,0 +1,42 @@
+package syntaxParser;
+/* Author: Sorin stancu-Mara
+ * date: 8 feb 2008
+ * All the lists have the same caracteristics, therfore all of them derive from this class
+ * No need to verify that the list contain same type of elements since they are created using the grammar.
+ */
+
+class List implements IParseTreeNode {
+ IParseTreeNode element;
+ List next;
+ String tag;
+
+ public List(IParseTreeNode elem) {
+ element = elem;
+ next = null;
+ }
+
+ public List(IParseTreeNode elem, List next) {
+ element = elem;
+ this.next = next;
+ }
+
+ public void setTag(String tagName) {
+ tag = tagName;
+ if (next != null) {
+ next.setTag(tag);
+ }
+ }
+
+ public String toXML() {
+ String result = "";
+ if (tag != null) {
+ result += "<" + tag + ">";
+ result += element.toXML();
+ result += "</" + tag + ">";
+ } else
+ result += element.toXML();
+ if (next != null)
+ result += next.toXML();
+ return result;
+ }
+}