mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
added raise statements
This commit is contained in:
parent
f521cef0bf
commit
7130476e15
3 changed files with 23 additions and 4 deletions
|
@ -513,6 +513,12 @@ def test_del_two_comma():
|
|||
def test_raise():
|
||||
yield check_stmts, 'raise', False
|
||||
|
||||
def test_raise_x():
|
||||
yield check_stmts, 'raise TypeError', False
|
||||
|
||||
def test_raise_x_from():
|
||||
yield check_stmts, 'raise TypeError from x', False
|
||||
|
||||
|
||||
#DEBUG_LEVEL = 1
|
||||
#DEBUG_LEVEL = 100
|
||||
|
|
|
@ -6,4 +6,4 @@ from ast import Module, Num, Expr, Str, Bytes, UnaryOp, UAdd, USub, Invert, \
|
|||
Index, Load, Slice, List, Tuple, Set, Dict, AST, NameConstant, Ellipsis, \
|
||||
Name, GeneratorExp, Store, comprehension, ListComp, SetComp, DictComp, \
|
||||
Assign, AugAssign, BitXor, BitAnd, BitOr, LShift, RShift, Assert, Delete, \
|
||||
Del, Pass
|
||||
Del, Pass, Raise
|
|
@ -559,10 +559,23 @@ class Parser(object):
|
|||
|
||||
def p_raise_stmt(self, p):
|
||||
"""raise_stmt : RAISE
|
||||
| test
|
||||
| test FROM test
|
||||
| RAISE test
|
||||
| RAISE test FROM test
|
||||
"""
|
||||
p[0] = p[1:]
|
||||
lenp = len(p)
|
||||
cause = None
|
||||
if lenp == 2:
|
||||
exc = None
|
||||
elif lenp == 3:
|
||||
exc = p[2]
|
||||
elif lenp == 5:
|
||||
exc = p[2]
|
||||
cause = p[4]
|
||||
else:
|
||||
assert False
|
||||
p0 = ast.Raise(exc=exc, cause=cause, lineno=self.lineno,
|
||||
col_offset=self.col)
|
||||
p[0] = p0
|
||||
|
||||
def p_import_stmt(self, p):
|
||||
"""import_stmt : import_name
|
||||
|
|
Loading…
Add table
Reference in a new issue