FunctionList - Alphabetical sort not (quite) working?

stepher
2013-11-07
2013-12-06
  • stepher
    stepher
    2013-11-07

    Hi all,

    Thanks much for upgrading FunctionList (sort AND reload!). I truly appreciate it and have now moved to 6.5.1.

    I'm trying to figure out if I (or FunctionList) have a problem.

    My ASM parser I added to functionlist.xml seems to work (mostly...still need to do some closer checking). I noticed a couple of things. First, FL doesn't pick up a label if the line immediately after the label is a comment (starting w/a ";"). However, if the following line is blank or contains any spaces, it seems OK. It's like it's looking for more of a C-kind of function rather than a label followed by some (or no) code. Is there something in the parser that can solve this?

    Secondly, the alphabetic sort seems to place labels in odd places (like early up in the list) if there is a blank line before the label. If the line before the label contains any spaces, the label is moved up higher/earlier in the list. As an example, a label that starts with A-Z and a space in the line before it is seen as being less than a label w/a dash ("-") at the beginning. Again...parser?

    Here's what I have at present:

            <parser id="asm_funct" displayName="Assembly" commentExpr=";">
                        <function
                            mainExpr="(^[\s]*[A-Za-z0-9_]+:)"
                             displayMode="$className->$functionName">
                            <functionName>
                                    <nameExpr expr="^[\s]*[A-Za-z0-9_]+"/>
                            </functionName>
                        <className>
                            <nameExpr expr="[\w_]+(?=[\s]*::)"/>
                        </className>
                        </function>
                </parser>
    

    I also have the following association:

            <association langID ="32" id="asm_funct"/>
    

    I will take another look at my parser and see if there is something I need to modify. If someone sees something obvious, I would greatly appreciate it. Thanks.

    Cheers...Steph

     
  • stepher
    stepher
    2013-11-11

    BUMP!!

     
  • Menno Vogels
    Menno Vogels
    2013-11-12

    How about this?

      <parser id="asm_funct" displayName="Assembly" commentExpr=";.*$">
        <function mainExpr="^[\t ]*\w+:" displayMode="$functionName">
          <functionName>
            <nameExpr expr="\w+"/>
          </functionName>
        </function>
      </parser>
    
     
  • stepher
    stepher
    2013-11-13

    Thanks for the time and help. Unfortunately, your suggestion didn't work :(

    However, I did find a solution. When I removed the char from the commentExpr it solved the problem. Not completely sure why, but it seemed to do the job.

    1st line now looks like this (ignore "\"....couldn't get it to display otherwise):

    \<parser id="asm_funct" displayName="Assembly" commentExpr="">

    Cheers....Steph

     
    Last edit: stepher 2013-11-13
  • Menno Vogels
    Menno Vogels
    2013-11-14

    Great to hear you found a solution!

    However, I am wondering why my suggestion did not work.
    What do you expect the parser to show in the function-list panel?

     
  • stepher
    stepher
    2013-11-15

    Your solution gave me 0 results (as in, it didn't work at all). Maybe I copied/pasted it wrong for some reason. I may go back and check that when I have the chance (the code is still in the XML file, but it's commented out).

    My original XML code produced mostly what I wanted, but as I mention above, sorting was off and whether or not a label was displayed in the FL window depended on what was in the line before or after the label (";" followed by a comment without any code in the line seemed to be the "trigger"). Once I removed the ";" from commentExpr, every label was visible and displayed in the right order without being affected by the contents of the previous or following line.

     
  • Menno Vogels
    Menno Vogels
    2013-11-17

    This one should do:

    <association langID="32" id="ASM_function" />
    
    <parser id="ASM_function" displayName="Assembly" commentExpr=";.*?$">
      <function mainExpr="^[\t ]*[A-Za-z_][\w]+:" displayMode="$functionName">
        <functionName>
          <nameExpr expr="[A-Za-z_][\w]*" />
        </functionName>
      </function>
    </parser>
    

    See also https://sourceforge.net/p/notepad-plus/discussion/331753/thread/b9d2fe00/#167e

     
    • stepher
      stepher
      2013-11-23

      Apologies for delayed response. I am not getting email notifications that someone has responded to my postings/threads. And I haven't been back to this forum in a bit.

      Thanks for the revised parser. I'll check it out when I get the chance and let you know how well it works for me. Just as a point of info (and don't know if it makes any difference): I am working with 8051 assembler code.

       
  • elmonty
    elmonty
    2013-11-21

    Is there a way to save the sort order so I don't have to keep clicking the sort button?

     
    • Menno Vogels
      Menno Vogels
      2013-11-24

      Good question and that would be a great addition to the function list plugin!

      However, you might want to post the question in the plugin forum and/or add a feature request (Tickets > Feature Requests).

      EDIT:
      Stepher already posted about the sort setting, see https://sourceforge.net/p/notepad-plus/discussion/331753/thread/e7ed2f93/#473d

       
      Last edit: Menno Vogels 2013-11-24
  • Menno Vogels
    Menno Vogels
    2013-11-24

    Hi Stepher,

    I really appreciate any feedback on the revised parser.
    FYI: I don't code in assembler myself so can't tell the difference between 8051 assembler code and any other assembler code.

     
  • stepher
    stepher
    2013-11-25

    Menno,

    Tried your parser and, sorry to say, no luck. Still doesn't work :(

    A few obvious things to me (if I understand Scintilla at all):
    1. I allow any char except white space at the beginning of the line
    2. My char set is limited to upper/lower case letters and "_" (underscores)
    and, this may be the most important one,
    3. It looks like you require an underscore (\w) at the end of the label (which is more of a high level language format than assembler). Assembler can have underscores (why I allow them) but I've never known them to be standard or required.

    Cheers....Steph

     
  • Menno Vogels
    Menno Vogels
    2013-11-27

    That [\w]+ should have been [\w]*. The square brackets are not required, added them for readability.
    FYI: \w is equivalent to [A-Za-z0-9_].

     
  • stepher
    stepher
    2013-12-06

    Hi Menno,

    Hmmmm....thought I posted this last week (Must have gotten started, then distracted by something else :(

    Anyway, I recopied and retested your asm parser. Works fine (can't tell it apart from mine ;)

    Also, thanks for the clarification of "\w". I must have read something else as the description because that's not what I remembered reading. As I mentioned, I only think I know Scintilla (at least, enough to get my asm parser working). Some of the more obvious "nuances" escape my understanding.....(and, sometimes my sight).

    Cheers...Steph