Skip to content

Commit 18bd101

Browse files
authoredOct 5, 2021
Python: Recognise walrus operator (#3126)
1 parent 3d96eed commit 18bd101

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed
 

‎components/prism-python.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Prism.languages.python = {
5555
'builtin': /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
5656
'boolean': /\b(?:False|None|True)\b/,
5757
'number': /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
58-
'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
58+
'operator': /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
5959
'punctuation': /[{}[\];(),.:]/
6060
};
6161

‎components/prism-python.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎tests/languages/python/operator_feature.test

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
> >= >>
88
= ==
99
!=
10+
:=
1011
& | ^ ~
1112

1213
----------------------------------------------------
@@ -21,9 +22,10 @@
2122
["operator", ">"], ["operator", ">="], ["operator", ">>"],
2223
["operator", "="], ["operator", "=="],
2324
["operator", "!="],
25+
["operator", ":="],
2426
["operator", "&"], ["operator", "|"], ["operator", "^"], ["operator", "~"]
2527
]
2628

2729
----------------------------------------------------
2830

29-
Checks for all operators.
31+
Checks for all operators.

0 commit comments

Comments
 (0)
Please sign in to comment.