Next step to add user defined language SQR
Open User Language Dialog and and create new language SQR.
You can add some keywords, comments and nice formatting. Look here for details.
After that we can define Language Parsing Rule for Function List plugin.
But keep in mind, that SQR script has a lot nameless blocks, so function list could not show any text.
Recommended workaround to add some descriptive comment after begin word, e.g.
begin-program !my first app
Lets add new Group PROGRAMM and RegEx
and of course we need PROCEDURE group with 2 rules!
Rule 1.
Rule 2.
Press OK and enjoy with end result
Keywords for SQR have been taken here. Many thanks to Iouri Chadour!
Sincerely yours,
R
10 comments:
Thanks Ruslan, this worked like a charm for me. I apprecite the time and effort you put into this. Now I can share this functionality with the rest of my team.
If you have time, can you show me how to write my expression so that in the function list, I see "Begin-Program" in addition to procedure name?
PS. I was able to modify the existing Regex to include procedure names by adding the following to the Function List Name attribute;
[\w_]*+-+_+[A-Za-z0-9]+
as a result the following sample procedure shows up as "Print-File" in my Function list;
Begin-Procedure Print-File
Print 'Hello World' ()
End-Procedure
Now, if I can only figure out how to get function list to show;
"Begin-Procedure Print-File"
Thanks again for all of your help.
@Tom:
You don't need really so complex regex.
just use [\w_-]+
Is there a way to include the arguments in the procedures ?
Where do I go to understand how to define this syntax.
[\w_]*+-+_+[A-Za-z0-9]+
Tom could I get a copy of your final syntax, thanks
To: Scott
Please read description of regular expressions in NPP here
what means [\w_-]+ ?
it means that function name should contain at least one or more alphanumeric, underscore or minus.
Thanks for your help so far Ruslan.
I have fixed most of the things I want to at this stage although I do have 2 questions:
1. When you defined the PROCEDURE passign above you had 2 rules, what was this for do the rules run in a particular order ?
2. With the Procedures in SQR we can have some with arguments and some without, is there a way to show both, I have changed the fucntion list to be [\w_-]+\s*\(.*\) in rule 2 which gives me the Function and lists the arguments but the ones without arguements dissappear, I have tred a few different combinations but cannot get ti to work.
Hi Ruslan. thanks for the wonderful post. But can you help me as i was not able to find Language Parsing Rule .
i got my SQR colored but I need the function list.
Thanks
Ashwin
Thanks Ruslan for the useful tip. Is there any way we can get a tree structure in the same of the program flow? I mean Procedure calling another procedure it would be good if we can get that flow. if anything you are aware of please suggest
Ruslan,
Nice post!
Thanks
Post a Comment