diff --git a/Lib/idlelib/colorizer.py b/Lib/idlelib/colorizer.py index bffa2ddd3cd9cd..899584554061ce 100644 --- a/Lib/idlelib/colorizer.py +++ b/Lib/idlelib/colorizer.py @@ -17,6 +17,7 @@ def any(name, alternates): def make_pat(): kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b" match_softkw = ( + r"(?match)\b" + r"(?![ \t]*(?:" + "|".join([ # not followed by ... @@ -27,11 +28,13 @@ def make_pat(): r"))" ) case_default = ( + r"(?case)" + r"[ \t]+(?P_\b)" ) case_softkw_and_pattern = ( + r"(?case)\b" + r"(?![ \t]*(?:" + "|".join([ # not followed by ... @@ -45,7 +48,30 @@ def make_pat(): builtinlist = [str(name) for name in dir(builtins) if not name.startswith('_') and name not in keyword.kwlist] - builtin = r"([^.'\"\\#]\b|^)" + any("BUILTIN", builtinlist) + r"\b" + builtin = ( + r"(?` where slashes at the end of lines aren't +treated as line continuations.