Simple Function list but not working
-
Hi
I have looked at the help and FAQ and none the wiser :(The functions I am looking for have the syntax (not case-sensitive)
!whatever:rem
So!*:rem
works as a regular expressionThe language name and name of the function list are the same.
The language is a simple C version, so I took the c.xml, renamed it and displayed the name and ID tags.
Setting the function name does not make sense to me.<functionName> <nameExpr expr="(?x) # Utilize inline comments (see `RegEx - Pattern Modifiers`) [A-Za-z_\x7F-\xFF][\w\x7F-\xFF]* \s*\( ! # start of parameters (?s:.*?) # whatever, until... :rem\) # end of parameters " />
Can someone point out where I am wrong, please?
—
moderator added code markdown around text; please don’t forget to use the
</>
button to mark example text as “code” so that characters don’t get changed by the forum -
When I merge that regex into one line
(?x) [A-Za-z_\x7F-\xFF][\w\x7F-\xFF]* \s*\( ! (?s:.*?) :rem\)
, and try it in the MARK dialog, like the following:spacer func (!blah:rem) spacer notfunc (!something else) spacer stillnot (!this) spacer butyes (!whatever:rem) spacer butabsoultelynot (!whatever:rem ) spacer norspacey ( !whatever:rem) spacer
As you can see, it found three matches: line 2 was a single match, lines 4-8 was a single match, and lines 10-12 was the third match.
Function names for the FunctionList feature should normally resolve down to a single line of text (or less)
When I use your functionName’s nameExpr, I get:
… each of those entries matches the first line of the three blocks that MARK found. So it’s behaving as I’d expect it.Also note that your regex has some restrictions, like the
!
must come immediately after the(
with no spaces between, and the:rem
must come immediately before the)
with no spaces in between. I am not sure if that’s intentional.Since you gave no examples of text that you expected to show up in the function list panel and text you didn’t, I cannot know what you intended, and cannot try to help you fix it.
Update: But my guess is that even though you tried to make it non-greedy, the sub-expression
(?s:.*?)
is probably matching more than you think it does. I think you probably wanted it to stop if it ever hit a)
that wasn’t preceeded by:rem
, but you don’t have that there. If that’s the case, I would change it to(?s:[^)].*?)
… this would only find thefunc
and thebutyes
lines in my example code, which I think were the two that you would expect to match. -
Thanks for your time on this, Peter.
I have spent more time on this than it was worth and will shelve it until I get some more free time.