Syntax Highlighting Nested States?

SyntaxEditor for Windows Forms Forum

Posted 20 years ago by Rhywun
Avatar
How do I nest one state in another state? For example,

print "blah blah <<expression>> blah";

I want "<<expression>>" to be a separate state (the StringExpressionState) inside the string state. I can only get it to work inside the DefaultState, not the StringState. Here is what I came up with:

<Styles>
  <Style Key="StringExpressionDelimiterStyle" ForeColor="Blue" BackColor="PaleGoldenrod" Bold="True" Italic="False" Underline="False" />
  <Style Key="StringExpressionDefaultStyle" ForeColor="Blue" BackColor="PaleGoldenrod" Bold="True" Italic="False" Underline="False" />
</Styles>
<States>
  <State Key="StringExpressionState" DefaultToken="StringExpressionDefaultToken" />
</States>
<Tokens>
  <Token Key="StringExpressionStartToken" Style="StringExpressionDelimiterStyle">
    <PushState State="StringExpressionState" />
  </Token>
  <Token Key="StringExpressionDefaultToken" Style="StringExpressionDefaultStyle" />
  <Token Key="StringExpressionEndToken" Style="StringExpressionDelimiterStyle">
    <PopStates>
      <PopState State="StringExpressionState" />
    </PopStates>
  </Token>
</Tokens>
<Regexs>
  <Regex Value="\<\<" Token="StringExpressionStartToken">
    <RegexValidStates>
      <RegexValidState State="StringState" />                <!-- THIS DOESN'T WORK -->
      <RegexValidState State="DefaultState" />               <!-- THIS WORKS -->
    </RegexValidStates>
  </Regex>
  <Regex Value="[^\\(\>\> )]+" Token="StringExpressionDefaultToken">
    <RegexValidStates>
      <RegexValidState State="StringExpressionState" />
    </RegexValidStates>
  </Regex>    
  <Regex Value="\>\>" Token="StringExpressionEndToken">
    <RegexValidStates>
      <RegexValidState State="StringExpressionState" />
    </RegexValidStates>
  </Regex>
</Regexs>
[ 04-15-2004: Message edited by: Rhywun ]

Comments (2)

Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The problem probably is that your string state has a regex in it that has a pattern like "[^\\\"]+" in it. That means that it will only break on \ and " characters. You need to add the < character to that. Then it should stop when < characters are reached, see your new expression, and move on.


Actipro Software Support

Posted 20 years ago by Rhywun
Avatar
Quote:
<font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Actipro Software Support:
The problem probably is that your string state has a regex in it that has a pattern like "[^\\\"]+" in it. That means that it will only break on \ and " characters. You need to add the &lt; character to that. Then it should stop when &lt; characters are reached, see your new expression, and move on.<HR>


I got it to work now - thanks!
The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.