Author Topic: SlickEdit Regular Expression for Defs Parsing  (Read 1000 times)

LCubed

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
SlickEdit Regular Expression for Defs Parsing
« 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)


Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2389
  • Hero Points: 328
Re: SlickEdit Regular Expression for Defs Parsing
« Reply #1 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);
}

LCubed

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: SlickEdit Regular Expression for Defs Parsing
« Reply #2 on: November 07, 2017, 01:17:19 pm »
Thank you for your reply, but shouldn't there be an "ARGS" entry in re_map?

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2389
  • Hero Points: 328
Re: SlickEdit Regular Expression for Defs Parsing
« Reply #3 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():+"]@";