small bugfix for s{foo} {bar} regexes.

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2009-07-05 17:48:29 -04:00
parent d2f4ba2d64
commit 6b5b2eb244
1 changed files with 21 additions and 4 deletions

View File

@ -16,6 +16,12 @@ from tab import StackTabber, StackTabber2
from parse import Any, And, Or, Optional, Name, Match, Matchs from parse import Any, And, Or, Optional, Name, Match, Matchs
import term import term
class WhitespaceGrammar(Grammar):
rules = [
PatternRule('spaces', ' +'),
PatternRule('eol', r'\n'),
]
class PodDataGrammar(Grammar): class PodDataGrammar(Grammar):
rules = [PatternRule(r'data', r'[^\n]+\n$')] rules = [PatternRule(r'data', r'[^\n]+\n$')]
@ -150,14 +156,22 @@ class PerlGrammar(Grammar):
RegionRule('perl.match', 'm(?P<delim>#)', MatchGrammar2, '#[a-z]*'), RegionRule('perl.match', 'm(?P<delim>#)', MatchGrammar2, '#[a-z]*'),
# match regexes; paired delimiters # match regexes; paired delimiters
#RegionRule('perl.replace', r's *(?P<delim>\()', MatchGrammar3,
# r'\) *\(', MatchGrammar3, r'\)[a-z]*'),
#RegionRule('perl.replace', r's *(?P<delim>\[)', MatchGrammar4,
# r'\] *\[', MatchGrammar4, r'\][a-z]*'),
#RegionRule('perl.replace', r's *(?P<delim>\{)', MatchGrammar5,
# r'\} *\{', MatchGrammar5, r'\}[a-z]*'),
#RegionRule('perl.replace', r's *(?P<delim>\<)', MatchGrammar6,
# r'\> *\<', MatchGrammar6, r'\>[a-z]*'),
RegionRule('perl.replace', r's *(?P<delim>\()', MatchGrammar3, RegionRule('perl.replace', r's *(?P<delim>\()', MatchGrammar3,
r'\) *\(', MatchGrammar3, r'\)[a-z]*'), r'\)', WhitespaceGrammar, '\(', MatchGrammar3, r'\)[a-z]*'),
RegionRule('perl.replace', r's *(?P<delim>\[)', MatchGrammar4, RegionRule('perl.replace', r's *(?P<delim>\[)', MatchGrammar4,
r'\] *\[', MatchGrammar4, r'\][a-z]*'), r'\]', WhitespaceGrammar, '\[', MatchGrammar4, r'\][a-z]*'),
RegionRule('perl.replace', r's *(?P<delim>\{)', MatchGrammar5, RegionRule('perl.replace', r's *(?P<delim>\{)', MatchGrammar5,
r'\} *\{', MatchGrammar5, r'\}[a-z]*'), r'\}', WhitespaceGrammar, '\{', MatchGrammar5, r'\}[a-z]*'),
RegionRule('perl.replace', r's *(?P<delim>\<)', MatchGrammar6, RegionRule('perl.replace', r's *(?P<delim>\<)', MatchGrammar6,
r'\> *\<', MatchGrammar6, r'\>[a-z]*'), r'\>', WhitespaceGrammar, '\<', MatchGrammar6, r'\>[a-z]*'),
# replace regexes # replace regexes
RegionRule('perl.replace', 's *(?P<delim>/)', MatchGrammar1, RegionRule('perl.replace', 's *(?P<delim>/)', MatchGrammar1,
@ -208,6 +222,8 @@ class PerlGrammar(Grammar):
PatternRule('perl.function', word2 + r"(?= *\()"), PatternRule('perl.function', word2 + r"(?= *\()"),
PatternRule('perl.class', word2 + "(?=->)"), PatternRule('perl.class', word2 + "(?=->)"),
PatternRule('perl.glob', r'(?:(?<=[^a-zA-Z0-9_])|(?<=^)) *\*[^ ]+'),
# some basic stuff # some basic stuff
PatternRule('delimiter', r"::|->|=>|(?<!:):(?!=:)|[,;=\?(){}\[\]\(\)]"), PatternRule('delimiter', r"::|->|=>|(?<!:):(?!=:)|[,;=\?(){}\[\]\(\)]"),
PatternRule('perl.noperator', "-[rwxoRWXOezsfdlpSbctugkTBMAC](?!" + PatternRule('perl.noperator', "-[rwxoRWXOezsfdlpSbctugkTBMAC](?!" +
@ -768,6 +784,7 @@ class Perl(Fundamental):
# replace regex # replace regex
'replace.start': ('cyan', 'default', 'bold'), 'replace.start': ('cyan', 'default', 'bold'),
'replace.middle0': ('cyan', 'default', 'bold'), 'replace.middle0': ('cyan', 'default', 'bold'),
'replace.middle1': ('cyan', 'default', 'bold'),
'replace.end': ('cyan', 'default', 'bold'), 'replace.end': ('cyan', 'default', 'bold'),
'replace.null': ('cyan', 'default', 'bold'), 'replace.null': ('cyan', 'default', 'bold'),
'replace.escaped': ('magenta', 'default', 'bold'), 'replace.escaped': ('magenta', 'default', 'bold'),