diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-09-10 20:19:26 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-09-10 20:20:00 +0200 |
commit | adb23b20e8d2f360e9b20499bff10734890810ac (patch) | |
tree | 916aba7b040755d1e5cab033049f55e037ccf1b1 /parser | |
parent | 7eac3c24255a86257d42ab38668cbd88dc96f55b (diff) |
Remove all XML support
Diffstat (limited to 'parser')
-rw-r--r-- | parser/parser.go | 54 |
1 files changed, 1 insertions, 53 deletions
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 |