Unable to use custom parser in FunctionList
-
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 -
Could you provide:
- more information about the language or a link where to find more infomation;
- an example file;
-
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 returnthere is potentially a small truck load of procedures in at least one file.
Thanks for the quick response.
Pat -
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. -
Try this:
<parser displayName="lnn" id ="script_file" commentExpr="(?m-s:;.*$)" > <function mainExpr="(?m)^\$PROCEDURE\s+\K\w+" /> </parser>
-
I’m not an expert on the functionList, or the regular expressions it uses, but things I see:
-
you are using smart quotes
“...”
instead of straight-quotes"..."
in many places (and inconsistently:";.“
) -
your
mainExpr
is requiring any character (.
) between the start-of-line and the dollar sign$
-
$
is a special character to regular expressions, so you need to escape it with a backslash:\$
-
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). -
-
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