aboutsummaryrefslogtreecommitdiff
path: root/src/main/model/html/HtmlTree.java
diff options
context:
space:
mode:
authorj-james2022-10-17 06:58:44 +0000
committerj-james2022-10-17 07:00:53 +0000
commit0caf1994dae8e88f7c219bedd87b65190b88aa89 (patch)
tree6b9302c64eb74194e8ed1f267ec711c038b514cd /src/main/model/html/HtmlTree.java
parent3e9bb5fae16c35938bc1f7f7669c12cc355c9331 (diff)
Implement LL(1) parsers for HTML and CSS
Diffstat (limited to 'src/main/model/html/HtmlTree.java')
-rw-r--r--src/main/model/html/HtmlTree.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/model/html/HtmlTree.java b/src/main/model/html/HtmlTree.java
new file mode 100644
index 0000000..1aae0a8
--- /dev/null
+++ b/src/main/model/html/HtmlTree.java
@@ -0,0 +1,33 @@
+package model.html;
+
+import model.util.AbstractTree;
+import org.javatuples.Pair;
+
+import java.util.ArrayList;
+import java.util.Optional;
+
+/**
+ * Representation of HTML as a tree of nodes. Sorry about the generics.
+ */
+public class HtmlTree extends AbstractTree<Pair<String, ArrayList<Pair<String, String>>>> {
+ private String tag;
+ private ArrayList<Pair<String, String>> attributes;
+ private Optional<HtmlTree> parent = Optional.empty();
+ private Optional<HtmlTree> sibling = Optional.empty();
+
+ // I don't quite know why I can't say ArrayList<HtmlTree> children.
+ public HtmlTree(String tag, ArrayList<Pair<String, String>> attributes,
+ ArrayList<AbstractTree<Pair<String, ArrayList<Pair<String, String>>>>> children,
+ Optional<HtmlTree> parent, Optional<HtmlTree> sibling) {
+ super(new Pair<>(tag, attributes), children);
+ this.tag = tag;
+ this.attributes = attributes;
+ this.parent = parent;
+ this.sibling = sibling;
+ }
+
+ public HtmlTree(String tag, ArrayList<Pair<String, String>> attributes) {
+ this(tag, attributes, new ArrayList<AbstractTree<Pair<String, ArrayList<Pair<String, String>>>>>(),
+ Optional.empty(), Optional.empty());
+ }
+}