some updates and fixes

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-04-15 22:55:26 +00:00
parent 54c303e07f
commit 3ff927fdb7
4 changed files with 17 additions and 5 deletions

View File

@ -748,8 +748,10 @@ class Application(object):
# for debugging things like lexing/relexing/etc.
if token._debug:
attr = color.build('blue', 'green')
else:
elif token.color:
attr = color.build(*token.color)
else:
attr = color.build("default", "default")
k = slot.y_offset + count
self.win.addstr(k, x_offset + lm, s[:swidth - x_offset], attr)

12
lex.py
View File

@ -221,7 +221,14 @@ class RegionRule(Rule):
# now we will loop over the different pairs of grammars/stop-patterns in
# this region, and return the resulting token; we start at i
for tok in self._lex_loop(lexer, toresume, toresume[0].matchd, i):
matchd = toresume[0].matchd
if not matchd and toresume[0].parent:
p = toresume[0].parent
while not p.matchd and p.parent:
p = p.parent
matchd = p.matchd
#for tok in self._lex_loop(lexer, toresume, toresume[0].matchd, i):
for tok in self._lex_loop(lexer, toresume, matchd, i):
yield tok
raise StopIteration
def _lex_loop(self, lexer, toresume, matchd, i):
@ -249,7 +256,10 @@ class RegionRule(Rule):
lexer.mstack.append(mode)
if self.pairs[i][1]:
try:
stopre = re.compile(self.pairs[i][1] % matchd, self.reflags)
except:
raise Exception, "%r\n%r\n%r" % (self.pairs[i][1], matchd, self.reflags)
else:
stopre = None
if i == len(self.pairs) - 1:

View File

@ -45,7 +45,7 @@ class QuotedGrammar4(Grammar):
class PerlGrammar(Grammar):
rules = [
RegionRule(r'heredoc', r"<<(?P<heredoc>[a-zA-Z0-9_]+) *;", StringGrammar, r'^%(heredoc)s$'),
RegionRule(r'heredoc', r"<<(?P<heredoc>[a-zA-Z_][a-zA-Z0-9_]+)", None, ';\n', StringGrammar, r'^%(heredoc)s$'),
RegionRule(r'heredoc', r'<< *"(?P<heredoc>[a-zA-Z0-9_]+)" *;', StringGrammar, r'^%(heredoc)s$'),
RegionRule(r'heredoc', r"<< *'(?P<heredoc>[a-zA-Z0-9_]+)' *;", Grammar, r'^%(heredoc)s$'),
RegionRule(r'evaldoc', r"<< *`(?P<heredoc>[a-zA-Z0-9_]+)` *;", StringGrammar, r'^%(heredoc)s$'),

View File

@ -47,7 +47,7 @@ class TestGrammar(Grammar):
class ShGrammar(Grammar):
rules = [
RegionRule(r'heredoc', r"<<(?P<heredoc>[a-zA-Z0-9_]+)", StringGrammar, r'^%(heredoc)s$'),
RegionRule(r'heredoc', r"<<(?P<heredoc>[a-zA-Z][a-zA-Z0-9_]*)", None, "\n", StringGrammar, r'^%(heredoc)s$'),
PatternRule(r'sh_function', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\(\))'),
PatternRule(r'sh_reserved', r"(?:done|do|elif|else|esac|fi|for|function|if|in|select|then|until|while|time)(?![a-zA-Z0-9_=/])"),
RegionRule(r'case', r'case', Grammar, 'in', CaseGrammar, r'esac'),