diff --git a/BUGS b/BUGS index 1f4fee2..e7b9374 100644 --- a/BUGS +++ b/BUGS @@ -16,7 +16,7 @@ 2008/05/16: paired delimiters in perl regexes either never worked or are broken. - dammit. + dammit. (FIXED 2008/07/29) 2007/07/15: sometimes you don't get search-as-you-type (and have to hit C-s again diff --git a/mode/perl.py b/mode/perl.py index be6f1fb..9914b60 100644 --- a/mode/perl.py +++ b/mode/perl.py @@ -15,9 +15,9 @@ class PodGrammar(Grammar): def _make_string_rules(forbidden=None): if forbidden: - rule = PatternRule(r'scalar', r"\$[^A-Za-z0-9 \\%s](?![A-Za-z0-9_])" % forbidden) + rule = PatternRule(r'scalar', r"\$[^\[\]\(\){}<>A-Za-z0-9 \\%s](?![A-Za-z0-9_])" % forbidden) else: - rule = ContextPatternRule(r'scalar', r"\$[^A-Za-z0-9 %(delim)s](?![A-Za-z0-9_])", r"\$[^A-Za-z0-9 ](?![A-Za-z0-9_])") + rule = ContextPatternRule(r'scalar', r"\$[^\[\]\(\){}<>A-Za-z0-9 %(delim)s](?![A-Za-z0-9_])", r"\$[^A-Za-z0-9 ](?![A-Za-z0-9_])") rules = [ PatternRule(r'octal', r'\\[0-7]{3}'), @@ -81,11 +81,23 @@ class PerlGrammar(Grammar): PatternRule(r'perl_hash', r"%\$*[A-Za-z_](?:[A-Za-z0-9_]|::)*"), PatternRule(r'deref', r"[@%\$&\*](?={)"), + # match regexes; paired delimiters + RegionRule(r'match', r'm *(?P\()', StringGrammar, r'\)[a-z]*'), + RegionRule(r'match', r'm *(?P\[)', StringGrammar, r'\][a-z]*'), + RegionRule(r'match', r'm *(?P\{)', StringGrammar, r'\}[a-z]*'), + RegionRule(r'match', r'm *(?P\<)', StringGrammar, r'\>[a-z]*'), + # match regexes RegionRule(r'match', r'(?:(?<==~)|(?<=!~)|(?<=\()|(?<=split)|(?<=if)|(?<=unless)|(?<=while)|(?<=until)) *(?P/)', StringGrammar, r'/[a-z]*'), RegionRule(r'match', r'm *(?P[^ #a-zA-Z0-9_])', StringGrammar, r'%(delim)s[a-z]*'), RegionRule(r'match', r'm(?P#)', StringGrammar, r'#[a-z]*'), + # match regexes; paired delimiters + RegionRule(r'replace', r's *(?P\()', StringGrammar, r'\)\(', StringGrammar, r'\)[a-z]*'), + RegionRule(r'replace', r's *(?P\[)', StringGrammar, r'\]\[', StringGrammar, r'\][a-z]*'), + RegionRule(r'replace', r's *(?P\{)', StringGrammar, r'\}\{', StringGrammar, r'\}[a-z]*'), + RegionRule(r'replace', r's *(?P\<)', StringGrammar, r'\>\<', StringGrammar, r'\>[a-z]*'), + # replace regexes RegionRule(r'replace', r's *(?P[^ a-zA-Z0-9_])', StringGrammar, r'%(delim)s', StringGrammar, r'%(delim)s[a-z]*'), RegionRule(r'replace', r's(?P#)', StringGrammar, r'#', StringGrammar, r'#[a-z]*'),