You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Remove redundant 2.7 (and 2.x) grammar rules
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
machine:
|
machine:
|
||||||
python:
|
python:
|
||||||
version: 2.7.8
|
version: 2.7.12
|
||||||
environment:
|
environment:
|
||||||
COMPILE: --compile
|
COMPILE: --compile
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import re
|
import re
|
||||||
from uncompyle6 import PYTHON_VERSION, PYTHON3, IS_PYPY # , PYTHON_VERSION
|
from uncompyle6 import PYTHON_VERSION, PYTHON3, IS_PYPY # , PYTHON_VERSION
|
||||||
from uncompyle6.parser import get_python_parser
|
from uncompyle6.parser import get_python_parser, python_parser
|
||||||
from uncompyle6.scanner import get_scanner
|
from uncompyle6.scanner import get_scanner
|
||||||
|
|
||||||
def test_grammar():
|
def test_grammar():
|
||||||
@@ -53,3 +53,11 @@ def test_grammar():
|
|||||||
ignore_set.add('STORE_LOCALS')
|
ignore_set.add('STORE_LOCALS')
|
||||||
opcode_set = set(s.opc.opname).union(ignore_set)
|
opcode_set = set(s.opc.opname).union(ignore_set)
|
||||||
check_tokens(tokens, opcode_set)
|
check_tokens(tokens, opcode_set)
|
||||||
|
|
||||||
|
def test_dup_rule():
|
||||||
|
import inspect
|
||||||
|
python_parser(PYTHON_VERSION, inspect.currentframe().f_code,
|
||||||
|
is_pypy=IS_PYPY,
|
||||||
|
parser_debug={
|
||||||
|
'rules': True, 'transition': False, 'reduce': False,
|
||||||
|
'errorstack': None, 'context': True})
|
||||||
|
9
tox.ini
9
tox.ini
@@ -6,13 +6,14 @@ filename = *.py
|
|||||||
ignore = C901,E113,E121,E122,E123,E124,E125,E126,E127,E128,E129,E201,E202,E203,E221,E222,E225,E226,E241,E242,E251,E261,E271,E272,E302,E401,E501,F401,E701,E702
|
ignore = C901,E113,E121,E122,E123,E124,E125,E126,E127,E128,E129,E201,E202,E203,E221,E222,E225,E226,E241,E242,E251,E261,E271,E272,E302,E401,E501,F401,E701,E702
|
||||||
|
|
||||||
[tox]
|
[tox]
|
||||||
envlist = py26, py27, pypy
|
envlist = py27, py34, pypy
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps =
|
deps =
|
||||||
requests>=0.8.8
|
hypothesis
|
||||||
mock>=1.0.1
|
pytest
|
||||||
commands = python -W always setup.py nosetests {posargs}
|
flake8
|
||||||
|
commands = python -W always make test {posargs}
|
||||||
|
|
||||||
[testenv:py27]
|
[testenv:py27]
|
||||||
deps =
|
deps =
|
||||||
|
@@ -425,7 +425,6 @@ class PythonParser(GenericASTBuilder):
|
|||||||
expr ::= unary_not
|
expr ::= unary_not
|
||||||
expr ::= binary_subscr
|
expr ::= binary_subscr
|
||||||
expr ::= binary_subscr2
|
expr ::= binary_subscr2
|
||||||
expr ::= load_attr
|
|
||||||
expr ::= get_iter
|
expr ::= get_iter
|
||||||
expr ::= buildslice2
|
expr ::= buildslice2
|
||||||
expr ::= buildslice3
|
expr ::= buildslice3
|
||||||
@@ -556,7 +555,7 @@ def parse(p, tokens, customize):
|
|||||||
|
|
||||||
|
|
||||||
def get_python_parser(
|
def get_python_parser(
|
||||||
version, debug_parser={}, compile_mode='exec',
|
version, debug_parser=PARSER_DEFAULT_DEBUG, compile_mode='exec',
|
||||||
is_pypy = False):
|
is_pypy = False):
|
||||||
"""Returns parser object for Python version 2 or 3, 3.2, 3.5on,
|
"""Returns parser object for Python version 2 or 3, 3.2, 3.5on,
|
||||||
etc., depending on the parameters passed. *compile_mode* is either
|
etc., depending on the parameters passed. *compile_mode* is either
|
||||||
|
@@ -76,8 +76,6 @@ class Python2Parser(PythonParser):
|
|||||||
return_if_stmts ::= _stmts return_if_stmt
|
return_if_stmts ::= _stmts return_if_stmt
|
||||||
return_if_stmt ::= ret_expr RETURN_END_IF
|
return_if_stmt ::= ret_expr RETURN_END_IF
|
||||||
|
|
||||||
stmt ::= importstmt
|
|
||||||
|
|
||||||
stmt ::= break_stmt
|
stmt ::= break_stmt
|
||||||
break_stmt ::= BREAK_LOOP
|
break_stmt ::= BREAK_LOOP
|
||||||
|
|
||||||
@@ -210,14 +208,6 @@ class Python2Parser(PythonParser):
|
|||||||
and ::= expr jmp_false expr come_from_opt
|
and ::= expr jmp_false expr come_from_opt
|
||||||
or ::= expr jmp_true expr come_from_opt
|
or ::= expr jmp_true expr come_from_opt
|
||||||
|
|
||||||
slice0 ::= expr SLICE+0
|
|
||||||
slice0 ::= expr DUP_TOP SLICE+0
|
|
||||||
slice1 ::= expr expr SLICE+1
|
|
||||||
slice1 ::= expr expr DUP_TOPX_2 SLICE+1
|
|
||||||
slice2 ::= expr expr SLICE+2
|
|
||||||
slice2 ::= expr expr DUP_TOPX_2 SLICE+2
|
|
||||||
slice3 ::= expr expr expr SLICE+3
|
|
||||||
slice3 ::= expr expr expr DUP_TOPX_3 SLICE+3
|
|
||||||
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
|
||||||
@@ -248,7 +238,6 @@ class Python2Parser(PythonParser):
|
|||||||
"""
|
"""
|
||||||
inplace_op ::= INPLACE_DIVIDE
|
inplace_op ::= INPLACE_DIVIDE
|
||||||
binary_op ::= BINARY_DIVIDE
|
binary_op ::= BINARY_DIVIDE
|
||||||
binary_subscr2 ::= expr expr DUP_TOPX_2 BINARY_SUBSCR
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def add_custom_rules(self, tokens, customize):
|
def add_custom_rules(self, tokens, customize):
|
||||||
|
@@ -84,8 +84,6 @@ class Python27Parser(Python2Parser):
|
|||||||
POP_BLOCK LOAD_CONST COME_FROM
|
POP_BLOCK LOAD_CONST COME_FROM
|
||||||
WITH_CLEANUP END_FINALLY
|
WITH_CLEANUP END_FINALLY
|
||||||
|
|
||||||
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM
|
|
||||||
|
|
||||||
# Common with 2.6
|
# Common with 2.6
|
||||||
while1stmt ::= SETUP_LOOP return_stmts bp_come_from
|
while1stmt ::= SETUP_LOOP return_stmts bp_come_from
|
||||||
while1stmt ::= SETUP_LOOP return_stmts COME_FROM
|
while1stmt ::= SETUP_LOOP return_stmts COME_FROM
|
||||||
|
Reference in New Issue
Block a user