Just to start off, I'm using regexr.com as reference (writing the highlighting in Javascript). And a very important thing is: I'm not writing syntax highlighting for Javascript. I'm writing for a language called gLUA, which is a very strict type of language, example code can be found here.
I have a project I'm using PrismJS for, with its syntax highlighting features. I had to make my own with regex (code below), and now I'm stuck at one part, namely two selectors clashing one another. Syntax highlight looks like this with both rules.
If I remove the (
from the punctuation regex selection, everything turns out fine (except the parenthesis, that is...)
I need the (?=\()
selection for the function, or else I'm going to have a really bad time working around it. I've already spend several hours figuring it out, so I'd rather not poke on it. Are there any other workarounds? I love the gray color on the parentheses...
// DONE
'directive': /@(name.*|model.*|inputs|outputs|persist|trigger|autoupdate)/,
//DONE
'type': /\b(angle|array|bone|complex|entity|matrix[24]?|number|quaternion|ranger|string|table|vector[24]?|wirelink)(?!\()\b/ig,
//DONE
'keyword': /\b((else)?if|else|for(each)?|while|break|continue|local|switch|case|default|function|return)\b/g,
//ERROR - CLASHING WITH FUNCTION BECAUSE OF "("
'punctuation': /[()\[\]{};:,]/,
//DONE
'operator': /[-+=*/%]/,
//DONE WITH MARGIN OF ERROR - SINGLE POUND CONSUMES NEXT LINE IF NO COMMENT IS ADDED AFTER POUND
'comment': /#([^\[].*?|\[[\s\S]*?]#)\b/g,
//DONE WITH MARGIN OF ERROR
'variable': /\b[A-Z]\w*/,
//DONE
'constant': /_[A-Z0-9_]+/,
//ERROR - CLASHING WITH THE PUNCTUATION "(" BECAUSE OF SELECTION (?=\() IN REGEX
'function': /\b(?!(else)?if|else|for(each)?|while|break|continue|local|switch|case|default|function|return)([a-z]\w*)(?=\()/,
//DONE
'number': /\b[-+]?[0-9]*\.?[0-9]+\b/,
//DONE
'string': {
pattern: /("|')(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/ig,
greedy: true
}