• Login
Community
  • Login

Function List - Help for adding a custom language

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
8 Posts 3 Posters 1.9k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    Mateos81
    last edited by Mateos81 Dec 15, 2018, 11:24 AM Dec 15, 2018, 11:22 AM

    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++ file

    Here 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/Uk9jdfzw

    The 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

    1 Reply Last reply Reply Quote 1
    • R
      rinku singh
      last edited by Dec 15, 2018, 11:53 AM

      modify the exiting language for test
      as css
      #define IDM_LANG_CSS (IDM_LANG + 10)

      1 Reply Last reply Reply Quote 0
      • M
        Mateos81
        last edited by Dec 15, 2018, 3:33 PM

        Hi,

        What do you mean by the “exiting language”? Where should I put this line?

        R 1 Reply Last reply Dec 15, 2018, 4:10 PM Reply Quote 0
        • R
          rinku singh @Mateos81
          last edited by Dec 15, 2018, 4:10 PM

          @Mateos81
          well in function list.xml go to line no. 59

               <association id="my_parser_id" userDefinedLangName="My UDL Name" />
          
          1 Reply Last reply Reply Quote 0
          • M
            Mateos81
            last edited by Mateos81 Dec 15, 2018, 4:16 PM Dec 15, 2018, 4:15 PM

            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

            1 Reply Last reply Reply Quote 0
            • R
              rinku singh
              last edited by rinku singh Dec 15, 2018, 4:53 PM Dec 15, 2018, 4:52 PM

              @Mateos81 said:
              i think this was a only comment
              uses is as
              displayName=“Omni-Bot”
              replace

              userDefinedLangName=“Omni-Bot”

              1 Reply Last reply Reply Quote 0
              • M
                Mateos81
                last edited by Dec 16, 2018, 9:27 AM

                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?

                1 Reply Last reply Reply Quote 0
                • guy038G
                  guy038
                  last edited by guy038 May 16, 2020, 1:46 PM May 13, 2020, 1:11 AM

                  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 function AXIS 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 the 22 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 !

                  https://community.notepad-plus-plus.org/post/53905

                  1 Reply Last reply Reply Quote 3
                  • First post
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors