NT binary_subscr -> subscript to match AST

This commit is contained in:
rocky
2017-11-29 00:08:08 -05:00
parent fb695616a6
commit c81b4df8b7
7 changed files with 12 additions and 12 deletions

View File

@@ -439,8 +439,8 @@ class PythonParser(GenericASTBuilder):
expr ::= unary_expr expr ::= unary_expr
expr ::= call expr ::= call
expr ::= unary_not expr ::= unary_not
expr ::= binary_subscr expr ::= subscript
expr ::= binary_subscr2 expr ::= subscript2
expr ::= get_iter expr ::= get_iter
expr ::= yield expr ::= yield
@@ -465,7 +465,7 @@ class PythonParser(GenericASTBuilder):
unary_not ::= expr UNARY_NOT unary_not ::= expr UNARY_NOT
binary_subscr ::= expr expr BINARY_SUBSCR subscript ::= expr expr BINARY_SUBSCR
load_attr ::= expr LOAD_ATTR load_attr ::= expr LOAD_ATTR
get_iter ::= expr GET_ITER get_iter ::= expr GET_ITER

View File

@@ -189,7 +189,7 @@ class Python2Parser(PythonParser):
unary_convert ::= expr UNARY_CONVERT unary_convert ::= expr UNARY_CONVERT
# In Python 3, DUP_TOPX_2 is DUP_TOP_TWO # In Python 3, DUP_TOPX_2 is DUP_TOP_TWO
binary_subscr2 ::= expr expr DUP_TOPX_2 BINARY_SUBSCR subscript2 ::= expr expr DUP_TOPX_2 BINARY_SUBSCR
""" """
def p_slice2(self, args): def p_slice2(self, args):

View File

@@ -11,7 +11,7 @@ class Python31Parser(Python32Parser):
def p_31(self, args): def p_31(self, args):
""" """
binary_subscr2 ::= expr expr DUP_TOPX BINARY_SUBSCR subscript2 ::= expr expr DUP_TOPX BINARY_SUBSCR
setupwith ::= DUP_TOP LOAD_ATTR store LOAD_ATTR CALL_FUNCTION_0 POP_TOP setupwith ::= DUP_TOP LOAD_ATTR store LOAD_ATTR CALL_FUNCTION_0 POP_TOP
setupwithas ::= DUP_TOP LOAD_ATTR store LOAD_ATTR CALL_FUNCTION_0 store setupwithas ::= DUP_TOP LOAD_ATTR store LOAD_ATTR CALL_FUNCTION_0 store

View File

@@ -62,7 +62,7 @@ class Python32Parser(Python3Parser):
def p_32on(self, args): def p_32on(self, args):
""" """
# In Python 3.2+, DUP_TOPX is DUP_TOP_TWO # In Python 3.2+, DUP_TOPX is DUP_TOP_TWO
binary_subscr2 ::= expr expr DUP_TOP_TWO BINARY_SUBSCR subscript2 ::= expr expr DUP_TOP_TWO BINARY_SUBSCR
""" """
pass pass

View File

@@ -137,10 +137,10 @@ TABLE_DIRECT = {
'DELETE_NAME': ( '%|del %{pattr}\n', ), 'DELETE_NAME': ( '%|del %{pattr}\n', ),
'DELETE_GLOBAL': ( '%|del %{pattr}\n', ), 'DELETE_GLOBAL': ( '%|del %{pattr}\n', ),
'delete_subscr': ( '%|del %c[%c]\n', 0, 1,), 'delete_subscr': ( '%|del %c[%c]\n', 0, 1,),
'binary_subscr': ( '%c[%p]', 'subscript': ( '%c[%p]',
(0, 'expr'), (0, 'expr'),
(1, 100) ), (1, 100) ),
'binary_subscr2': ( '%c[%c]', 'subscript2': ( '%c[%c]',
(0, 'expr'), (0, 'expr'),
(1, 'expr') ), (1, 'expr') ),
'store_subscr': ( '%c[%c]', 0, 1), 'store_subscr': ( '%c[%c]', 0, 1),
@@ -308,8 +308,8 @@ PRECEDENCE = {
'generator_exp': 0, 'generator_exp': 0,
'load_attr': 2, 'load_attr': 2,
'binary_subscr': 2, 'subscript': 2,
'binary_subscr2': 2, 'subscript2': 2,
'slice0': 2, 'slice0': 2,
'slice1': 2, 'slice1': 2,
'slice2': 2, 'slice2': 2,

View File

@@ -190,7 +190,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
self.set_pos_info(node[-1], start, final) self.set_pos_info(node[-1], start, final)
raise GenericASTTraversalPruningException raise GenericASTTraversalPruningException
n_slice0 = n_slice1 = n_slice2 = n_slice3 = n_binary_subscr = table_r_node n_slice0 = n_slice1 = n_slice2 = n_slice3 = n_subscript = table_r_node
n_augassign_1 = n_print_item = exec_stmt = print_to_item = del_stmt = table_r_node n_augassign_1 = n_print_item = exec_stmt = print_to_item = del_stmt = table_r_node
n_classdefco1 = n_classdefco2 = except_cond1 = except_cond2 = table_r_node n_classdefco1 = n_classdefco2 = except_cond1 = except_cond2 = table_r_node

View File

@@ -849,7 +849,7 @@ class SourceWalker(GenericASTTraversal, object):
node[-2][0].kind = 'build_tuple2' node[-2][0].kind = 'build_tuple2'
self.default(node) self.default(node)
n_store_subscr = n_binary_subscr = n_delete_subscr n_store_subscr = n_subscript = n_delete_subscr
# 'tryfinallystmt': ( '%|try:\n%+%c%-%|finally:\n%+%c%-', 1, 5 ), # 'tryfinallystmt': ( '%|try:\n%+%c%-%|finally:\n%+%c%-', 1, 5 ),
def n_tryfinallystmt(self, node): def n_tryfinallystmt(self, node):