• Login
Community
  • Login

MIB file (SNMP) syntax highlighting [User Defined Language]

Scheduled Pinned Locked Moved General Discussion
9 Posts 7 Posters 3.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.
  • U
    unknown14725
    last edited by unknown14725 Oct 16, 2019, 6:40 AM Oct 16, 2019, 6:39 AM

    I work on a lot of SNMP projects where I need to read MIB files. I could not find a UDL for MIB files anywhere on the net, but I found a few forum posts here and there where people request it. In the end I decided to make one for personal use, and figured i might as well share it.

    Download here: pastebin.com (save as i.e. userDefineLang-MIB.xml, and place in directory .\Notepad++\userDefineLangs)

    2019-10-16 08_21_03-HOST-RESOURCES-MIB-rfc2790.txt - Notepad++.png

    It’s very rough around the edges, and does not do folding (I could not get it to work due to the complexity of delimiters in ASN.1). It’s purely for visual syntax highlighting to ease on-screen reading of MIB files.

    G 1 Reply Last reply Apr 24, 2022, 7:28 AM Reply Quote 4
    • V
      Vincent Duvernet
      last edited by Apr 28, 2020, 12:13 PM

      wonderful :) I was looking for MIB/SNMP compatibility today :)

      But the BackColor is not working associated to DarkTheme :
      [https://github.com/Ludomancer/VS2015-Dark-Npp](link url)

      M 2 Replies Last reply Apr 28, 2020, 1:45 PM Reply Quote 0
      • P
        PeterJones
        last edited by Apr 28, 2020, 1:36 PM

        @Vincent-Duvernet said in MIB file (SNMP) syntax highlighting [User Defined Language]:

        But the BackColor is not working associated to DarkTheme

        User Defined Languages do not honor themes: if you change your theme, it does not change the coloring for the UDL syntax highlighter. You can use Language > User Defined Language > Define Your Language… to change the colors for your specific UDL.

        1 Reply Last reply Reply Quote 2
        • M
          Michael Vincent @Vincent Duvernet
          last edited by Apr 28, 2020, 1:45 PM

          @Vincent-Duvernet said in MIB file (SNMP) syntax highlighting [User Defined Language]:

          wonderful :) I was looking for MIB/SNMP compatibility today :)

          Why use a UDL? The default theme already has ASN.1 and that can be copied into (and adjusted for color) into your preferred theme (as @PeterJones mentions). I did this for Obsidian Theme which I use exclusively.

          You may need to associate your MIB extension with ASN.1 for Notepad++ to recognize the file on opening:

          Settings => Style Configurator… =>

          3540c3c6-4fb9-4c15-a9c3-dccd5f2c4d6e-image.png

          Cheers.

          1 Reply Last reply Reply Quote 3
          • M
            Michael Vincent @Vincent Duvernet
            last edited by Apr 28, 2020, 9:44 PM

            @Vincent-Duvernet said in MIB file (SNMP) syntax highlighting [User Defined Language]:

            wonderful :) I was looking for MIB/SNMP compatibility today :)

            You may also want it in the function list. I’ve added in my $(NPP_INSTALL_DIR)/functionList.xml file:

             <association id="asn1_syntax" langID="65"  />
            

            […] then down in the parsers section:

            <!-- ============== [ ASN.1 ] -->
            
            <parser
            	displayName="ASN.1"
            	id         ="asn1_syntax"
            	commentExpr="(?x)
            					(?m-s:\-\-.*$)    # Single Line Comment
            				"
            >
            
            	<classRange mainExpr="(?:^\s*\w+\s+::=\s+[\w-]+\s*)">
            		<className>
            			<nameExpr expr="(?:\s*)\K[\w]+"/>
            		</className>
            		<function
            			mainExpr="(?:^\s*\w+\s+)">
            			<functionName>
            				<funcNameExpr expr="(?:\s*)\K[\w]+"/>
            			</functionName>
            		</function>
            	</classRange>
            	<function
            		mainExpr="(?:^\s*\w+\s+OBJECT-\w+[\n\s]*)">
            		<functionName>
            			<nameExpr expr="(?:\s*)\K[\w]+"/>
            		</functionName>
            	</function>
            </parser>
            

            Cheers.

            1 Reply Last reply Reply Quote 2
            • J
              Joshua From Vietnam
              last edited by Apr 22, 2022, 4:56 PM

              @vincent-duvernet said in MIB file (SNMP) syntax highlighting [User Defined Language]:

              wonderful :) I was looking for MIB/SNMP compatibility today :)

              But the BackColor is not working associated to DarkTheme :

              Just stumbled on this UDL but you’re right it doesn’t come up very well in Dark Mode.

              So I tweaked it for DM here: at pastebin, with the URL: zC7fCauP

              (Sorry for the lack of a hyperlink, spam filters were blocking me.)

              Hope it can be useful.
              Cheers

              1 Reply Last reply Reply Quote 0
              • G
                gstavi @unknown14725
                last edited by Apr 24, 2022, 7:28 AM

                @unknown14725
                Long ago I worked with MIB files for ~1 year and wrote the lexamples plugin that provides MIB files and GNU Makefiles lexing.
                This is an external DLL lexer, not user defined language.

                I used it for writing GNU Makefiles for years. I haven’t touched MIB for 7 years.

                Haven’t used it for a while, it is possible that it was broken in latest NPP version but it should be possible to test the lexing quality with old NPP version. If the lexing is superior we could consider porting it to newer NPP version.

                Source code

                R 1 Reply Last reply Apr 24, 2022, 8:26 AM Reply Quote 3
                • R
                  rdipardo @gstavi
                  last edited by Apr 24, 2022, 8:26 AM

                  @gstavi,

                  Haven’t used it for a while, it is possible that it was broken in latest NPP version

                  This definitely won’t work:

                  ILexer *LexerMib::LexerFactoryMib()
                  {
                    return new LexerMib;
                  }
                  
                  ILexer *lexamples_create_mib_lexer()
                  {
                    return LexerMib::LexerFactoryMib();
                  }
                  

                  As other plugin developers are finding out, Scintilla 5 moved the lexer interface to the Lexilla library. The new API is ultimately better for external lexers — basically, every lexer is external now — once you get the hang of it.

                  G 1 Reply Last reply Apr 24, 2022, 8:41 AM Reply Quote 3
                  • G
                    gstavi @rdipardo
                    last edited by Apr 24, 2022, 8:41 AM

                    @rdipardo said in MIB file (SNMP) syntax highlighting [User Defined Language]:

                    This definitely won’t work:

                    That is why I said “test the lexing quality with old NPP version”.
                    if there is interest, I may invest the time. Or since the source code is available then maybe someone else will take over.

                    If everyone is happy with UDL, great.

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