Patch by Tim Peters to speed up colorizing of big multiline strings.

This commit is contained in:
Guido van Rossum 1999-04-21 15:49:34 +00:00
parent 743007d2fe
commit da4b25e0d9
1 changed files with 4 additions and 4 deletions

View File

@ -19,10 +19,10 @@ def any(name, list):
def make_pat():
kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b"
comment = any("COMMENT", [r"#[^\n]*"])
sqstring = r"(\b[rR])?'([^'\\\n]|\\.)*'?"
dqstring = r'(\b[rR])?"([^"\\\n]|\\.)*"?'
sq3string = r"(\b[rR])?'''([^'\\]|\\.|'(?!''))*(''')?"
dq3string = r'(\b[rR])?"""([^"\\]|\\.|"(?!""))*(""")?'
sqstring = r"(\b[rR])?'[^'\\\n]*(\\.[^'\\\n]*)*'?"
dqstring = r'(\b[rR])?"[^"\\\n]*(\\.[^"\\\n]*)*"?'
sq3string = r"(\b[rR])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?"
dq3string = r'(\b[rR])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?'
string = any("STRING", [sq3string, dq3string, sqstring, dqstring])
return kw + "|" + comment + "|" + string + "|" + any("SYNC", [r"\n"])