fixed whitespace issue

This commit is contained in:
Anthony Scopatz 2015-01-23 20:35:54 -06:00
parent 5acaae9fd3
commit 044fca0df7
2 changed files with 12 additions and 3 deletions

View file

@ -70,6 +70,15 @@ def test_indent():
assert_tokens_equal(exp, obs)
def test_post_whitespace():
l = Lexer()
l.build()
l.input('42 \t ')
obs = list(l)
exp = [('INT_LITERAL', '42', 1, 0)]
assert_tokens_equal(exp, obs)
if __name__ == '__main__':

View file

@ -87,7 +87,7 @@ class Lexer(object):
#
tokens = pykeywords + (
# Misc
'ID', 'INDENT', 'NEWLINE',
'ID', 'INDENT', 'NEWLINE', 'WHITESPACE',
# literals
'INT_LITERAL', 'HEX_LITERAL', 'OCT_LITERAL', 'BIN_LITERAL',
@ -145,8 +145,8 @@ class Lexer(object):
#
# Rules
#
t_INDENT = '^[ \t]+'
t_ignore = ' \t'
t_INDENT = r'^[ \t]+'
t_ignore_WHITESPACE = r' \t'
# Newlines
def t_NEWLINE(self, t):