UDL - Custom Language with multiple languages nested
-
Hopefully this is the right forum for this and sorry if this is a basic question, but I am really struggling with creating my own UDL.
I’m trying to create a UDL for writing custom alert messages for a monitoring software called SolarWinds Orion. They have these variables you can put in the message body that will resolve to data in the database. There are pre-defined variables you can use or you can actually put custom SQL statements inside of the variable brackets and have the results of that SQL query be displayed in the message body. You can also put HTML in the message body to make it look nicer when the alert is triggered and the alert message is sent via email.
This means I need a UDL with essentially 3 different formats.
- All predefined variables start with ${ and end with }. Inside of that would be the Orion Alert “language”.
- Custom SQL Variables start with ${SQL: and end with }, so inside of this would be SQL language
- HTML tags can be placed anywhere in the message body except inside of variables, so everywhere outside of the ${} brackets would recognize the HTML language.
- Anything outside of the three delimiters above would just be a single style, even if there are keywords from one of the 3 Keyword groups in it.
There is no comment standard defined by SolarWinds. Any characters in the message body will be interpreted. However, since I will often have a single text document with multiple alert messages in it, having my own comment format wouldn’t be a bad idea to use for marking it up in Notepad. It could be any character set honestly, so either #, <!, or /* really, it doesn’t matter.
What I’ve tried:
– I created 3 Keyword Groups in the UDL GUI. One with all of the HTML keywords I copied from the langs.xml file, one with all of the SQL keywords I copied from the langs.xml file, and one with all of the Orion Alert message keywords I could find or think of.
– I then created three delimiter sets, one for each keyword group, and each delimiter set had a corresponding keyword group selected in its “Nesting” option. So the Delimiter that starts with ${ and ends with } had the Orion keyword group nested, the Delimiter starting with ${SQL: and ending with } had the SQL Keyword Group nested, and the Delimiter starting and ending with <> had the HTML Keyword Group nested.
My Problem
– It seems to be formatting all of the keyword groups even outside of the delimiters. Words like from, in, and, etc. are being formatted even when just in the message body. So I basically need a way to apply a style based on a keyword group only when the keywords are found inside of their corresponding delimiters. The Keywords should be completely ignored outside of the matching delimiter set.
– I envision all text inside of a certain delimiter to be a certain color, and then the keywords an even different color. The basic format should just be black text for everything outside of a delimiter set. Inside of the SQL delimiter (${SQL: }) all text should be blue and the keywords purple. Inside of the Orion delimiter (${}) all text should be green and the keywords yellow, and everything inside of the HTML delimiters should be brown and the keywords orange.
– Inside of the Orion variables, the syntax goes something like this: ${N=Alerting;M=AlertName}. The words “Alerting” and “AlertName” are in the Orion keyword group. I’m undecided, and honestly have no clue how to, handle the N=, the ;, and the M= characters. Those are operators I guess? If so, how do I have them only formatted when inside of the Orion delimiters?
– With the Orion delimters starting and ending with ${} and the SQL version of the variable essentially starting and ending with the same brackets ${SQL: }, how do I need to handle this so that they are seen as two distinct delimiter sets?
Thanks for any help you can provide. I know that’s a ton of stuff, but every instruction manual and tutorial I found just mostly goes over my head. A lot of it seems to be written assuming the reader already has some base set of knowledge (like I couldn’t really find descriptions of exactly what Keywords, Delimiters, and Operators are. I mean, they are kind of self explanatory, but the definition of them in the context of Notepad++ would be real nice.). Basically, I was looking for a “for dummies” level tutorial and couldn’t find one…
-
a long post, but unfortunately there is a short answer.
The way you want to have it work cannot be achieved with UDL.The first misunderstanding is, that you can define keywords which only
get colored when surrounded by delimiter. This isn’t the case, keywords get
colored when found.Next, you cannot define delimiters which are subsets of other delimiters.
Sorry, either you redefine your requirements or you need to use a different approach
like writing your own lexer (can even be done with python or lua script plugins).The documentation about UDL is here.
Cheers
Claudia