branch : pmacs2
This commit is contained in:
moculus 2008-05-13 22:53:17 +00:00
parent 9a87e554dc
commit 7d2a8959d2
2 changed files with 6 additions and 1 deletions

5
lex.py
View File

@ -2,6 +2,9 @@ import curses, re
import regex, util
from point import Point
def escape(s):
return re.escape(s)
class Token(object):
def __init__(self, name, rule, y, x, s, color=None, parent=None, matchd={}, link=None):
self.name = name
@ -199,6 +202,8 @@ class RegionRule(Rule):
# ok, so since we had a match, we need to create our start token, who
# will be the ancestor to all other tokens matched in this region
matchd = m.groupdict()
for (key, val) in matchd.iteritems():
matchd[key] = escape(val)
parent = self.make_token(lexer, m.group(0), 'start', parent, matchd, 'start')
yield parent

View File

@ -77,7 +77,7 @@ class PerlGrammar(Grammar):
PatternRule(r'deref', r"[@%\$&\*](?={)"),
# match regexes
RegionRule(r'match', r'(?:(?<==~)|(?<=!~)|(?<=\()|(?<=split)) *(?P<delim>/)', StringGrammar, r'/[a-z]*'),
RegionRule(r'match', r'(?:(?<==~)|(?<=!~)|(?<=\()|(?<=split)|(?<=if)|(?<=unless)|(?<=while)|(?<=until)) *(?P<delim>/)', StringGrammar, r'/[a-z]*'),
RegionRule(r'match', r'm *(?P<delim>[^ #a-zA-Z0-9_])', StringGrammar, r'%(delim)s[a-z]*'),
RegionRule(r'match', r'm(?P<delim>#)', StringGrammar, r'#[a-z]*'),