diff --git a/mode/perl.py b/mode/perl.py index 3fb07c7..76b45fe 100644 --- a/mode/perl.py +++ b/mode/perl.py @@ -16,6 +16,12 @@ from tab import StackTabber, StackTabber2 from parse import Any, And, Or, Optional, Name, Match, Matchs import term +class WhitespaceGrammar(Grammar): + rules = [ + PatternRule('spaces', ' +'), + PatternRule('eol', r'\n'), + ] + class PodDataGrammar(Grammar): rules = [PatternRule(r'data', r'[^\n]+\n$')] @@ -150,14 +156,22 @@ class PerlGrammar(Grammar): RegionRule('perl.match', 'm(?P#)', MatchGrammar2, '#[a-z]*'), # match regexes; paired delimiters + #RegionRule('perl.replace', r's *(?P\()', MatchGrammar3, + # r'\) *\(', MatchGrammar3, r'\)[a-z]*'), + #RegionRule('perl.replace', r's *(?P\[)', MatchGrammar4, + # r'\] *\[', MatchGrammar4, r'\][a-z]*'), + #RegionRule('perl.replace', r's *(?P\{)', MatchGrammar5, + # r'\} *\{', MatchGrammar5, r'\}[a-z]*'), + #RegionRule('perl.replace', r's *(?P\<)', MatchGrammar6, + # r'\> *\<', MatchGrammar6, r'\>[a-z]*'), RegionRule('perl.replace', r's *(?P\()', MatchGrammar3, - r'\) *\(', MatchGrammar3, r'\)[a-z]*'), + r'\)', WhitespaceGrammar, '\(', MatchGrammar3, r'\)[a-z]*'), RegionRule('perl.replace', r's *(?P\[)', MatchGrammar4, - r'\] *\[', MatchGrammar4, r'\][a-z]*'), + r'\]', WhitespaceGrammar, '\[', MatchGrammar4, r'\][a-z]*'), RegionRule('perl.replace', r's *(?P\{)', MatchGrammar5, - r'\} *\{', MatchGrammar5, r'\}[a-z]*'), + r'\}', WhitespaceGrammar, '\{', MatchGrammar5, r'\}[a-z]*'), RegionRule('perl.replace', r's *(?P\<)', MatchGrammar6, - r'\> *\<', MatchGrammar6, r'\>[a-z]*'), + r'\>', WhitespaceGrammar, '\<', MatchGrammar6, r'\>[a-z]*'), # replace regexes RegionRule('perl.replace', 's *(?P/)', MatchGrammar1, @@ -208,6 +222,8 @@ class PerlGrammar(Grammar): PatternRule('perl.function', word2 + r"(?= *\()"), PatternRule('perl.class', word2 + "(?=->)"), + PatternRule('perl.glob', r'(?:(?<=[^a-zA-Z0-9_])|(?<=^)) *\*[^ ]+'), + # some basic stuff PatternRule('delimiter', r"::|->|=>|(?