jed-users mailing list

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

Re: DFA problem


Morten Bo Johansen <mojo@xxxxxxxx> wrote:

MBJ> Can anyone tell me why these two rules are mutually exclusive?

MBJ>    dfa_define_highlight_rule ("\".*[^\"]$", missquote, name);
MBJ>    dfa_define_highlight_rule ("\\\\n", lbreak, name);
MBJ>    
MBJ> The first highlights all lines that has a double quote
MBJ> somewhere in the line, followed by any characters and which 
MBJ> are not terminated by a double quote. The second just highlights 
MBJ> the newline literal "\n".

MBJ> They work individually but not together and I don't understand
MBJ> why.

I should be more precise: With the above two rules,

   "string       % 'string' is highlighted
    string\n     % '\n' is highlighted
    \"string\n"  % '\n' is highlighted
   "string\n"    % '\n' is nolonger highlighted
    str"ing\n"   % '\n' is nolonger highlighted

I.e., if I have these two rules together, then '\n' won't be
highlighted, if it is preceded by an unescaped double quote.

I have enclosed a small test file.



Morten

-- 
In capitalism, man exploits man.  In socialism, it's exactly the opposite.
                                 - Ben Tucker, famous vaudeville comedian
variable mode ="testdfa"; 
add_color_object("missquote");
add_color_object("lbreak");
set_color("lbreak", "green", "black");
set_color("missquote", "yellow", "black");


#ifdef HAS_DFA_SYNTAX
create_syntax_table (mode);
%%% DFA_CACHE_BEGIN %%%
static define setup_dfa_callback (mode)
{
   dfa_define_highlight_rule ("\".*[^\"]$", "missquote", mode);
   dfa_define_highlight_rule ("\\\\n", "lbreak", mode);
   dfa_build_highlight_table(mode);
}
dfa_set_init_callback (&setup_dfa_callback, mode);
%%% DFA_CACHE_END %%%
enable_dfa_syntax_for_mode(mode);
#endif

define testdfa_mode()
{
#ifdef HAS_DFA_SYNTAX
   use_syntax_table(mode);
   use_dfa_syntax(1);
#endif
}

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