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
4ab92c80
Commit
4ab92c80
authored
Apr 10, 2014
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add matrix multiplication operator support to 2to3
parent
0134a35b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
9 deletions
+19
-9
Lib/lib2to3/Grammar.txt
Lib/lib2to3/Grammar.txt
+2
-2
Lib/lib2to3/pgen2/grammar.py
Lib/lib2to3/pgen2/grammar.py
+1
-0
Lib/lib2to3/pgen2/token.py
Lib/lib2to3/pgen2/token.py
+7
-6
Lib/lib2to3/pgen2/tokenize.py
Lib/lib2to3/pgen2/tokenize.py
+1
-1
Lib/lib2to3/tests/test_parser.py
Lib/lib2to3/tests/test_parser.py
+6
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/lib2to3/Grammar.txt
View file @
4ab92c80
...
...
@@ -56,7 +56,7 @@ small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt |
expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) |
('=' (yield_expr|testlist_star_expr))*)
testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [',']
augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' |
augassign: ('+=' | '-=' | '*=' | '
@=' | '
/=' | '%=' | '&=' | '|=' | '^=' |
'<<=' | '>>=' | '**=' | '//=')
# For normal assignments, additional restrictions enforced by the interpreter
print_stmt: 'print' ( [ test (',' test)* [','] ] |
...
...
@@ -119,7 +119,7 @@ xor_expr: and_expr ('^' and_expr)*
and_expr: shift_expr ('&' shift_expr)*
shift_expr: arith_expr (('<<'|'>>') arith_expr)*
arith_expr: term (('+'|'-') term)*
term: factor (('*'|'/'|'%'|'//') factor)*
term: factor (('*'|'
@'|'
/'|'%'|'//') factor)*
factor: ('+'|'-'|'~') factor | power
power: atom trailer* ['**' factor]
atom: ('(' [yield_expr|testlist_gexp] ')' |
...
...
Lib/lib2to3/pgen2/grammar.py
View file @
4ab92c80
...
...
@@ -149,6 +149,7 @@ opmap_raw = """
{ LBRACE
} RBRACE
@ AT
@= ATEQUAL
== EQEQUAL
!= NOTEQUAL
<> NOTEQUAL
...
...
Lib/lib2to3/pgen2/token.py
View file @
4ab92c80
...
...
@@ -57,12 +57,13 @@ DOUBLESTAREQUAL = 47
DOUBLESLASH
=
48
DOUBLESLASHEQUAL
=
49
AT
=
50
OP
=
51
COMMENT
=
52
NL
=
53
RARROW
=
54
ERRORTOKEN
=
55
N_TOKENS
=
56
ATEQUAL
=
51
OP
=
52
COMMENT
=
53
NL
=
54
RARROW
=
55
ERRORTOKEN
=
56
N_TOKENS
=
57
NT_OFFSET
=
256
#--end constants--
...
...
Lib/lib2to3/pgen2/tokenize.py
View file @
4ab92c80
...
...
@@ -84,7 +84,7 @@ String = group(r"[uU]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'",
# recognized as two instances of =).
Operator
=
group
(
r"\
*
\*=?"
,
r">>=?"
,
r"<<=?"
,
r"<>"
,
r"!="
,
r"//=?"
,
r"->"
,
r"[+\
-*/%&|^=<>]=?
",
r"[+\
-*/%&
@
|^=<>]=?
",
r"
~
")
Bracket = '[][(){}]'
...
...
Lib/lib2to3/tests/test_parser.py
View file @
4ab92c80
...
...
@@ -48,6 +48,12 @@ class GrammarTest(support.TestCase):
raise
AssertionError
(
"Syntax shouldn't have been valid"
)
class
TestMatrixMultiplication
(
GrammarTest
):
def
test_matrix_multiplication_operator
(
self
):
self
.
validate
(
"a @ b"
)
self
.
validate
(
"a @= b"
)
class
TestRaiseChanges
(
GrammarTest
):
def
test_2x_style_1
(
self
):
self
.
validate
(
"raise"
)
...
...
Misc/NEWS
View file @
4ab92c80
...
...
@@ -168,6 +168,8 @@ Tests
Tools/Demos
-----------
- Add support for the PEP 465 matrix multiplication operator to 2to3.
- Issue #16047: Fix module exception list and __file__ handling in freeze.
Patch by Meador Inge.
...
...
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