ExplicitPatternGroup and word separation

SyntaxEditor for Windows Forms Forum

Posted 12 years ago by Joachim Schwieren

I use a Dynamic Syntax Language to highlight HTML/XML code. I have defined a special state to highlight color names in tag attributes, e.g. <font color="red" id="myid">. So the word "red" is highlighted in another color than the other attributes like "myid" in this example.

Here is how I defined the color names as an ExplicitPatternGroup:

        <ExplicitPatternGroup TokenKey="ColorNameTokenW3C" TokenID="100">
            aqua black blue fuchsia gray green lime maroon navy olive purple red silver teal white yellow
This works fine so far but if I have the following HTML code in the Syntax Editor:

<object id="SilverlightPlugin1" width="300" height="300"
    type="application/x-silverlight-2" >
The word "Silver" in "SilverlightPlugin1" is also highlighted as color. How can I tell my language definition to only treat this as ColorNameTokenW3C when it is not inside another word?

Thanks for your help!


[Modified at 01/29/2010 04:39 AM]

Comments (1)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Joe,

You should set a LookAhead and maybe also LookBehind attribute on your ExplicitPatternGroup. Both attributes are regex-based so for the LookAhead for example, you could say something like:
LookAhead="{LineTerminatorWhitespaceMacro}* \&quot;"
This says, make sure there is optional whitespace followed by a quote character after the text being scanned. Otherwise, don't match. Similar for LookBehind:
LookAhead="\&quot; {LineTerminatorWhitespaceMacro}*"
Hope that helps.

Actipro Software Support

The latest build of this product (v21.1.0) was released 11 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.