aboutsummaryrefslogtreecommitdiff
path: root/parser
diff options
context:
space:
mode:
Diffstat (limited to 'parser')
-rw-r--r--parser/parser.go54
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