parent
54c303e07f
commit
3ff927fdb7
|
@ -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)
|
||||
|
|
14
lex.py
14
lex.py
|
@ -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]:
|
||||
stopre = re.compile(self.pairs[i][1] % matchd, self.reflags)
|
||||
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:
|
||||
|
|
|
@ -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$'),
|
||||
|
|
|
@ -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'),
|
||||
|
|
Loading…
Reference in New Issue