/** 
 * Unlike other predefined token patterns, keywords are dynamic during runtime and may change
 * the factory will produce tokenHandlers for a provided array of keywords
 * */

function onMatch(match) {
  return {
    type: 'KEYWORD',
    content: match[0],
    index: match.index,
  };
}

export default function factory(keyword) {
  return {
    pattern: new RegExp(`${keyword}`, 'gi'),
    onMatch
  };
}

@@ -178,120 +178,8 @@
 */%0A%0A
-function onMatch(match) %7B%0A  return %7B%0A    type: 'KEYWORD',%0A    content: match%5B0%5D,%0A    index: match.index,%0A  %7D;%0A%7D%0A
 %0Aexp
@@ -214,16 +214,34 @@
 (keyword
+, type = 'KEYWORD'
 ) %7B%0A  re
@@ -303,16 +303,142 @@
  onMatch
+: function onMatch(match) %7B%0A      return %7B%0A        type,%0A        content: match%5B0%5D,%0A        index: match.index,%0A      %7D;%0A    %7D
 %0A  %7D;%0A%7D%0A

allow type for keyword factory