Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Unable to use custom parser in FunctionList

    Help wanted · · · – – – · · ·
    function list custom language problems
    3
    7
    3003
    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.
    • Pat Sinclair
      Pat Sinclair last edited by

      I am working on utilizing the function list with a custom language.
      I am attempting to identifiy the procedures only however unable to do so. Procedures are identified by $PROCEDURE procedurename.

      My parser looks like such. I am specifying the file extension as described in the documentation.
      <association ext=“.lnn” id=“script_file” />
      Parser as such:

      <parser displayName=“lnn” id=“script_file” commentExpr=“;.“>
      <function
      mainExpr=”^.
      $procedure\s+” displayMode=“$functionName”
      >
      <functionName>
      <nameExpr expr=“.*+” />
      </functionName>
      </function>
      </parser>
      There is no open and close symbol in this language wrapping a procedure.
      Thanks in advance for any tips and or guidance you can provide.
      Pat

      1 Reply Last reply Reply Quote 0
      • MAPJe71
        MAPJe71 last edited by

        @Pat-Sinclair

        Could you provide:

        1. more information about the language or a link where to find more infomation;
        2. an example file;
        1 Reply Last reply Reply Quote 0
        • Pat Sinclair
          Pat Sinclair last edited by

          Example file…well at least one procedure …

          ;***************************************************************************
          ;
          ; header that is coments etc.
          ;***************************************************************************
          $PROCEDURE DoSomething
          $DEFINE TEMPVAR LVar
          ; Comment
          If<= LVar 0 Value 1
          Begin
          ;if lvar 0 is true
          End
          ;do some things
          Return ; may not always be here…at the end of the file, we will bail and don’t need the return

          there is potentially a small truck load of procedures in at least one file.

          Thanks for the quick response.
          Pat

          1 Reply Last reply Reply Quote 0
          • MAPJe71
            MAPJe71 last edited by

            @Pat-Sinclair

            Thank you for the example, that answers my second question.
            Could you also answer the first question?
            Knowing the name and the grammar (in BNF format) of the language would be very helpfull.

            1 Reply Last reply Reply Quote 0
            • MAPJe71
              MAPJe71 last edited by

              @Pat-Sinclair

              Try this:

              <parser
                  displayName="lnn"
                  id         ="script_file"
                  commentExpr="(?m-s:;.*$)"
              >
                  <function
                      mainExpr="(?m)^\$PROCEDURE\s+\K\w+"
                  />
              </parser>
              
              1 Reply Last reply Reply Quote 1
              • PeterJones
                PeterJones last edited by

                @Pat-Sinclair,

                I’m not an expert on the functionList, or the regular expressions it uses, but things I see:

                1. you are using smart quotes “...” instead of straight-quotes "..." in many places (and inconsistently: ";.“)

                2. your mainExpr is requiring any character (.) between the start-of-line and the dollar sign $

                3. $ is a special character to regular expressions, so you need to escape it with a backslash: \$

                4. My attempt didn’t seem to work when I just used the extension in the association; when I also defined a UDL (User Define Language) that I called “lnn” and set the association’s userDefinedLangName, then it started to work for me…

                   <association id="fn_udl_lnn" ext=".lnn" />
                   <association id="fn_udl_lnn" userDefinedLangName="lnn" />
                   ....
                   <parser displayName="lnn (UDL)" id="fn_udl_lnn" commentExpr=";.">
                       <function
                           mainExpr="^[\s]*\$procedure[\s]+[\w_]+"
                           displayMode="$functionName"
                       >
                           <functionName>
                               <nameExpr expr="\$procedure[\s]+[\w_]+" />
                           </functionName>
                       </function>
                   </parser>
                  

                I’m not a regular-expression expert, but this <parser> at least gets to the point that it’s parsing your example function list (actually, my file took two copies of yours, and gave the name “DoSomethingElse” to the second copy, just to make sure it would find more than one $PROCEDURE).

                There are fancier definitions that will do more: for example, I know there’s a way to get syntax like (?!blah) to mask out the $PROCEDURE from being listed in the name for every procedure, but I couldn’t get (?!\$procedure) or (?!(\$procedure)) to work).

                1 Reply Last reply Reply Quote 0
                • Pat Sinclair
                  Pat Sinclair last edited by

                  Thanks MapJE71 and Peter…

                  I too had to add the userDefinedLangName, then all worked fine using MapJe71’s suggested regex.

                  Thanks to you both.
                  Pat

                  1 Reply Last reply Reply Quote 1
                  • First post
                    Last post
                  Copyright © 2014 NodeBB Forums | Contributors