FunctionList with prefixed functions
-
The notepad function list does not seem to recognize interrupt functions which require a specific keyword to the compiler.
_interrupt(T1_INT) void T1_Overflow_ISR(void){
This works though.
_interrupt void T1_Overflow_ISR(void){
I’ve tried to edit the match in the functionList.xml. But regex is a true art I do not master.
^[\t ]*((static|const|virtual|_interrupt\([^\)\(]*\))[\s]+)?[\w:]+([\s]+[\w]+)?([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|while|for))[\w_]+[\s]*\([^\)\(]*\)([\s]*const[\s]*)?[\n\s]*\{
Is is possible to have notepad understand functions prefixed with _interrupt(ANY) ?
-
The clause ‘_interrupt([^)(]*)’ says find the word _interrupt followed by a bracket then 0 or one of: anything not a closing or opening bracket followed by a bracket. The * operator is ‘greedy’, so in the first example it considers ‘(T1_INT) void T1_Overflow_ISR(void)’ as one chunk from the first opening bracket to the last, and finds opening and closing brackets within it, so it rejects it. To make it non-greedy so that it stops at the first closing bracket, use ? as so '_interrupt([^)(]?)'.
However, since the brackets after _interrupt are optional, it might be clearer to use ‘_interrupt((.*?))+’ which reads: find _interrupt followed by 0 or 1 of: opening bracket, some characters non-greedy, closing bracket).
-
Oops, should have used markdown in my reply above.
To make it non-greedy so that it stops at the first closing bracket, use a ‘?’ after the ‘*’ as so:
_interrupt\([^\)\(]*?\)
However, since the brackets after _interrupt are optional, it might be clearer to use
_interrupt(\(.*?\))+
which reads: find _interrupt followed by 0 or 1 of: opening bracket, some characters non-greedy, then closing bracket).
-
Took some time, but I’m working on a project with these features again.
Well, I’ve tried it. But too bad, it doesn’t work.
Meanwhile the solution is just to add this one line higher.
void T1_Overflow_INT(void){ }
-
Hello @Jeroen6,
this should do the trick, I hope I didn’t break any other functions.
It’s basically Peter Brands proposal with a little modification (using * instead of +, as it is optional)
and introduced a new nameExpr to catch the interrupt functions.<parser id="c_function" displayName="C source" commentExpr="((/\*.*?\*)/|(//.*?$))"> <function mainExpr="^[\t ]*((static|const|virtual|_interrupt(\(.*?\))*)[\s]+)?[\w:]+([\s]+[\w]+)?([\s]+|(\*|\*\*)[\s]+|[\s]+(\*|\*\*)|[\s]+(\*|\*\*)[\s]+)([\w_]+[\s]*::)?(?!(if|while|for))[\w_]+[\s]*\([^\)\(]*\)([\s]*const[\s]*)?[\n\s]*\{" displayMode="$functionName"> <functionName> <nameExpr expr="(?!_interrupt(\(.*?\))*) [\w_~]+[\s]*\("/> <nameExpr expr="(?!(if|while|for))[\w_~]+[\s]*\("/> <nameExpr expr="(?!(if|while|for))[\w_~]+"/> </functionName> </function> </parser>
Cheers
Claudia