From adb23b20e8d2f360e9b20499bff10734890810ac Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 10 Sep 2023 20:19:26 +0200 Subject: Remove all XML support --- parser/parser.go | 54 +----------------------------------------------------- 1 file changed, 1 insertion(+), 53 deletions(-) (limited to 'parser/parser.go') diff --git a/parser/parser.go b/parser/parser.go index 946cc97..d8f7eb6 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -12,14 +12,11 @@ import ( type nodeType uint const ( - DocType nodeType = iota - Normal + Normal = iota Tagless Text ) -var Xml = false - type Attr struct { Key string Value string @@ -39,12 +36,6 @@ func ParseFile(file *os.File) (AstNode, error) { func (reader *reader) parseDocument() (AstNode, error) { document := AstNode{Type: Tagless} - if doctype, err, exists := reader.parseDocType(); err != nil { - return AstNode{}, err - } else if exists { - document.Children = append(document.Children, doctype) - } - if node, err := reader.parseNode(); err != nil { return AstNode{}, err } else { @@ -54,49 +45,6 @@ func (reader *reader) parseDocument() (AstNode, error) { return document, nil } -func (reader *reader) parseDocType() (AstNode, error, bool) { - doctype := AstNode{} - - r, err := reader.readNonSpaceRune() - if err != nil { - return AstNode{}, err, false - } - - switch r { - case '?': - Xml = true - fallthrough - case '!': - doctype.Type = DocType - default: - return AstNode{}, reader.unreadRune(), false - } - - if attrs, err := reader.parseAttrs(); err != nil { - return AstNode{}, err, false - } else { - doctype.Attrs = attrs - } - - // The above call to reader.parseAttrs() guarantees that we have the ā€˜{ā€™ - // token. - if _, err := reader.readRune(); err != nil { - return AstNode{}, err, false - } - - if r, err := reader.readNonSpaceRune(); err != nil { - return AstNode{}, err, false - } else if r != '}' { - return AstNode{}, invalidSyntax{ - pos: reader.pos, - expected: "empty body (doctypes must have empty bodies)", - found: fmt.Sprintf("ā€˜%cā€™\n", r), - }, false - } - - return doctype, nil, true -} - func (reader *reader) parseNode() (AstNode, error) { if err := reader.skipSpaces(); err != nil { return AstNode{}, err -- cgit v1.2.3