Skip to content

Commit 9738426

Browse files
committed
no more token classes; dicts rule tokenizer.py now
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40337
1 parent 1c35bfa commit 9738426

3 files changed

Lines changed: 106 additions & 184 deletions

File tree

src/parser.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,15 @@ def parse(self, stream, innerHTML=False):
163163
# XXX This is temporary for the moment so there isn't any other
164164
# changes needed for the parser to work with the iterable tokenizer
165165
for token in self.tokenizer:
166-
tokenClass = token.__class__.__name__
167-
method = getattr(self.phase, 'process%s' % tokenClass, None)
168-
if tokenClass in ('Characters', 'Comment'):
169-
method(token.data)
170-
elif tokenClass in ('Doctype', 'StartTag'):
171-
method(token.name, token.data)
172-
elif tokenClass == 'EndTag':
173-
method(token.name)
174-
elif tokenClass == 'ParseError':
166+
type = token["type"]
167+
method = getattr(self.phase, "process%s" % type, None)
168+
if type in ("Characters", "Comment"):
169+
method(token["data"])
170+
elif type in ("Doctype", "StartTag"):
171+
method(token["name"], token["data"])
172+
elif type == "EndTag":
173+
method(token["name"])
174+
elif type == "ParseError":
175175
self.parseError()
176176
else:
177177
self.atheistParseError()

0 commit comments

Comments
 (0)