SlickEdit Community

SlickEdit Product Discussion => SlickEditĀ® => Slick-CĀ® Macro Programming => Topic started by: LCubed on October 27, 2017, 03:06:45 pm

Title: SlickEdit Regular Expression for Defs Parsing
Post by: LCubed on October 27, 2017, 03:06:45 pm
Hi,
I have a macro for tagging/identifying calls and functions in a custom language, but it's broken now in 2017 version of SlickEdit. I'm hoping someone with more regex experience than I can help me out. Here are the test cases I'm trying to validate with the Regex Evaluator, but not having much luck. Any takers? The various defines are NOT case sensitive.

define_call 'update meter info' (Integer nInt)
define_call 'update meter info'
define_call 'update_meter_info' (Char ch)
define_call 'UpdateMeterInfo'

**********************
define_function calls are more syntax strict, and I'm trying NOT to allow anything that doesn't meet these test cases
**********************
define_function asdf()
define_function asdf ()
define_function char asdf ()
define_function char[3][5] asdf()
define_function char[$A4] asdf()
define_function char[$A4] as_df()
define_function char[MAX_CHAR] asdf ()
define_function char[$A5][5] asdf (Char cd, Integer int)
Define_Function Integer MOD_QueueIsEmpty(L3_QUEUE Queue)

Title: Re: SlickEdit Regular Expression for Defs Parsing
Post by: Dennis on November 03, 2017, 05:29:58 pm
This isn't all that strict, but it gets the job done.

Code: [Select]
_str your_lang_id_proc_search(_str &proc_name, int find_first)
{
   _str kw_map:[];
   kw_map:["define_call"] = "proc";
   kw_map:["define_function"] = "func";
   _str re_map:[];
   re_map:["TYPE"] = "(define_call|define_function)";
   re_map:["RETURN"] = "[^(]*";
   re_map:["NAME"] = ":v";
   re_map:["NAME2"] = "[^']*";
   return _generic_regex_proc_search('^[ \t]*<<<TYPE>>><<<RETURN>>>:b(<<<NAME>>>|''<<<NAME2>>>'')[ \t]*([(]<<<ARGS>>>[)]|$)', proc_name, find_first!=0, "", re_map, kw_map);
}
Title: Re: SlickEdit Regular Expression for Defs Parsing
Post by: LCubed on November 07, 2017, 01:17:19 pm
Thank you for your reply, but shouldn't there be an "ARGS" entry in re_map?
Title: Re: SlickEdit Regular Expression for Defs Parsing
Post by: Dennis on November 07, 2017, 06:32:15 pm
It falls back on a default regular expression for an argument list.

Code: [Select]
"[ \\t,*&=":+_clex_identifier_chars():+"]@";