Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e5f7dcce
Commit
e5f7dcce
authored
Dec 28, 2017
by
Benjamin Peterson
Committed by
GitHub
Dec 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make PatternCompiler use the packaged grammar if possible (more bpo-24960) (#5034)
parent
e5681b98
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
Lib/lib2to3/patcomp.py
Lib/lib2to3/patcomp.py
+7
-7
No files found.
Lib/lib2to3/patcomp.py
View file @
e5f7dcce
...
...
@@ -21,10 +21,6 @@ from .pgen2 import driver, literals, token, tokenize, parse, grammar
from
.
import
pytree
from
.
import
pygram
# The pattern grammar file
_PATTERN_GRAMMAR_FILE
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"PatternGrammar.txt"
)
class
PatternSyntaxError
(
Exception
):
pass
...
...
@@ -42,13 +38,17 @@ def tokenize_wrapper(input):
class
PatternCompiler
(
object
):
def
__init__
(
self
,
grammar_file
=
_PATTERN_GRAMMAR_FILE
):
def
__init__
(
self
,
grammar_file
=
None
):
"""Initializer.
Takes an optional alternative filename for the pattern grammar.
"""
self
.
grammar
=
driver
.
load_grammar
(
grammar_file
)
self
.
syms
=
pygram
.
Symbols
(
self
.
grammar
)
if
grammar_file
is
None
:
self
.
grammar
=
pygram
.
pattern_grammar
self
.
syms
=
pygram
.
pattern_symbols
else
:
self
.
grammar
=
driver
.
load_grammar
(
grammar_file
)
self
.
syms
=
pygram
.
Symbols
(
self
.
grammar
)
self
.
pygrammar
=
pygram
.
python_grammar
self
.
pysyms
=
pygram
.
python_symbols
self
.
driver
=
driver
.
Driver
(
self
.
grammar
,
convert
=
pattern_convert
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment