2008-11-08 10:30:04 -05:00
|
|
|
import commands, os.path, string, sys, traceback
|
2008-05-02 19:18:17 -04:00
|
|
|
import color, completer, default, mode, method, regex, tab
|
|
|
|
from point import Point
|
|
|
|
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule, NocasePatternRule
|
|
|
|
|
|
|
|
class CommentGrammar(Grammar):
|
2008-10-07 23:39:22 -04:00
|
|
|
rules = [
|
|
|
|
RegionRule(r'comment', r'{-', None, r'-}'),
|
2008-10-15 00:49:39 -04:00
|
|
|
PatternRule(r'data', r'(?:[^{-]|{(?!-)|-(?!}))+'),
|
2008-10-07 23:39:22 -04:00
|
|
|
]
|
2008-05-02 19:18:17 -04:00
|
|
|
|
|
|
|
class StringGrammar(Grammar):
|
|
|
|
rules = [
|
|
|
|
RegionRule(r'gap', r'\\ *\n$', Grammar, r'^ *[^ \n]'),
|
|
|
|
NocasePatternRule(r'escaped', r'\\(?:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[&abfnrtv\\"\']|\^[a-z]|\d{1,3}|o[0-7]{0,3}|x(?:[0-9a-f]){0,2})'),
|
2008-10-07 23:39:22 -04:00
|
|
|
PatternRule(r'data', r'[^\\]+'),
|
2008-05-02 19:18:17 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
class HaskellGrammar(Grammar):
|
|
|
|
rules = [
|
|
|
|
PatternRule(r'comment', r'--.*$'),
|
|
|
|
RegionRule(r'comment', r'{-', CommentGrammar, r'-}'),
|
|
|
|
RegionRule(r'hs_string', r'"', StringGrammar, r'"'),
|
|
|
|
PatternRule(r'hs_reserved', r"(?:_|where|type|then|of|newtype|module|let|instance|infixr|infixl|infix|in|import|if|else|do|deriving|default|data|class|case)(?![a-zA-Z0-9_'])"),
|
|
|
|
PatternRule(r'hs_declaration', r"^[a-z_][a-zA-Z0-9_']*"),
|
|
|
|
PatternRule(r'hs_variable', r"[a-z_][a-zA-Z0-9_']*"),
|
|
|
|
PatternRule(r'hs_constructor', r"[A-Z][a-zA-Z0-9_']*"),
|
2008-10-15 00:49:39 -04:00
|
|
|
PatternRule(r'hs_operator', r'@|!|>@>|>>=|>>|=>|::|->|;|<-|\\\\|\.\.|!!|:|\+\+|\||\.|\\|>=|>|/=|==|<=|<|\|\||&&|\^\^|\*\*|##|\^|/|\*|-|\+|='),
|
2008-05-02 19:18:17 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
class Haskell(mode.Fundamental):
|
2009-02-15 12:06:35 -05:00
|
|
|
modename = 'Haskell'
|
|
|
|
extensions = ['.hs']
|
|
|
|
tabwidth = 4
|
|
|
|
commentc = '--'
|
2008-05-02 19:18:17 -04:00
|
|
|
#tabbercls = mode.lisp.LispTabber
|
2009-02-15 12:06:35 -05:00
|
|
|
grammar = HaskellGrammar
|
2008-05-02 19:18:17 -04:00
|
|
|
#opentokens = ('delimiter',)
|
|
|
|
#opentags = {'(': ')'}
|
|
|
|
#closetokens = ('delimiter',)
|
|
|
|
#closetags = {')': '('}
|
2009-02-15 12:06:35 -05:00
|
|
|
colors = {
|
2008-05-03 13:31:30 -04:00
|
|
|
'hs_reserved': ('cyan', 'default', 'bold'),
|
|
|
|
'hs_constructor': ('magenta', 'default', 'bold'),
|
|
|
|
'hs_declaration': ('blue', 'default', 'bold'),
|
|
|
|
'hs_operator': ('green', 'default', 'bold'),
|
|
|
|
'hs_string.start': ('green', 'default', 'bold'),
|
|
|
|
'hs_string.null': ('green', 'default', 'bold'),
|
|
|
|
'hs_string.end': ('green', 'default', 'bold'),
|
|
|
|
'hs_string.escaped': ('magenta', 'default', 'bold'),
|
|
|
|
'hs_string.gap.start': ('red', 'default', 'bold'),
|
|
|
|
'hs_string.gap.null': ('red', 'default', 'bold'),
|
|
|
|
'hs_string.gap.end': ('red', 'default', 'bold'),
|
2008-05-02 19:18:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
install = Haskell.install
|