From 5e5e9b87c26a5265a4cab6a437c66f47208ddea2 Mon Sep 17 00:00:00 2001 From: moculus Date: Tue, 1 Jul 2008 22:28:53 +0000 Subject: [PATCH] sh mode bugfixes --HG-- branch : pmacs2 --- mode/sh.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mode/sh.py b/mode/sh.py index 29714ba..a7ec427 100644 --- a/mode/sh.py +++ b/mode/sh.py @@ -30,17 +30,20 @@ class CaseGrammar(Grammar): rules = [ PatternRule(r'comment', r'#.*$'), PatternRule(r'ws', r' +'), - RegionRule(r'stanza', r'.+\\', StanzaGrammar, r'.+\)', Grammar, r';;'), + RegionRule(r'stanza', r'.+\\\n$', StanzaGrammar, r'.+\)', Grammar, r';;'), RegionRule(r'stanza', r'.+\)', Grammar, r';;'), ] class TestGrammar(Grammar): rules = [ - PatternRule(r'sh_builtin', r"(?:source|alias|bg|bind|break|builtin|cd|command|compgen|complete|declare|dirs|disown|echo|enable|eval|exec|exit|export|fc|fg|getops|hash|help|history|jobs|kill|let|local|logout|popd|printf|pushd|pwd|readonly|read|return|set|shift|shopt|suspend|test|times|trap|type|ulimit|umask|unalias|unset|wait)(?![a-zA-Z0-9_=/])"), - PatternRule(r'binop', r'==|=|!=|<|>'), + PatternRule(r'sh_builtin', r"(?'), + PatternRule(r'binop', r'==|=|!='), PatternRule(r'binop', r'-(?:nt|ot|ef|eq|ne|lt|gt|le|ge)(?![a-zA-Z0-9_])'), PatternRule(r'unop', r'-[a-zA-Z](?![a-zA-Z0-9_])'), PatternRule(r'continuation', r'\\\n$'), + PatternRule(r'redirect', r'<|>'), PatternRule(r'delimiter', r";;|[();{}|&><]"), RegionRule(r'eval', r'`', StringGrammar, r'`'), RegionRule(r'neval', r'\$\(', StringGrammar, r'\)'), @@ -55,14 +58,15 @@ class TestGrammar(Grammar): class ShGrammar(Grammar): rules = [ - RegionRule(r'heredoc', r"<<[a-zA-Z][a-zA-Z0-9_]*)", None, "\n", StringGrammar, r'^%(heredoc)s$'), - RegionRule(r'heredoc', r"<<-(?P[a-zA-Z][a-zA-Z0-9_]*)", None, "\n", StringGrammar, r'^ *%(heredoc)s$'), + RegionRule(r'heredoc', r"<<[<\\]?(?P[a-zA-Z_][a-zA-Z0-9_]*)", None, "\n", StringGrammar, r'^%(heredoc)s$'), + RegionRule(r'heredoc', r"<<-(?P[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', None, 'in', CaseGrammar, r'esac'), PatternRule(r'sh_builtin', r"(?'), PatternRule(r'delimiter', r";;|[();{}|&><]"), RegionRule(r'eval', r'`', EvalGrammar, r'`'), RegionRule(r'neval', r'\$\(', EvalGrammar, r'\)'),