From 4037fe17f365429dfd03b54722bb8cf674c919f8 Mon Sep 17 00:00:00 2001 From: moculus Date: Tue, 14 Apr 2009 00:46:40 +0000 Subject: [PATCH] string clean-up --HG-- branch : pmacs2 --- mode/python.py | 80 +++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/mode/python.py b/mode/python.py index 3b7b354..c0a26e1 100644 --- a/mode/python.py +++ b/mode/python.py @@ -10,68 +10,68 @@ from method.shell import Exec class StringGrammar1(Grammar): rules = [ - PatternRule(r'octal', r'\\[0-7]{3}'), - PatternRule(r'hex', r'\\x[0-9a-fA-F]{2}'), - PatternRule(r'escaped', r'\\.'), - PatternRule(r'data', r"[^\\']+"), + PatternRule('octal', r'\\[0-7]{3}'), + PatternRule('hex', r'\\x[0-9a-fA-F]{2}'), + PatternRule('escaped', r'\\.'), + PatternRule('data', r"[^\\']+"), ] class StringGrammar2(Grammar): rules = [ - PatternRule(r'octal', r'\\[0-7]{3}'), - PatternRule(r'hex', r'\\x[0-9a-fA-F]{2}'), - PatternRule(r'escaped', r'\\.'), - PatternRule(r'data', r'[^\\"]+'), + PatternRule('octal', r'\\[0-7]{3}'), + PatternRule('hex', r'\\x[0-9a-fA-F]{2}'), + PatternRule('escaped', r'\\.'), + PatternRule('data', r'[^\\"]+'), ] class StringGrammar3(Grammar): rules = [ - PatternRule(r'octal', r'\\[0-7]{3}'), - PatternRule(r'hex', r'\\x[0-9a-fA-F]{2}'), - PatternRule(r'escaped', r'\\.'), - PatternRule(r'data', r"(?:[^\\']|'(?!')|''(?!'))+"), + PatternRule('octal', r'\\[0-7]{3}'), + PatternRule('hex', r'\\x[0-9a-fA-F]{2}'), + PatternRule('escaped', r'\\.'), + PatternRule('data', r"(?:[^\\']|'(?!')|''(?!'))+"), ] class StringGrammar4(Grammar): rules = [ - PatternRule(r'octal', r'\\[0-7]{3}'), - PatternRule(r'hex', r'\\x[0-9a-fA-F]{2}'), - PatternRule(r'escaped', r'\\.'), - PatternRule(r'data', r'(?:[^\\"]|"(?!")|""(?!"))+'), + PatternRule('octal', r'\\[0-7]{3}'), + PatternRule('hex', r'\\x[0-9a-fA-F]{2}'), + PatternRule('escaped', r'\\.'), + PatternRule('data', r'(?:[^\\"]|"(?!")|""(?!"))+'), ] class PythonGrammar(Grammar): rules = [ - PatternRule(r'functionname', r'(?<=def )[a-zA-Z_][a-zA-Z0-9_]*'), - PatternRule(r'classname', r'(?<=class )[a-zA-Z_][a-zA-Z0-9_]*'), - PatternRule(r'python.reserved', r'(?:True|None|False|Exception|self)(?![a-zA-Z0-9_])'), - PatternRule(r'python.keyword', r'(?:yield|with|while|try|return|raise|print|pass|or|not|lambda|is|in|import|if|global|from|for|finally|exec|except|else|elif|del|def|continue|class|break|assert|as|and)(?![a-zA-Z0-9_])'), + PatternRule('functionname', '(?<=def )[a-zA-Z_][a-zA-Z0-9_]*'), + PatternRule('classname', '(?<=class )[a-zA-Z_][a-zA-Z0-9_]*'), + PatternRule('python.reserved', '(?:True|None|False|Exception|self)(?![a-zA-Z0-9_])'), + PatternRule('python.keyword', '(?:yield|with|while|try|return|raise|print|pass|or|not|lambda|is|in|import|if|global|from|for|finally|exec|except|else|elif|del|def|continue|class|break|assert|as|and)(?![a-zA-Z0-9_])'), PatternRule(r"python.builtin", r'(?>=|<<=|\*\*='), + PatternRule('identifier', '[a-zA-Z_][a-zA-Z0-9_]*'), + PatternRule('delimiter', r'\(|\)|\[|\]|{|}|@|,|:|\.|`|=|;|\+=|-=|\*=|/=|//=|%=|&=|\|=|\^=|>>=|<<=|\*\*='), PatternRule(r"integer", r"(?|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%"), - OverridePatternRule(r'comment', r'#@@:(?P[.a-zA-Z0-9_]+):(?P[.a-zA-Z0-9_]+) *$'), - PatternRule(r'comment', r'#.*$'), - PatternRule(r'continuation', r'\\\n$'), - PatternRule(r'spaces', r' +'), - PatternRule(r'eol', r'\n$'), + OverridePatternRule('comment', '#@@:(?P[.a-zA-Z0-9_]+):(?P[.a-zA-Z0-9_]+) *$'), + PatternRule('comment', '#.*$'), + PatternRule('continuation', r'\\\n$'), + PatternRule('spaces', ' +'), + PatternRule('eol', r'\n$'), ] class PythonTabber(tab.StackTabber):