User Defined language multiple questions
-
The functions can be defined by ‘method’ (for class) or ‘to’ for global functions.
-
which npp version do you use? Can be found as debug-info from ? menu (last menu item). With 7.7.1 it seems that folding is correct, regardless whether I open a gp file or if using a new file. Btw. I have add the gp to the extensions in udl.
-
Yes, I’m using 7.4.2. I’m going to update now.
-
don’t update. Download a zipped version and see if this changes what you want.
There are a lot of changes since 7.4, so you might run into other troubles. -
When variable contains numbers in it’s name and is inside parenthesis, the nuber are highlighted.
Is caused by the delimiter2 setting to allow nesting with numbers. What do you try to achieve with this delimiter?
-
I tried v7.7.1 and sadly it didn’t resolve my folding problem. And about the delimiter 2, I used it because if don’t numbers are not highlighted at all inside parenthesis.
-
But in the folding problem is not my main question with the workaround of opening a new file. I’m more intrusted in the variables/functions highlighting. If you could help would be awesome anyway.
-
I tried v7.7.1 and sadly it didn’t resolve my folding problem
With the same code you sent? What exactly do you do to see this behavior.
about the delimiter 2, I used it because if don’t numbers are not highlighted at all inside parenthesis
What do you try to achieve with this delimiter? Why is it needed at all?
-
I used delimiter 2 with parenthesis because when I’m not using it, numbers and strings are not highlighted at all, wich is kind of worse. But this is really not an issue. Just like the folding problem.
-
for function list you need to edit functionList.xml
I added to the end of associationMap tag
<association id= "gp_function" userDefinedLangName="GP" /> <association id= "gp_function" ext=".gp" />
and a new parser tag
<parser displayName="GP" id ="gp_function" > <!-- <classRange --> <!-- mainExpr ="(?<=^class\x20).*?(?=\n\S|\Z)" --> <!-- > --> <!-- <className> --> <!-- <nameExpr expr="\w+(?=[\(|:])" /> --> <!-- </className> --> <!-- <function --> <!-- mainExpr="(?<=def\x20).+?(?=:)" --> <!-- > --> <!-- <functionName> --> <!-- <funcNameExpr expr=".*" /> --> <!-- </functionName> --> <!-- </function> --> <!-- </classRange> --> <function mainExpr="(?m-s)(?<=to\x20).+?(?={.*$)" > <functionName> <nameExpr expr=".*" /> </functionName> </function> </parser>
The open part is how a class and its methods are defined. Is not part of your sample code.
Note, once you edit functionlist.xml you need to restart npp in order to make it work.
-
Midnight here - unless someone else takes over I will follow up on this tomorrow.
-
Thnks a lot for now.
I tried what you said but I still have problems.-
Only functions defined by ‘to’ are recognized.
-
The function are listed with the arguments in their name. For example :
to playABC s instr beatsPerMinute transposition { if (isNil instr) { instr = 'piano' } if (isNil beatsPerMinute) { beatsPerMinute = 120 } if (isClass instr 'String') { instrument = (newSampledInstrument instr) } (isClass instr 'Array') { instrument = (sampledInstrumentFromSamples instr) } else { return nil } scorePlayer = (newScorePlayer instrument beatsPerMinute) voice = (parse (new 'ABCParser') s) if (notNil transposition) { transpose (new 'ABCParser') voice transposition } addVoice scorePlayer voice playScore scorePlayer return scorePlayer }
Here, the name of the function is just ‘playABC’. Without ‘instr’, ‘beatsPerMinute’ and ‘transposition’.
Thanks a lot for all of this. But don’t hurry to help I won’t be able to answer for two weeks.
-
-
Only functions defined by ‘to’ are recognized.
:-) That’s no wonder as it isn’t included yet. Therefore my statement
The open part is how a class and its methods are defined. Is not part of your sample code. :-)The function are listed with the arguments in their name. For example :
Yes, as I don’t know this language and don’t know how you wanted it to be reported
I used<nameExpr expr=".*" />
which returns the whole line. For example, a change to
<nameExpr expr="\w+" />
would return the first word after to.But don’t hurry to help I won’t be able to answer for two weeks.
No problem. Just respond when you are back to this thread and we can go on.
As said, I need the class and its method definitions as an example.