branch : pmacs2
This commit is contained in:
moculus 2007-09-20 06:10:27 +00:00
parent f41f09401d
commit 11b0b69bd9
2 changed files with 42 additions and 6 deletions

View File

@ -60,6 +60,8 @@ while getopts "halbtu" var; do
esac esac
done done
test 3 -eq 3
echo hola > foo/bar/duh; echo hola > foo/bar/duh;
if [[ $( id -u ) -ne 0 ]]; then if [[ $( id -u ) -ne 0 ]]; then
@ -67,6 +69,12 @@ if [[ $( id -u ) -ne 0 ]]; then
exit 1 exit 1
fi fi
if 0; then
foo
else
bar
fi
if [[ ${TCP} -eq 1 ]]; then if [[ ${TCP} -eq 1 ]]; then
if [[ ${LISTENING} -eq 0 ]]; then if [[ ${LISTENING} -eq 0 ]]; then
findtcptype ESTABLISHED findtcptype ESTABLISHED

View File

@ -11,14 +11,38 @@ class StringGrammar(Grammar):
PatternRule(r'variable', r"\$(?=\()"), PatternRule(r'variable', r"\$(?=\()"),
] ]
class TestGrammar(Grammar):
rules = [
PatternRule(r'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'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'delimiter', r";;|[();{}|&><]"),
RegionRule(r'eval', r'`', StringGrammar, r'`'),
RegionRule(r'neval', r'\$\(', StringGrammar, 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_]*"),
PatternRule(r'variable', r"\$(?=\()"),
RegionRule(r'string', "'", Grammar, "'"),
RegionRule(r'string', '"', StringGrammar, '"'),
PatternRule(r'bareword', r'[a-zA-Z0-9_-]+'),
]
class ShGrammar(Grammar): class ShGrammar(Grammar):
rules = [ rules = [
PatternRule(r'function', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\(\))'), PatternRule(r'function', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\(\))'),
PatternRule(r'reserved', r"(?:case|done|do|elif|else|esac|fi|for|function|if|in|select|then|until|while|time)(?![a-zA-Z0-9_=/])"), PatternRule(r'reserved', r"(?:case|done|do|elif|else|esac|fi|for|function|if|in|select|then|until|while|time)(?![a-zA-Z0-9_=/])"),
PatternRule(r'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'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'operator', r"(?:-eq|-ne|-gt|-lt|-ge|-le| = | != )(?![a-zA-Z0-9_])"), PatternRule(r'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|times|trap|type|ulimit|umask|unalias|unset|wait)(?![a-zA-Z0-9_=/])"),
PatternRule(r'delimiter', r";;|[\[\]\(\);\{\}|&><]"), #PatternRule(r'operator', r"(?:-eq|-ne|-gt|-lt|-ge|-le| = | != )(?![a-zA-Z0-9_])"),
RegionRule(r'eval', '`', StringGrammar, '`'), #PatternRule(r'delimiter', r";;|[\[\]\(\);\{\}|&><]"),
#RegionRule(r'test', r'\[', TestGrammar, r'\]'),
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'neval', r'\$\(', StringGrammar, r'\)'),
PatternRule(r'variable', r"(?:^|(?<= ))[a-zA-Z_][a-zA-Z0-9_]*(?==)"), 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_]+|\?\$)}"),
@ -53,6 +77,8 @@ class ShTabber(tab2.StackTabber):
fqname = token.fqname() fqname = token.fqname()
if token.name == 'continuation': if token.name == 'continuation':
self._opt_append("cont", currlvl + 4) self._opt_append("cont", currlvl + 4)
elif token.name == 'reserved' and token.string == 'else':
currlvl -= 4
elif token.name == 'eol': elif token.name == 'eol':
self._opt_pop("cont") self._opt_pop("cont")
return currlvl return currlvl
@ -73,7 +99,9 @@ class Sh(mode2.Fundamental):
'variable': ('yellow', 'default', 'bold'), 'variable': ('yellow', 'default', 'bold'),
'delimiter': ('default', 'default', 'bold'), 'delimiter': ('default', 'default', 'bold'),
'operator': ('magenta', 'default', 'bold'), 'test.start': ('cyan', 'default', 'bold'),
'binop': ('magenta', 'default', 'bold'),
'unop': ('magenta', 'default', 'bold'),
'string.start': ('green', 'default'), 'string.start': ('green', 'default'),
'string.variable': ('yellow', 'default'), 'string.variable': ('yellow', 'default'),