1 % Halibut mode for Jed.
4 create_syntax_table ($1);
6 define_syntax ("\#", "", '%', $1); % Comment Syntax
7 define_syntax ('\\', '\\', $1); % Quote character
8 define_syntax ("{", "}", '(', $1); % are all these needed?
9 define_syntax ("a-zA-Z0-9", 'w', $1);
10 set_syntax_flags ($1, 8);
13 %enable_highlight_cache ("halibut.dfa", $1);
15 % A braced comment in Halibut is \#{ ... }, where ... may contain
16 % any correctly nested sequence of braces. Of course we can't match
17 % that in a DFA rule, so we'll go down to a reasonable depth of 3
19 #ifexists dfa_define_highlight_rule
20 dfa_define_highlight_rule ("\\\\#{[^{}]*({[^{}]*({[^}]*}[^{}]*)*}[^{}]*)*}",
23 dfa_define_highlight_rule ("\\\\#.*$", "comment", $1);
24 dfa_define_highlight_rule ("^\\\\c([ \t].*)?$", "string", $1);
25 dfa_define_highlight_rule ("\\\\[\\\\{}\\-_]", "keyword0", $1);
26 dfa_define_highlight_rule ("\\\\[A-Za-tv-z][A-Za-z0-9]*", "keyword0", $1);
27 dfa_define_highlight_rule ("\\\\u[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]",
29 dfa_define_highlight_rule ("\\\\u[A-Fa-f0-9]?[A-Fa-f0-9]?[A-Fa-f0-9]?[A-Fa-f0-9]",
31 dfa_define_highlight_rule ("[{}]", "delimiter", $1);
32 dfa_define_highlight_rule (".", "normal", $1);
33 dfa_build_highlight_table ($1);
35 define_highlight_rule ("\\\\#{[^{}]*({[^{}]*({[^}]*}[^{}]*)*}[^{}]*)*}",
38 define_highlight_rule ("\\\\#.*$", "comment", $1);
39 define_highlight_rule ("^\\\\c([ \t].*)?$", "string", $1);
40 define_highlight_rule ("\\\\[\\\\{}\\-_]", "keyword0", $1);
41 define_highlight_rule ("\\\\[A-Za-tv-z][A-Za-z0-9]*", "keyword0", $1);
42 define_highlight_rule ("\\\\u[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]",
44 define_highlight_rule ("\\\\u[A-Fa-f0-9]?[A-Fa-f0-9]?[A-Fa-f0-9]?[A-Fa-f0-9]",
46 define_highlight_rule ("[{}]", "delimiter", $1);
47 define_highlight_rule (".", "normal", $1);
48 build_highlight_table ($1);
52 % This hook identifies lines containing comments as paragraph separator
53 define halibut_is_comment() {
55 while (ffind ("\\\\#")) go_right (3);
56 ffind ("\\#"); % return value on stack
59 variable Halibut_Ignore_Comment = 0; % if true, line containing a comment
60 % does not delimit a paragraph
62 define halibut_paragraph_separator() {
67 if (looking_at("\\c ") or looking_at("\\c\t") or
70 return not (Halibut_Ignore_Comment) and halibut_is_comment();
73 define halibut_wrap_hook() {
76 yep = up_1 () and halibut_is_comment ();
86 #ifexists mode_set_mode_info
87 mode_set_mode_info("Halibut", "fold_info", "\\# {{{\r\\# }}}\r\r");
90 define halibut_mode() {
91 variable mode = "Halibut";
93 set_mode (mode, 0x1 | 0x20);
94 set_buffer_hook ("par_sep", "halibut_paragraph_separator");
95 set_buffer_hook ("wrap_hook", "halibut_wrap_hook");
96 use_syntax_table (mode);
97 runhooks ("halibut_mode_hook");