Remove Whitespace class and replace it with Newline and Endmarker.

This commit is contained in:
Dave Halter
2016-07-24 17:16:36 +02:00
parent 7f2f66f011
commit ff47fab62a
5 changed files with 17 additions and 10 deletions

View File

@@ -147,7 +147,7 @@ class Base(object):
return scope
def get_definition(self):
if self.type in ('whitespace', 'dedent', 'indent'):
if self.type in ('newline', 'dedent', 'indent', 'endmarker'):
raise ValueError('Cannot get the indentation of whitespace or indentation.')
scope = self
while scope.parent is not None:
@@ -354,10 +354,15 @@ class LeafWithNewLines(Leaf):
return "<%s: %r>" % (type(self).__name__, self.value)
class Whitespace(LeafWithNewLines):
class EndMarker(Leaf):
__slots__ = ()
type = 'endmarker'
class Newline(LeafWithNewLines):
"""Contains NEWLINE and ENDMARKER tokens."""
__slots__ = ()
type = 'whitespace'
type = 'newline'
@utf8_repr
def __repr__(self):