Community
    • Login

    Problems creating a new user defined language

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    udf
    10 Posts 3 Posters 6.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.
    • MaDillM
      MaDill
      last edited by

      Hi,

      I created a new user defined language for Denso robots called pacscript. I would say it looks not bad, but I still have some problems. I checked the link from the plugin http://udl20.weebly.com/introduction.html but it was not helpfull.

      I use Notepad++ 7.3.1 64bit with “User Defined Language v.2.1.0.12”

      Here is a sample program with the problems: http://pastebin.com/0vvpwrA2
      This is my UDF export: http://pastebin.com/DnrVtc6n

      Thank you for your time and help.

      Best Regards
      Matthias

      1 Reply Last reply Reply Quote 0
      • MaDillM
        MaDill
        last edited by MaDill

        I add some number problems to the sample program: http://pastebin.com/eQCqJUCj

        1 Reply Last reply Reply Quote 0
        • PeterJonesP
          PeterJones
          last edited by PeterJones

          FYI, UDL 2.1 is better described at http://ivan-radic.github.io/udl-documentation/ (the weebly link is for the older 2.0).

          (Sorry, no specific hints; I don’t have the time to study your examples, especially since the require going to an obfuscated link on an external site, which I try to avoid)

          1 Reply Last reply Reply Quote 0
          • MaDillM
            MaDill
            last edited by

            Thank you for the new link, maybe this can be updated in notepad++. But nevertheless I could solve some problems. But two main things are left:

            When I have words with numbers at the end and these are in parentheses, the number is displayed as number. For Example:

            IntVariable1 = 42
            

            This will be displayed normal

            If (IntVariable1 = 42) Then
            End If
            

            Here the 1 is highlighted as number. When I remove the nesting from the Delimiter, then allso the 42 is not highlighted anymore as a number.

            The next problem are the comments
            Comments can be ’ or Rem
            ’ is working fine, but with Rem I have the problem, that also “Call RemoveCharacter()” will be a comment. How to define that Rem is only the comment when there is a blank behind?

            The next thing what I can not work is the code folding. For easy Function…End Function it is working, but more complex not. I used following settings in the “Folding in code 2 style”

            • Open: Function Sub If For Select Do
            • Middle: Else
              *Close: “End Function” “End Sub” “End If” Next “End Select” Loop

            Any help is appreciated. Thank you.

            Here is some sample code:

            Function TestFunctionWithoutArg As Integer
            		'dasdsd
            End Function
            
            Function TestFunction1() As Integer
            	Do While (IntCounter < 42)
            		If (IntCounter <= 0) Then
            			Exit Loop
            		End If
            		IntCounter = IntCounter + 1
            	Loop
            	'dasdsd
            End Function
            
            Function TestFunction2(ByVal IntInput As Integer, ByRef IntOutput As Integer) As Integer
            	For IntCounter = 1 To (IntCounter1 + 3) 'the "1" in IntCounter1 should be no number
            		If (IntCounter = 13) Then
            			Exit For '"For" should be not used as open folding
            		End If
            	Next IntCounter
            
            	IntVarNumber1 = 12
            	IntVarNumber1Plus = 13
            
            	If (IntVarNumber1 = 12) Then
            		'dasdsd
            	End If
            
            	If (IntVarNumber1Plus = 13) Then
            		'dasdsd
            	End If
            
            	IntNumberBin1 = &B1031001 'should be no number because of the "3" inside
            
            	'line comment
            	Rem Comment
            	Call Remove '"Remove" should be not displayed as comment
            	Call Remove() '"Remove" should be not displayed as comment
            
            	Select Case IntCounter
            		Case 1
            		Case 13
            		Case Else '"Else" should be not used as open folding
            	End Select
            
            	If (IntCounter = 42) Then
            		Exit Function '"Function" should be not used as open folding
            	Else
            		IntCounter = 47
            	End If
            End Function
            
            
            Sub TestSub3(ByRef IntOutput As Integer)
            	If (IO[IntOutput] = On) Then
            		Reset IO[IntOutput]
            	Else
            		Set IO[IntOutput]
            		Exit Sub '"Sub" should be not used as open folding
            	End If
            End Sub
            
            
            Sub TestSub1()
            	'blabla
            End Sub
            
            
            Sub TestSub2
            	'blabla
            End Sub
            
            Claudia FrankC 1 Reply Last reply Reply Quote 0
            • PeterJonesP
              PeterJones
              last edited by

              @MaDill,

              In December, I put in issue 2713, and ivan-radic and chcg already talked about having Don Ho update the link to the UDL2.1 documentation; I have no idea when or if it will actually happen, however.

              Other than that, I don’t think you’ll like my answers. Sorry in advance.

              For the “Rem” vs “RemoveCharacter()”, I’ve come across this before (I couldn’t quickly find it in the forum, though I thought it was with “Rem” vs “Remove” or maybe “Remember” – but maybe it was in my own experimenting). As far as I remember, there is nothing that can be done with UDL2.1. If UDL were to add another version of the comment style that required separators (similar to the operators 1 not requiring spaces, but operators 2 requiring spaces), it would fix it; or if UDL were to allow regular expressions for the various entries, it would be an easy fix, Rem(?![a-zA-Z]) or similar.

              For the complex folding: because UDL2.1 is doing simple word-matching, rather than allowing full regular expression matching for fold indicators and keywords, there is no way you can disambiguate “Exit For” from "For blah = ", or “Case Else” from “If”/“Else”/“End If”. If it were using full regular expressions, those would be doable.

              For the (Variable1 = 2) incorrectly highlighting both the 1 and the 2 as numbers, but Variable1 = 1 working just fine outside of parentheses: that seems more like a bug than a lack of feature. I was able to re-create it with a very simple UDL language: Number styling was set to something obvious (Foreground=white, background=black), Delimiter 1 was set to (/), style: underline, foreground=red, background=white, and nesting=numbers

              I filtered the notepad-plus-plus repo issues for UDL, and saw 28 open UDL issues; you could read if any of those mention your problems or not. If not, I’d suggest adding them as separate issues, with a simplified example (don’t show your full UDL definition, just the smallest UDL that shows the exact issue – like I described for the in-parentheses vs no-parentheses re-creation, so there are no external downloads required to understand the issue – though an embedded ![](url://to/img.png) would probably be helpful, like I did). The nested-number-in-delimiter might possibly be a bug fix in UDL2.1, whereas for full regular expressions for the various entries, it’s probably going to be a UDL3 feature request; ivan-radic is non-publically working on UDL3, but no news as to when it might happen.

              1 Reply Last reply Reply Quote 0
              • Claudia FrankC
                Claudia Frank @MaDill
                last edited by

                @MaDill

                may I ask you why you do not use the builtin visual basic lexer?
                Your provided example matches 100% in terms of syntax.

                Cheers
                Claudia

                1 Reply Last reply Reply Quote 1
                • MaDillM
                  MaDill
                  last edited by

                  @PeterJones Thank you for your help.
                  @Claudia-Frank Good idea. I didn’t check this, because I added all the special keywords and preprocessor word already. I added now all the special keywords to the langs.xml and this is working. But I need some more keyword groups and not only “instre1”. I added the the “instre2” and “type1” to “type4”, add them also in the “styler.xml” but it is not working. The keywords are in the list, when I check Settings > “Style Configurator…”. Do you have one more hint?

                  Claudia FrankC 2 Replies Last reply Reply Quote 0
                  • Claudia FrankC
                    Claudia Frank @MaDill
                    last edited by

                    @MaDill

                    I’ve tested it and can confirm your findings but currently, I do not understand why it
                    can’t be done. From your description it sounds that you’ve done what you needed to do
                    except that vb lexer only support 4 different keyword lists.
                    The issue seems to be the keyword list as I see that the styles I have defined are
                    registered with scintilla editor. Unfortunately I cannot see which keywords
                    are registered. I will try to see if I can figure out what’s going on.

                    Cheers
                    Claudia

                    1 Reply Last reply Reply Quote 0
                    • Claudia FrankC
                      Claudia Frank @MaDill
                      last edited by

                      @MaDill

                      ok - I assume I found the reason why it isn’t allowing more than one keyword list.
                      in ScintillaEditView.h

                      void setVBLexer() {
                      	setLexer(SCLEX_VB, L_VB, LIST_0);
                      };
                      

                      contrary to the LexVB.cxx

                      static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,
                                                 WordList *keywordlists[], Accessor &styler, bool vbScriptSyntax) {
                      
                          WordList &keywords = *keywordlists[0];
                          WordList &keywords2 = *keywordlists[1];
                          WordList &keywords3 = *keywordlists[2];
                          WordList &keywords4 = *keywordlists[3];
                      

                      As this is hardcoded - I don’t see how this can be changed easily.

                      Cheers
                      Claudia

                      1 Reply Last reply Reply Quote 0
                      • MaDillM
                        MaDill
                        last edited by MaDill

                        @Claudia Frank Thank you for looking in the source code. Then I decided to stick with my own created UDL even code folding and some others are missing. It feels better to me to have at least the requested keywords are highlighted.

                        Best regards
                        Matthias

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