From c63e82e9a7e8b26ab5063bc4006390928cede63a Mon Sep 17 00:00:00 2001 From: moculus Date: Sun, 14 Oct 2007 17:11:01 +0000 Subject: [PATCH] fixed small sh mode eval highlighting bug --HG-- branch : pmacs2 --- mode/sh.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/mode/sh.py b/mode/sh.py index 781fb35..6be7b5b 100644 --- a/mode/sh.py +++ b/mode/sh.py @@ -11,6 +11,16 @@ class StringGrammar(Grammar): PatternRule(r'variable', r"\$(?=\()"), ] +class EvalGrammar(Grammar): + rules = [ + RegionRule(r'string', "'", Grammar, "'"), + RegionRule(r'string', '"', StringGrammar, '"'), + PatternRule(r'escaped', r'\\.'), + PatternRule(r'variable', r"\${(?:[a-zA-Z0-9_]+|\?\$)}"), + PatternRule(r"variable", r"\$[^({][a-zA-Z0-9_]*"), + PatternRule(r'variable', r"\$(?=\()"), + ] + class CaseGrammar(Grammar): rules = [ RegionRule(r'stanza', r'.+\)', Grammar, r';;'), @@ -44,8 +54,10 @@ class ShGrammar(Grammar): RegionRule(r'test', r'test', TestGrammar, r'\n'), RegionRule(r'test2', r'\[', TestGrammar, r'\]'), PatternRule(r'delimiter', r";;|[();{}|&><]"), - RegionRule(r'eval', r'`', StringGrammar, r'`'), - RegionRule(r'neval', r'\$\(', StringGrammar, r'\)'), + #RegionRule(r'eval', r'`', StringGrammar, r'`'), + #RegionRule(r'neval', r'\$\(', StringGrammar, r'\)'), + RegionRule(r'eval', r'`', EvalGrammar, r'`'), + RegionRule(r'neval', r'\$\(', EvalGrammar, r'\)'), PatternRule(r'variable', r"(?:^|(?<= ))[a-zA-Z_][a-zA-Z0-9_]*(?==)"), PatternRule(r'variable', r"\${(?:[a-zA-Z0-9_]+|\?\$)}"), PatternRule(r"variable", r"\$[^({][a-zA-Z0-9_]*"),