jed-users mailing list

[2007 Date Index] [2007 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Making my own Haskell mode


Hi,
I decided to do my own Haskell mode. Since I never did a jed mode before I stumbled upon a few problems:
a) I don't know how should I define multiline comments using DFA (looking at cmode, it seems that it uses some wierd regular expressions that end up matching lines between other lines that have the /* and */. I don't know if this is the way I should do it (even so, I'm not very sure what should I match).
b) Keywords are not being highlighted. I looked at makemode.sl which defines a keyword "shell" which is being highlighted correctly. The code of my mode is very similar to makemode.sl, but the keywords I define aren't being highlighted.

BTW, I'm sticking to DFA since I don't want to define the syntax twice (one for regular highlighting method, and one for DFA) and I like regular expressions better.

Here's my code in progress:
<code>
% Haskell Mode
%
% By v01d <v01d@xxxxxxxxxxx>

%% Standard includes
require("comments");
require("keydefs");

%% Declare the namespace
implements("haskell");

%% Declare the mode name
static variable mode = "haskell";
provide(mode);

%% Custom vars
%custom_variable("Haskell_Indent", 2);

%% Syntax highlighting
create_syntax_table(mode);
set_syntax_flags(mode, 0);

%% DFA
#ifdef HAS_DFA_SYNTAX
static define setup_dfa_callback(mode) {
   dfa_enable_highlight_cache(mode + ".dfa", mode);
   dfa_define_highlight_rule("[0-9]*", "number", mode);
   dfa_define_highlight_rule("--.*", "comment", mode);
   dfa_define_highlight_rule("\\{-.*-\\}", "comment", mode);
   dfa_define_highlight_rule("[\\+\\-\\*]|->|::", "operator", mode);
   dfa_define_highlight_rule("[\\(\\)]", "delimiter", mode);
   dfa_build_highlight_table(mode);
}

dfa_set_init_callback(&setup_dfa_callback, mode);
enable_dfa_syntax_for_mode(mode);
#endif

%% Keywords
% Type 0 keywords (language keywords)
() = define_keywords_n(mode, "otherwise", 9, 0);

% Type 1 keywords (common functions from prelude)
() = define_keywords_n(mode, "Integer", 7, 1);

%% Mode Hook
public define haskell_mode() {
   set_mode(mode, 4);
   use_syntax_table(mode);
   set_comment_info(mode, "-- ", "", 0x01 | 0x02 | 0x04);
   run_mode_hooks(mode + "_mode_hook");
}
</code>

Thanks in advance,
Matt
-- 
"error: declaration does not declare anything"
"error: long long long is too long for gcc"
	- gcc errors

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2007 date index] [2007 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]