Syntax Color entire line following Exclamation Mark !

I've read countless KBs and Forum posts and for the life of me I cannot get my mind wrapped around this silly custom syntax configuration language. It just makes no sense to me.

All I'm trying to do is treat the ! character as the start of a comment and continue until the end of the line.  I can get it to color the ! itself but that is all.  I want it to continue until the end of the line.  

I would think according to the documentation it would be as simple as 

      <lexem BeginBlock="!" Type="Comment"   EndBlock="\n" IsEndRegex="true"/>

That won't highlight anything though.

I even found a reference somewhere to doing comments like this:

<ConfigLanguage name="Cisco" CaseInsensitive="true" StartComment="!">

But that's not doing anything either.


Does anyone have a better primer or set of examples that are more intuitive than the 1-2 paragraphs in the documentation that basically speak gibberish?

3 Replies

EF Eric Fetty March 30, 2018 07:25 AM UTC

I can't even get it to highlight a simple IP address using REGEX

123.123.123.123

      <lexem BeginBlock="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" IsBeginRegex="true" Type="KeyWord" />

I'm beginning to think it would faster to just build my own control from scratch given the mystical nature of this config language.


EF Eric Fetty March 30, 2018 04:06 PM UTC

Ok, it looks like I got the comment to work  using the following

      <lexem BeginBlock="!" Type="Comment" IsBeginRegex="false" ContinueBlock=".+" IsContinueRegex="true" />


But how do I match a literal period in the regex as the usual escaped period does not match  \.   vs .


DR Durga Rajan Syncfusion Team April 2, 2018 11:30 AM UTC

Hi Eric, 

Thanks for contacting Syncfusion support. 

Query 1 : How to highlight IP address with specific color and how do I match a literal period in the regex as the usual escaped period does not match  \.   vs . 

We have checked your requirement about highlighting IP address with some specific color and we have prepared sample for the same. In this sample we have used the given RegEx format in the BeginBlock of the Lexem and we have mentioned the same in Split collection, so that the given format will be considered as single text instead of separating special characters from given IP. Please find more information about Split in below link, 


Code Example to highlight the IP address: 
 
<lexems>       
      <lexem BeginBlock="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" IsBeginRegex="true" IsContinueRegex="true"  Type="IPFormat" />       
    </lexems> 
    <splits> 
          <split IsRegex="true">(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})</split>      
    </splits> 


Query 2 : it looks like I got the comment to work  using the following 

We have checked your requirement “Highlighting the entire text in the line as comment section”. You can use the same code(which was mentioned in your last update), to Highlight the Comment block. Also you can use below codes to highlight the comment section. We have used the same code in the attached sample. In this sample, we have mentioned the EndBlock and enable the properties IsComplex and OnlyLocalSublexems as true.  

Code Example to highlight the comment block : 

<lexem BeginBlock="!" Type="Comment" OnlyLocalSublexems="true" EndBlock="\n" IsComplex="true"/>   

If we have misunderstood your query, please get back to us with more details. This would help us to provide solution at earliest. 

Regards, 
Durga S. 


Loader.
Up arrow icon