sh mode bugfixes

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-07-01 22:28:53 +00:00
parent 59acc62072
commit 5e5e9b87c2
1 changed files with 10 additions and 6 deletions

View File

@ -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"(?<![-a-zA-Z0-9_])(?: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'sh_reserved', r"(?:done|do|elif|else|esac|fi|for|function|if|in|select|then|until|while|time)(?![a-zA-Z0-9_=/])"),
#PatternRule(r'binop', 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"<<<?(?P<heredoc>[a-zA-Z][a-zA-Z0-9_]*)", None, "\n", 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-Z_][a-zA-Z0-9_]*)", None, "\n", 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', None, 'in', CaseGrammar, r'esac'),
PatternRule(r'sh_builtin', r"(?<![-a-zA-Z0-9_])(?: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|times|trap|type|ulimit|umask|unalias|unset|wait)(?![a-zA-Z0-9_=/])(?![-a-zA-Z0-9_])"),
RegionRule(r'test', r'test', TestGrammar, r'\n'),
RegionRule(r'test', r'test', TestGrammar, r';|\n'),
RegionRule(r'test2', r'\[', TestGrammar, r'\]'),
PatternRule(r'redirect', r'<|>'),
PatternRule(r'delimiter', r";;|[();{}|&><]"),
RegionRule(r'eval', r'`', EvalGrammar, r'`'),
RegionRule(r'neval', r'\$\(', EvalGrammar, r'\)'),