shlexer cleanup
This commit is contained in:
parent
77949c8d33
commit
ca1ca7db36
@ -49,24 +49,19 @@ class ShellLexer:
|
|||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
"""Read a raw token from the input stream."""
|
"""Read a raw token from the input stream."""
|
||||||
self.quoted = False
|
self.reset()
|
||||||
self.escapedstate = ' '
|
|
||||||
self.token = ''
|
|
||||||
self.state = ' '
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
nextchar = next(self.iterator)
|
nextchar = next(self.iterator)
|
||||||
except StopIteration:
|
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:
|
if self.state in self.escape and not self.keep:
|
||||||
self.token += self.state
|
self.token += self.state
|
||||||
if self.token or self.quoted:
|
if self.token or self.quoted:
|
||||||
yield self.token
|
yield self.token
|
||||||
return
|
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:
|
if nextchar in self.whitespace:
|
||||||
log.shlexer.vdebug("I see whitespace in whitespace state")
|
log.shlexer.vdebug("I see whitespace in whitespace state")
|
||||||
if self.keep:
|
if self.keep:
|
||||||
|
Loading…
Reference in New Issue
Block a user