Regex for Function List in User Defined Language (Business Rules!)
-
Hi John,
User Defined Language doesn’t support (yet) regex.
So in your cas, you can only colourise def (or DEF).I’ll do a feature request to Loreia (the person who develops and maintains UDL), but it will not be soon even the FR is accepted.
-
Oh - I’m not trying to colorize it. I’m trying to make them appear in the functionlist side bar. :)
-
Oups sorry, I misunderstand you totally.
Each function takes only one line and whole line?
-
John,
Try this one:
([0-9][0-9][0-9][0-9][0-9][ ]|)(def|DEF) [\w]+(\(.*\)|)
-
oh it’s getting really close! I don’t fully understand everything I am doing. But here’s what I’ve got so far. I’va added these lines:
<association userDefinedLangName="BR! Source" id="brs_function"/>
and
<parser id="brs_function" displayName="BR! Source"> <function mainExpr="([0-9][0-9][0-9][0-9][0-9][ ]|)(def|DEF) [\w]+(\(.*\)|)" displayMode="$className->$functionName"> </function> </parser>
It encounters the first function in the program then and doesn’t stop… it thinks the rest of the program is a function. I need it to stop at the first “)”, “!” or CRLF (whichever of the three comes first) … I might have formatted my parser stuff wrong too… I didn’t know what to do with the <functionName> section so i just took it out… may have been a bad idea.
-
a little more clarification:
the function definition will always be on one line. the name ends at the first = or (. the variables passed to it (if any) start at the ( and end at the ) and are comma or semicolon delimited. (variables may include characters: a-z,A-Z,_,$,1-9 and &)
another kink:
the function definition line may or may not have the word “library” after the def before the function name. for example:
examples:
def library fnsteve
def fnsteve
def fnsteve(; x,y)
DEF LIBRARY FNSTEVE( x; y,e3$)
Def Fnsteve=13
Def Fnsteve=x12+rnd
01020 def library fnsteve
01030 def fnsteve
01040 def fnsteve(; x,y)
01080 DEF LIBRARY FNSTEVE( x; y,e3$)
01022 Def Fnsteve=13
41020 Def Fnsteve=x12+rndIn all of these fnsteve would be the function name. In some of these variables passed are like x, y and e3$.
-
Try this one:
([0-9][0-9][0-9][0-9][0-9][ ]|)(def|DEF)( library| LIBRARY|) [\w]+(\(.*\)|=.+|)
-
Closer still!!
That works beautifully until it encounters a ; then it puts everything on the same line… And also I failed to mention * may be in the variable parameter list… here is a better test list:
def fnwhatever (x,y,x)
fnend
def fn_another
fnend
def fnyeah$(nope)
fnend
100 def fnyop
200 fnend
300 def fnok
def library fnwhatever (x,y,x)
fnend
def library fn_another
fnend
def library fnyeah$(nope)
fnend
100 def library fnyop
200 fnend
300 def library fnok
def library fnsteve
def fnstevedef fntestastrisk(x$*20,big$*2048)
def fnsteve(; x,y)
DEF LIBRARY FNSTEVE( x; y,e3$)
Def Fnsteve=13
Def Fnsteve=x12+rnd
01020 def library fnsteve
01030 def fnsteve
01040 def fnsteve(; x,y)
01080 DEF LIBRARY FNSTEVE( x; y,e3$) -
oh geeze I forgot the &s. & may preceed any or all variables in the line. it’s allowed.
i.e.
def fnwhatever(x; &no,more, &spaceallowed)
-
@John-Bowman said:
That works beautifully until it encounters a ; then it puts everything on the same line…
A screenshot will explain everything.
-
Otherwise, you can try this one:
([0-9][0-9][0-9][0-9][0-9][ ]|)(def|DEF)( library| LIBRARY|) \w+\$?[ ]*(\(.*\)|=.+|)
-
Alternative:
(?i)(\d{3,5}[\t ]+)?DEF([\t ]+LIBRARY)?[\t ]+FN\w+\$?[\t ]*(\([^)]*\)|=)?
-
@donho yours was really close but it was adding everything to the end of the first line when it encounterd a $ for some reason.
@MAPJe71 WORKS GREAT!!!
I now have all my function lines listed in my Function List! Wonderful - I can double click on them and get right to them! SPECTACULAR!
So - one follow detail though - Is it possible for me to get the parameters as auto-complete things when typing code?
Here is what I have right now:
<parser id="brs_function" displayName="BR! Source"> <function mainExpr="(?i)(\d{3,5}[\t ]+)?DEF([\t ]+LIBRARY)?[\t ]+FN\w+\$?[\t ]*(\([^)]*\)|=)?" displayMode="$className->$functionName"> </function> </parser>
I notice most the other parser sections have a <functionName> part too - but I don’t… I’m really REALLY happy with what I have right now - but if I can take it a step farther I don’t want to miss out on all the fun =)
-
The Function List parsers are used to populate the Function List tree view only.
Auto-Complete has its separate configuration files in thePlugins\APIs
sub-folder, but I don’t know if it works for user defined languages. You could try by adding the applicablebrs.xml
.The
<functionName>
part is used to filter/resolve the function name e.g.<functionName> <nameExpr expr="(?i)FN\w+\$?[\t ]*(\([^)]*\))?" /> <!-- comment out the following node to display the method with its parameters --> <nameExpr expr="(?i)FN\w+\$?" /> </functionName>
-
you are correct. and yes, it does work with the UDLs. I have that working, but was only asking if I could use the cool regex syntax detecting settings in functionList.xml to accomplish the same thing. Perhaps I could do it more auto-magically over in there, but that is a subject for another thread. I’m going mark this bad boy solved. THANK YOU!!!