# Bourne Shell syntax file for Diffuse
# Copyright (C) 2008-2009 Derrick Moser <derrick_moser@yahoo.com>
syntax 'Bourne Shell' normal text
syntax_files 'Bourne Shell' '^(.*\.sh|\.bashrc)$'
syntax_magic 'Bourne Shell' '^#![ \t]*([^ \t/]*/)*(env[ \t]+)?(sh|ash|bash|dash|ksh|pdksh|rbash|zsh)[0-9\.]*([ \t].*)?$'

# colours
colour bash_comment 0.2 0.4 0.64
colour bash_fixme 1.0 0.5 0.0
colour bash_literal 1.0 0.2 0.8
colour bash_string 0.8 0.0 0.0
colour bash_subshell 0.46 0.31 0.48
colour bash_escapedchar 0.46 0.31 0.48
colour bash_variable 0.02 0.6 0.6
colour bash_keyword 0.77 0.63 0.0
colour bash_punctuation 0.5 0.5 0.5
colour bash_function 0.02 0.6 0.6

# keywords
syntax_pattern normal expr bash_keyword '\b(alias|bg|bind|break|builtin|caller|case|cd|command|compgen|complete|continue|declare|dirs|disown|do|done|echo|elif|else|enable|esac|eval|exec|exit|export|fc|fg|fi|for|getopts|hash|help|history|if|in|jobs|kill|let|local|logout|popd|printf|pushd|pwd|read|readonly|return|select|set|shift|shopt|source|suspend|test|then|time|times|trap|type|typeset|ulimit|umask|unalias|unset|until|wait|while)\b'

# function/class definitions
syntax_pattern normal declaration bash_keyword '\b(function)\b'
syntax_pattern declaration declaration2 text '[ \t]+'
syntax_pattern declaration expr text ''
syntax_pattern declaration2 expr bash_function '\b[a-z_][a-z_0-9]*\b' ignorecase
syntax_pattern declaration2 normal text ''

# whitespace/comments
syntax_pattern normal comment bash_comment '#'
syntax_pattern comment normal bash_comment '(\r\n|\r|\n)$'
syntax_pattern comment comment bash_fixme '\b(TODO|FIXME|XXX)\b'
syntax_pattern comment comment bash_comment '.[^TFX\r\n]*'
syntax_pattern normal expr bash_comment ''
syntax_pattern expr normal text '[ \t\r\n]+'

# '-style strings
syntax_pattern expr single_string bash_string "'"
syntax_pattern single_string expr bash_string "'"
syntax_pattern single_string single_string bash_string "[^']+"

# "-style strings
syntax_pattern expr double_string bash_string '"'
syntax_pattern double_string expr bash_string '"'
syntax_pattern double_string double_subshell_string bash_subshell '`'
syntax_pattern double_string double_string bash_variable '\$([\*@#\?\-\$!]|[a-z_0-9]+|\{[a-z_0-9]+\})' ignorecase
syntax_pattern double_string double_string bash_escapedchar '(\\(\r?\n|.))+'
syntax_pattern double_string double_string bash_string '.[^\\"\$`]*'

# subshell within "-style strings
syntax_pattern double_subshell_string double_string bash_subshell '`'
syntax_pattern double_subshell_string double_subshell_string bash_escapedchar '(\\.)+'
syntax_pattern double_subshell_string double_subshell_string bash_variable '\$([\*@#\?\-\$!]|[a-z_0-9]+|\{[a-z_0-9]+\})' ignorecase
syntax_pattern double_subshell_string double_subshell_string bash_subshell '.[^\\`\$]*'

# subshell
syntax_pattern expr subshell_string bash_subshell '`'
syntax_pattern subshell_string expr bash_subshell '`'
syntax_pattern subshell_string subshell_string bash_variable '\$([\*@#\?\-\$!]|[a-z_0-9]*|{[a-z_0-9]*})' ignorecase
syntax_pattern subshell_string subshell_string bash_escapedchar '(\\(\r?\n|.))+'
syntax_pattern subshell_string subshell_string bash_subshell '.[^\\`\$]*'

# escaped character
syntax_pattern expr expr bash_escapedchar '(\\(\r?\n|.))+'

# punctuation
syntax_pattern expr normal bash_punctuation '[!\|&;\(\)<>]+'
syntax_pattern expr expr bash_punctuation '[\{\}=\[\]]+'

# literal
syntax_pattern expr expr bash_literal '\b[0-9]+\b'

# environment variables
syntax_pattern expr expr bash_variable '\$([\*@#\?\-\$!]|[a-z_0-9]+|\{[a-z_0-9]+\})' ignorecase

# parsing optimisation
syntax_pattern expr expr text '[a-z0-9_]+' ignorecase
