parent
54c303e07f
commit
3ff927fdb7
|
@ -748,8 +748,10 @@ class Application(object):
|
||||||
# for debugging things like lexing/relexing/etc.
|
# for debugging things like lexing/relexing/etc.
|
||||||
if token._debug:
|
if token._debug:
|
||||||
attr = color.build('blue', 'green')
|
attr = color.build('blue', 'green')
|
||||||
else:
|
elif token.color:
|
||||||
attr = color.build(*token.color)
|
attr = color.build(*token.color)
|
||||||
|
else:
|
||||||
|
attr = color.build("default", "default")
|
||||||
|
|
||||||
k = slot.y_offset + count
|
k = slot.y_offset + count
|
||||||
self.win.addstr(k, x_offset + lm, s[:swidth - x_offset], attr)
|
self.win.addstr(k, x_offset + lm, s[:swidth - x_offset], attr)
|
||||||
|
|
12
lex.py
12
lex.py
|
@ -221,7 +221,14 @@ class RegionRule(Rule):
|
||||||
|
|
||||||
# now we will loop over the different pairs of grammars/stop-patterns in
|
# now we will loop over the different pairs of grammars/stop-patterns in
|
||||||
# this region, and return the resulting token; we start at i
|
# 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
|
yield tok
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
def _lex_loop(self, lexer, toresume, matchd, i):
|
def _lex_loop(self, lexer, toresume, matchd, i):
|
||||||
|
@ -249,7 +256,10 @@ class RegionRule(Rule):
|
||||||
lexer.mstack.append(mode)
|
lexer.mstack.append(mode)
|
||||||
|
|
||||||
if self.pairs[i][1]:
|
if self.pairs[i][1]:
|
||||||
|
try:
|
||||||
stopre = re.compile(self.pairs[i][1] % matchd, self.reflags)
|
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:
|
else:
|
||||||
stopre = None
|
stopre = None
|
||||||
if i == len(self.pairs) - 1:
|
if i == len(self.pairs) - 1:
|
||||||
|
|
|
@ -45,7 +45,7 @@ class QuotedGrammar4(Grammar):
|
||||||
|
|
||||||
class PerlGrammar(Grammar):
|
class PerlGrammar(Grammar):
|
||||||
rules = [
|
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_]+)" *;', StringGrammar, r'^%(heredoc)s$'),
|
||||||
RegionRule(r'heredoc', r"<< *'(?P<heredoc>[a-zA-Z0-9_]+)' *;", Grammar, 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$'),
|
RegionRule(r'evaldoc', r"<< *`(?P<heredoc>[a-zA-Z0-9_]+)` *;", StringGrammar, r'^%(heredoc)s$'),
|
||||||
|
|
|
@ -47,7 +47,7 @@ class TestGrammar(Grammar):
|
||||||
|
|
||||||
class ShGrammar(Grammar):
|
class ShGrammar(Grammar):
|
||||||
rules = [
|
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_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_=/])"),
|
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'),
|
RegionRule(r'case', r'case', Grammar, 'in', CaseGrammar, r'esac'),
|
||||||
|
|
Loading…
Reference in New Issue