|
1 |
| -# Copyright (c) 2017-2018 Rocky Bernstein |
| 1 | +# Copyright (c) 2017-2018, 2022-2024 Rocky Bernstein |
2 | 2 |
|
3 | 3 | # This program is free software: you can redistribute it and/or modify
|
4 | 4 | # it under the terms of the GNU General Public License as published by
|
|
21 | 21 |
|
22 | 22 |
|
23 | 23 | class Python34Parser(Python33Parser):
|
24 |
| - |
25 | 24 | def p_misc34(self, args):
|
26 | 25 | """
|
27 | 26 | expr ::= LOAD_ASSERT
|
@@ -57,36 +56,45 @@ def p_misc34(self, args):
|
57 | 56 | """
|
58 | 57 |
|
59 | 58 | def customize_grammar_rules(self, tokens, customize):
|
60 |
| - self.remove_rules(""" |
| 59 | + self.remove_rules( |
| 60 | + """ |
61 | 61 | yield_from ::= expr expr YIELD_FROM
|
62 | 62 | # 3.4.2 has this. 3.4.4 may now
|
63 | 63 | # while1stmt ::= SETUP_LOOP l_stmts COME_FROM JUMP_BACK COME_FROM_LOOP
|
64 |
| - """) |
| 64 | + """ |
| 65 | + ) |
65 | 66 | super(Python34Parser, self).customize_grammar_rules(tokens, customize)
|
66 | 67 | return
|
67 | 68 |
|
| 69 | + |
68 | 70 | class Python34ParserSingle(Python34Parser, PythonParserSingle):
|
69 | 71 | pass
|
70 | 72 |
|
71 | 73 |
|
72 |
| -if __name__ == '__main__': |
| 74 | +if __name__ == "__main__": |
73 | 75 | # Check grammar
|
74 | 76 | p = Python34Parser()
|
75 | 77 | p.check_grammar()
|
76 | 78 | from xdis.version_info import IS_PYPY, PYTHON_VERSION_TRIPLE
|
| 79 | + |
77 | 80 | if PYTHON_VERSION_TRIPLE[:2] == (3, 4):
|
78 | 81 | lhs, rhs, tokens, right_recursive, dup_rhs = p.check_sets()
|
79 | 82 | from uncompyle6.scanner import get_scanner
|
| 83 | + |
80 | 84 | s = get_scanner(PYTHON_VERSION_TRIPLE, IS_PYPY)
|
81 |
| - opcode_set = set(s.opc.opname).union(set( |
82 |
| - """JUMP_BACK CONTINUE RETURN_END_IF COME_FROM |
| 85 | + opcode_set = set(s.opc.opname).union( |
| 86 | + set( |
| 87 | + """JUMP_BACK CONTINUE RETURN_END_IF COME_FROM |
83 | 88 | LOAD_GENEXPR LOAD_ASSERT LOAD_SETCOMP LOAD_DICTCOMP LOAD_CLASSNAME
|
84 | 89 | LAMBDA_MARKER RETURN_LAST
|
85 |
| - """.split())) |
| 90 | + """.split() |
| 91 | + ) |
| 92 | + ) |
86 | 93 | remain_tokens = set(tokens) - opcode_set
|
87 | 94 | import re
|
88 |
| - remain_tokens = set([re.sub(r'_\d+$', '', t) for t in remain_tokens]) |
89 |
| - remain_tokens = set([re.sub('_CONT$', '', t) for t in remain_tokens]) |
| 95 | + |
| 96 | + remain_tokens = set([re.sub(r"_\d+$", "", t) for t in remain_tokens]) |
| 97 | + remain_tokens = set([re.sub("_CONT$", "", t) for t in remain_tokens]) |
90 | 98 | remain_tokens = set(remain_tokens) - opcode_set
|
91 | 99 | print(remain_tokens)
|
92 | 100 | # print(sorted(p.rule2name.items()))
|
0 commit comments