From 607495107e0f9e794680cedf265b7e6d4b94614e Mon Sep 17 00:00:00 2001 From: moculus Date: Wed, 15 Oct 2008 04:49:39 +0000 Subject: [PATCH] --HG-- branch : pmacs2 --- mode/__init__.py | 2 ++ mode/erlang.py | 10 ++++++++-- mode/haskell.py | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/mode/__init__.py b/mode/__init__.py index d2a0c3c..b2db6c8 100644 --- a/mode/__init__.py +++ b/mode/__init__.py @@ -89,6 +89,8 @@ class Fundamental(Handler): context = None colors = {} config = {} + lconfig = {} + dconfig = {} actions = [] completers = {} format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s" diff --git a/mode/erlang.py b/mode/erlang.py index b57213b..1ec1f22 100644 --- a/mode/erlang.py +++ b/mode/erlang.py @@ -3,10 +3,16 @@ import color, completer, default, mode, method, regex, tab from point import Point from lex import Grammar, PatternRule, RegionRule, OverridePatternRule, NocasePatternRule +class AtomGrammar(Grammar): + rules = [ + NocasePatternRule(r'escaped', r'\\(?:[bdefnrstv\\"\']|\^[a-z]|\d{1,3})'), + NocasePatternRule(r'data', r"[^\\']+"), + ] + class StringGrammar(Grammar): rules = [ NocasePatternRule(r'escaped', r'\\(?:[bdefnrstv\\"\']|\^[a-z]|\d{1,3})'), - NocasePatternRule(r'data', r'[^\\]+'), + NocasePatternRule(r'data', r'[^\\"]+'), ] class ErlangGrammar(Grammar): @@ -19,8 +25,8 @@ class ErlangGrammar(Grammar): PatternRule(r'erl_function', r'[a-z][a-zA-Z0-9_@]*(?= *\()'), PatternRule(r'erl_namespace', r'[a-z][a-zA-Z0-9_@]*(?=:)'), PatternRule(r'erl_builtin', r"whereis|unregister|unlink|tuple_to_list|tuple_size|trunc|tl|time|throw|term_to_binary|term_to_binary|statistics|split_binary|spawn_opt|spawn_opt|spawn_opt|spawn_opt|spawn_monitor|spawn_monitor|spawn_link|spawn_link|spawn_link|spawn_link|spawn|spawn|spawn|spawn|size|setelement|self|round|registered|register|put|purge_module|process_info|process_info|process_flag|process_flag|processes|pre_loaded|port_control|port_connect|port_command|port_close|pid_to_list|open_port|now|nodes|nodes|node|node|monitor_node|module_loaded|make_ref|load_module|list_to_tuple|list_to_pid|list_to_integer|list_to_float|list_to_existing_atom|list_to_bitstring|list_to_binary|list_to_atom|link|length|is_tuple|is_reference|is_record|is_record|is_process_alive|is_port|is_pid|is_number|is_list|is_integer|is_function|is_function|is_float|is_boolean|is_bitstring|is_binary|is_atom|is_alive|iolist_to_binary|iolist_size|iolist|iodata|integer_to_list|hd|halt|halt|group_leader|group_leader|get_keys|get|get|garbage_collect|garbage_collect|float_to_list|float|ext_binary|exit|exit|erase|erase|ence|element|disconnect_node|delete_module|date|concat_binary|check_process_code|byte_size|bitstring_to_list|bit_size|binary_to_term|binary_to_list|binary_to_list|atom_to_list|atom_to_list|apply|apply|apply|abs"), + RegionRule(r'erl_atom', r"'", AtomGrammar, r"'"), RegionRule(r'string', r'"', StringGrammar, r'"'), - RegionRule(r'erl_atom', r"'", StringGrammar, r"'"), PatternRule(r'erl_atom', r"[a-z][a-zA-Z0-9_@]*"), PatternRule(r'erl_variable', r"[A-Z_][a-zA-Z0-9_@]*"), PatternRule(r'delimiter', r'->|<<|>>|\(|\)|{|}|\[|\]|\.|;|,|\|'), diff --git a/mode/haskell.py b/mode/haskell.py index 3d54177..9bff8c9 100644 --- a/mode/haskell.py +++ b/mode/haskell.py @@ -6,7 +6,7 @@ from lex import Grammar, PatternRule, RegionRule, OverridePatternRule, NocasePat class CommentGrammar(Grammar): rules = [ RegionRule(r'comment', r'{-', None, r'-}'), - PatternRule(r'data', r'(?:[^{]|{(?!-))+'), + PatternRule(r'data', r'(?:[^{-]|{(?!-)|-(?!}))+'), ] class StringGrammar(Grammar): @@ -25,7 +25,7 @@ class HaskellGrammar(Grammar): 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_']*"), - PatternRule(r'hs_operator', r'@|!|>@>|>>=|>>|=>|::|->|;|<-|\\\\|\.\.|!!|:|\+\+|\||\.|\\|>=|>|/=|==|<=|<|\|\||&&|\^\^|\*\*|\^|/|\*|-|\+|='), + PatternRule(r'hs_operator', r'@|!|>@>|>>=|>>|=>|::|->|;|<-|\\\\|\.\.|!!|:|\+\+|\||\.|\\|>=|>|/=|==|<=|<|\|\||&&|\^\^|\*\*|##|\^|/|\*|-|\+|='), ] class Haskell(mode.Fundamental):