Open michthom opened 10 years ago
Yay. Fixed it, I think.
I nested the non-comment options one level lower so comments take priority, and the function parsing works as expected.
So from this:
<string>(?x: (?P<function> (?P<function_name> (?> _* [A-Za-z] [A-Za-z0-9_]* ) (?: (?: (?> (?> \s+ ) | (?P>comment) | (?P>string) ) )* :: (?: (?> (?> \s+ ) | (?P>comment) | (?P>string) ) )* ~? _* [A-Za-z] [A-Za-z0-9_]* )? ) (?: (?> (?> \s+ ) | (?P>comment) | (?P>string) ) )* (?P<parens> \( (?: (?> (?> [^'"()]+ ) | (?: / (?![/*]) ) | (?P>comment) | (?P>string) | (?P>parens) ) )* \) ) (?: (?> (?> \s+ ) | (?P>comment) | (?P>string) ) )* (?: : (?: (?> (?> [^'"{]+ ) | (?: / (?![/*]) ) | (?P>comment) | (?P>string) ) )* )? (?P<braces> { (?: (?> (?P>comment) | (?> [^{}]+ ) | (?: / (?![/*]) ) | (?P>string) | (?P>braces) ) )* } ) ) )</string>
To this:
<string>(?x: (?P<function> (?P<function_name> (?> _* [A-Za-z] [A-Za-z0-9_]* ) (?: (?: (?> (?> \s+ ) | (?P>comment) | (?P>string) ) )* :: (?: (?> (?> \s+ ) | (?P>comment) | (?P>string) ) )* ~? _* [A-Za-z] [A-Za-z0-9_]* )? ) (?: (?> (?> \s+ ) | (?P>comment) | (?P>string) ) )* (?P<parens> \( (?: (?> (?> [^'"()]+ ) | (?: / (?![/*]) ) | (?P>comment) | (?P>string) | (?P>parens) ) )* \) ) (?: (?> (?> \s+ ) | (?P>comment) | (?P>string) ) )* (?: : (?: (?> (?> [^'"{]+ ) | (?: / (?![/*]) ) | (?P>comment) | (?P>string) ) )* )? (?P<braces> { (?: (?> (?P>comment) | ( (?> [^{}]+ ) | (?: / (?![/*]) ) | (?P>string) | (?P>braces) ) ) )* } ) ) )</string>
Hi there - love this CLM, though I only found it recently. I've noticed that if I include comments with any of the characters ' " or { (but not &close curly brace - } ) then BBEdit can't find the current function boundary any more, and starts reporting for / if blocks as new functions. I'm guessing it's somewhere in the Function Pattern, but my regex analysis isn't up to finding the culprit.
So this parses correctly. and the functions are both shown in the browser:
But these don't, and only the first function appears, the second gets mistaken for a loop: