Skip to content

Commit

Permalink
Python: Recognise walrus operator (#3126)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoonweiting committed Oct 5, 2021
1 parent 3d96eed commit 18bd101
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/prism-python.js
Expand Up @@ -55,7 +55,7 @@ Prism.languages.python = {
'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/,
'boolean': /\b(?:False|None|True)\b/,
'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,
'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
'operator': /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
'punctuation': /[{}[\];(),.:]/
};

Expand Down
2 changes: 1 addition & 1 deletion components/prism-python.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion tests/languages/python/operator_feature.test
Expand Up @@ -7,6 +7,7 @@
> >= >>
= ==
!=
:=
& | ^ ~

----------------------------------------------------
Expand All @@ -21,9 +22,10 @@
["operator", ">"], ["operator", ">="], ["operator", ">>"],
["operator", "="], ["operator", "=="],
["operator", "!="],
["operator", ":="],
["operator", "&"], ["operator", "|"], ["operator", "^"], ["operator", "~"]
]

----------------------------------------------------

Checks for all operators.
Checks for all operators.

0 comments on commit 18bd101

Please sign in to comment.