Function List - Help for adding a custom language
-
Hello,
The game Wolfenstein Enemy Territory has a bot mod called Omni-Bot, which has a scripting part powered by the Game Monkey script language
It has as such added some particular functions etc. which are bundled through its repository with a custom Notepad++ installation
Currently, it has a parser definition that roughly works: it captures almost all the “namespace” and function names, but at the same level
Here it is:
<code>
<parser id=“ob_function_old” displayName=“Omni-Bot (old)” commentExpr=“((/*.?*)/|(//.?$))”>
<function mainExpr=“^[ \t]*(global |member )?([0-9A-Za-z_.]+)(\ *)=(\ )function(\ )(([0-9A-Za-z_,\ ]))" displayMode=“$functionName”>
<functionName>
<nameExpr expr="^[ \t](global |member )?\K[0-9A-Za-z_.]+”/>
</functionName>
</function>
</parser>
</code>I’d like to improve it so the functions are inside the “namespaces”, and that all parts are captured
I ran the various regular expressions in regex101 to check them, but they doesn’t seem to work once in the N++ fileHere is the script I’ve modified:
<code>
<!-- ========================================================== [ GM ] -->
<!-- GM - Game Monkey script for Omni-Bot --><parser
displayName=“Omni-Bot”
id =“ob_function”<classRange mainExpr ="\w*(global)\s+([0-9A-Za-z_\.]+)\s*\=\s*(function\(\s*\w*\s*\)){0,1}\s*\{" openSymbole ="\{" closeSymbole="\}\;" > <className> <nameExpr expr="\w*(global)\s+\K[0-9A-Za-z_\.]+" /> </className> <function mainExpr="\s*\K[0-9A-Za-z_\.]+\s*\=\s*(function\(\s*[0-9a-zA-Z_\.]*\s*\))?\s*\{" > <functionName> <nameExpr expr="\s*\K[0-9A-Za-z_\.]+"/> </functionName> </function> </classRange>
</parser>
</code>And here is an example file:
https://pastebin.com/Uk9jdfzwThe current definition outputs:
<code>
navigate
OnEnter
Test
Test2
OnMapLoad
OnBotJoin
InitializeRoutes
</code>The goal is to have something like:
<code>
Map
Navigation
jump
navigate
Roles
Axis
DEFENDER
DEFENDER1
AxisBridgeSuicide
OnEnter
Test0
Test
Test2
OnMapLoad
OnBotJoin
InitializeRoutes
</code>(What’s above it supposed to be indented but heh I’m probably using the wrong MarkDown stuff)
My modified parser just outputs nothing atm…
The script part in userDefineLang.xml is the same between these two, I don’t think you need that in order to help?
Do you see what’s wrong? ^^’
Thank you in advance,
Regards,
Mateos
-
modify the exiting language for test
as css
#define IDM_LANG_CSS (IDM_LANG + 10) -
Hi,
What do you mean by the “exiting language”? Where should I put this line?
-
@Mateos81
well in function list.xml go to line no. 59<association id="my_parser_id" userDefinedLangName="My UDL Name" />
-
Ah I have this there:
<!-- ======================================================================== -->
<association id= “ob_function_old” userDefinedLangName=“Omni-Bot (old)” />
<!-- ======================================================================== -->
<association id= “ob_function” userDefinedLangName=“Omni-Bot” />
<!-- ======================================================================== -->That’s what I use to test; like now if I switch through the N++ menu to either of these languages, well original works but mine don’t
I should have precised that’s present in the file yeah, without you can’t select the language ^^’
Edit: And ofc related entries in userDefineLang.xml
-
@Mateos81 said:
i think this was a only comment
uses is as
displayName=“Omni-Bot”
replaceuserDefinedLangName=“Omni-Bot”
-
Hmm I think it’s already the case, or I’m mistaking something?
I have two association and parser tables, one is Omni-Bot (old) and the other is Omni-Bot in functionList.xml, same in userDefineLang.xml
Old works fine, it’s the new one the issue, it doesn’t seem to parse anything
Have you tried adding these to your files and checked the two configurations?
-
Hi, @mateos81 and All,
Concerning your present parser :
<parser id="ob_function_old" displayName="Omni-Bot (old)" commentExpr="((/\*.*?\*)/|(//.*?$))"> <function mainExpr="^[ \t]*(global |member )?([0-9A-Za-z_\.]+)(\ *)\=(\ *)function(\ *)\(([0-9A-Za-z_\,\ ]*)\)" displayMode="$functionName"> <functionName> <nameExpr expr="^[ \t]*(global |member )?\K[0-9A-Za-z_\.]+"/> </functionName> </function> </parser>
I modified and simplified the different regexes, in the same way I did, in my previous post ! So, I ended up with this version :
<parser id="ob_function_old" displayName="Omni-Bot (old)" commentExpr="/\*.*?\*/|//.*?$"> <function mainExpr="(?-i)^\h*(global\x20|member\x20)?[\w.]+\x20*=(\x20*function\x20*\([\w,\x20]*\))?\s*\{" displayMode="$functionName"> <functionName> <nameExpr expr="(?-i)^\h*(global\x20|member\x20)?\K[\w.]+"/> </functionName> </function> </parser>
Remark :
- Because of the in-line
//
comment, the functionAXIS
does not appear in the function-list panel. Logical !
AXIS = // Team
So, three work-around syntaxes are possible :
AXIS = { // Team AllBots = true, // Each bot is considered for a role
or :
AXIS = { // Team AllBots = true, // Each bot is considered for a role
or :
// Team AXIS = { AllBots = true, // Each bot is considered for a role
Note that, with the
1st
solution, there must be, at least,two
blank characters, between the{
and the start comment//
, although I don’t understand exactly why ;-))
Given your example file : https://pastebin.com/Uk9jdfzw and using the syntax
AXIS = { // Team
, the function List panel displays the22
elements, below :Map Navigation jump navigate Roles AXIS DEFENDER DEFENDER1 AxisBridgeSuicide OnEnter Test0 Test Test2 Test_3 OnMapLoad OnBotJoin InitializeRoutes MapRoutes BUILD_Command_POST NonFunctionClassLevelTest NonFunctionClassLevelTestWithFunction Test
I didn’t study your enhanced parser, with
classRange
node, yet ! I hope to be able to get some results as I know very little about objects classes :-((Cheers,
guy038
P.S. :
To test your parser, I used the following association
<association id= "ob_function_old" langID= "0" />
which enabled me to simply use
Normal Text
language ;-))IMPORTANT : Follow the link, below, for further discussion !
- Because of the in-line