shlexer cleanup

This commit is contained in:
Florian Bruhin 2014-11-06 07:13:58 +01:00
parent 77949c8d33
commit ca1ca7db36

View File

@ -49,24 +49,19 @@ class ShellLexer:
def __iter__(self):
"""Read a raw token from the input stream."""
self.quoted = False
self.escapedstate = ' '
self.token = ''
self.state = ' '
self.reset()
while True:
try:
nextchar = next(self.iterator)
except StopIteration:
nextchar = None
log.shlexer.vdebug("in state {!r} I see character: {!r}".format(
self.state, nextchar))
if nextchar is None:
if self.state in self.escape and not self.keep:
self.token += self.state
if self.token or self.quoted:
yield self.token
return
elif self.state == ' ':
log.shlexer.vdebug("in state {!r} I see character: {!r}".format(
self.state, nextchar))
if self.state == ' ':
if nextchar in self.whitespace:
log.shlexer.vdebug("I see whitespace in whitespace state")
if self.keep: