From 0caf1994dae8e88f7c219bedd87b65190b88aa89 Mon Sep 17 00:00:00 2001 From: j-james Date: Sun, 16 Oct 2022 23:58:44 -0700 Subject: Implement LL(1) parsers for HTML and CSS --- src/main/model/html/HtmlTree.java | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/main/model/html/HtmlTree.java (limited to 'src/main/model/html/HtmlTree.java') 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>>> { + private String tag; + private ArrayList> attributes; + private Optional parent = Optional.empty(); + private Optional sibling = Optional.empty(); + + // I don't quite know why I can't say ArrayList children. + public HtmlTree(String tag, ArrayList> attributes, + ArrayList>>>> children, + Optional parent, Optional sibling) { + super(new Pair<>(tag, attributes), children); + this.tag = tag; + this.attributes = attributes; + this.parent = parent; + this.sibling = sibling; + } + + public HtmlTree(String tag, ArrayList> attributes) { + this(tag, attributes, new ArrayList>>>>(), + Optional.empty(), Optional.empty()); + } +} -- cgit v1.2.3-70-g09d2