mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
and/or up to run_subproc()
This commit is contained in:
parent
79e02c7d72
commit
2aab43b9a4
4 changed files with 19 additions and 4 deletions
|
@ -494,7 +494,10 @@ def run_subproc(cmds, captured=True):
|
|||
stdin = None
|
||||
stderr = None
|
||||
if isinstance(cmd, string_types):
|
||||
continue
|
||||
if cmd == '|':
|
||||
continue
|
||||
else:
|
||||
raise RuntimeError('{0!r} not understood'.format(cmd))
|
||||
streams = {}
|
||||
while True:
|
||||
if len(cmd) >= 3 and _is_redirect(cmd[-2]):
|
||||
|
|
|
@ -93,6 +93,14 @@ def handle_name(state, token, stream):
|
|||
else:
|
||||
state['last'] = n
|
||||
yield _new_token('IOREDIRECT', string, token.start)
|
||||
elif token.string == 'and':
|
||||
yield _new_token('AND', token.string, token.start)
|
||||
if n is not None:
|
||||
yield from handle_token(state, n, stream)
|
||||
elif token.string == 'or':
|
||||
yield _new_token('OR', token.string, token.start)
|
||||
if n is not None:
|
||||
yield from handle_token(state, n, stream)
|
||||
else:
|
||||
yield _new_token('NAME', token.string, token.start)
|
||||
if n is not None:
|
||||
|
|
|
@ -83,12 +83,12 @@ except ImportError:
|
|||
codec = lookup(encoding)
|
||||
except LookupError:
|
||||
# This behaviour mimics the Python interpreter
|
||||
raise SyntaxError("unknown encoding: " + encoding)
|
||||
raise SyntaxError("unknown encoding: " + encoding, filename='<file>')
|
||||
|
||||
if bom_found:
|
||||
if codec.name != 'utf-8':
|
||||
# This behaviour mimics the Python interpreter
|
||||
raise SyntaxError('encoding problem: utf-8')
|
||||
raise SyntaxError('encoding problem: utf-8', filename='<file>')
|
||||
encoding += '-sig'
|
||||
return encoding
|
||||
|
||||
|
|
|
@ -375,12 +375,14 @@ class BaseParser(object):
|
|||
def _parse_error(self, msg, loc):
|
||||
err = SyntaxError('{0}: {1}'.format(loc, msg))
|
||||
err.loc = loc
|
||||
err.filename = '<xonsh-parser>'
|
||||
raise err
|
||||
|
||||
#
|
||||
# Precedence of operators
|
||||
#
|
||||
precedence = (('left', 'PIPE'), ('left', 'XOR'), ('left', 'AMPERSAND'),
|
||||
precedence = (('left', 'PIPE'),
|
||||
('left', 'XOR'), ('left', 'AMPERSAND'),
|
||||
('left', 'EQ', 'NE'), ('left', 'GT', 'GE', 'LT', 'LE'),
|
||||
('left', 'RSHIFT', 'LSHIFT'), ('left', 'PLUS', 'MINUS'),
|
||||
('left', 'TIMES', 'DIVIDE', 'DOUBLEDIV', 'MOD'),
|
||||
|
@ -2108,6 +2110,7 @@ class BaseParser(object):
|
|||
| WS DOUBLEAMP
|
||||
| DOUBLEAMP WS
|
||||
| WS DOUBLEAMP WS
|
||||
| AND WS
|
||||
| WS AND WS
|
||||
"""
|
||||
p[0] = ast.Str(s='and', lineno=self.lineno, col_offset=self.col)
|
||||
|
@ -2117,6 +2120,7 @@ class BaseParser(object):
|
|||
| WS DOUBLEPIPE
|
||||
| DOUBLEPIPE WS
|
||||
| WS DOUBLEPIPE WS
|
||||
| OR WS
|
||||
| WS OR WS
|
||||
"""
|
||||
p[0] = ast.Str(s='or', lineno=self.lineno, col_offset=self.col)
|
||||
|
|
Loading…
Add table
Reference in a new issue