mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-18 00:58:08 +00:00
[lit] Use more modern syntax for constructing exceptions.
llvm-svn: 187853
This commit is contained in:
parent
156c1522d4
commit
44d0ad7767
@ -20,14 +20,14 @@ class Command:
|
|||||||
elif '"' not in arg and '$' not in arg:
|
elif '"' not in arg and '$' not in arg:
|
||||||
quoted = '"%s"' % arg
|
quoted = '"%s"' % arg
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError,'Unable to quote %r' % arg
|
raise NotImplementedError('Unable to quote %r' % arg)
|
||||||
print >>file, quoted,
|
print >>file, quoted,
|
||||||
|
|
||||||
# For debugging / validation.
|
# For debugging / validation.
|
||||||
import ShUtil
|
import ShUtil
|
||||||
dequoted = list(ShUtil.ShLexer(quoted).lex())
|
dequoted = list(ShUtil.ShLexer(quoted).lex())
|
||||||
if dequoted != [arg]:
|
if dequoted != [arg]:
|
||||||
raise NotImplementedError,'Unable to quote %r' % arg
|
raise NotImplementedError('Unable to quote %r' % arg)
|
||||||
|
|
||||||
for r in self.redirects:
|
for r in self.redirects:
|
||||||
if len(r[0]) == 1:
|
if len(r[0]) == 1:
|
||||||
@ -54,7 +54,7 @@ class Pipeline:
|
|||||||
|
|
||||||
def toShell(self, file, pipefail=False):
|
def toShell(self, file, pipefail=False):
|
||||||
if pipefail != self.pipe_err:
|
if pipefail != self.pipe_err:
|
||||||
raise ValueError,'Inconsistent "pipefail" attribute!'
|
raise ValueError('Inconsistent "pipefail" attribute!')
|
||||||
if self.negate:
|
if self.negate:
|
||||||
print >>file, '!',
|
print >>file, '!',
|
||||||
for cmd in self.commands:
|
for cmd in self.commands:
|
||||||
|
@ -116,9 +116,11 @@ class ShLexer:
|
|||||||
reference = self.lex_arg_slow(c)
|
reference = self.lex_arg_slow(c)
|
||||||
if res is not None:
|
if res is not None:
|
||||||
if res != reference:
|
if res != reference:
|
||||||
raise ValueError,"Fast path failure: %r != %r" % (res, reference)
|
raise ValueError("Fast path failure: %r != %r" % (
|
||||||
|
res, reference))
|
||||||
if self.pos != end:
|
if self.pos != end:
|
||||||
raise ValueError,"Fast path failure: %r != %r" % (self.pos, end)
|
raise ValueError("Fast path failure: %r != %r" % (
|
||||||
|
self.pos, end))
|
||||||
return reference
|
return reference
|
||||||
|
|
||||||
def lex_arg(self, c):
|
def lex_arg(self, c):
|
||||||
@ -186,9 +188,9 @@ class ShParser:
|
|||||||
def parse_command(self):
|
def parse_command(self):
|
||||||
tok = self.lex()
|
tok = self.lex()
|
||||||
if not tok:
|
if not tok:
|
||||||
raise ValueError,"empty command!"
|
raise ValueError("empty command!")
|
||||||
if isinstance(tok, tuple):
|
if isinstance(tok, tuple):
|
||||||
raise ValueError,"syntax error near unexpected token %r" % tok[0]
|
raise ValueError("syntax error near unexpected token %r" % tok[0])
|
||||||
|
|
||||||
args = [tok]
|
args = [tok]
|
||||||
redirects = []
|
redirects = []
|
||||||
@ -213,7 +215,7 @@ class ShParser:
|
|||||||
op = self.lex()
|
op = self.lex()
|
||||||
arg = self.lex()
|
arg = self.lex()
|
||||||
if not arg:
|
if not arg:
|
||||||
raise ValueError,"syntax error near token %r" % op[0]
|
raise ValueError("syntax error near token %r" % op[0])
|
||||||
redirects.append((op, arg))
|
redirects.append((op, arg))
|
||||||
|
|
||||||
return Command(args, redirects)
|
return Command(args, redirects)
|
||||||
@ -235,7 +237,8 @@ class ShParser:
|
|||||||
assert isinstance(operator, tuple) and len(operator) == 1
|
assert isinstance(operator, tuple) and len(operator) == 1
|
||||||
|
|
||||||
if not self.look():
|
if not self.look():
|
||||||
raise ValueError, "missing argument to operator %r" % operator[0]
|
raise ValueError(
|
||||||
|
"missing argument to operator %r" % operator[0])
|
||||||
|
|
||||||
# FIXME: Operator precedence!!
|
# FIXME: Operator precedence!!
|
||||||
lhs = Seq(lhs, operator[0], self.parse_pipeline())
|
lhs = Seq(lhs, operator[0], self.parse_pipeline())
|
||||||
|
@ -66,7 +66,7 @@ def executeShCmd(cmd, cfg, cwd, results):
|
|||||||
res = executeShCmd(cmd.rhs, cfg, cwd, results)
|
res = executeShCmd(cmd.rhs, cfg, cwd, results)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
raise ValueError,'Unknown shell command: %r' % cmd.op
|
raise ValueError('Unknown shell command: %r' % cmd.op)
|
||||||
|
|
||||||
assert isinstance(cmd, ShUtil.Pipeline)
|
assert isinstance(cmd, ShUtil.Pipeline)
|
||||||
procs = []
|
procs = []
|
||||||
|
Loading…
Reference in New Issue
Block a user