How to correctly highlight nested brackerts?

SyntaxEditor for Windows Forms Forum

Posted 10 years ago by Norbert Jurkiewicz
Version: 12.1.0290
Avatar

I am defining a DyanmicSyntaxLanguage.  I've got the bracket highlightting to work except that nested brackets aren't getting highlighted correctly.  For every opening bracket the first closing bracket gets highlighted.

For example:

((test) asdf )

 

How can I get the parser to match these correctly?

 

<?xml version="1.0"?> <SyntaxLanguages>  <!-- Script Language Definition -->  <SyntaxLanguage Key="Script" LanguageDefinitionVersion="4.0" Secure="False" WordStandaloneCharacters="!&quot;'(),./:;&lt;&gt;?[\]{}←" xmlns="http://ActiproSoftware/SyntaxEditor/4.0/LanguageDefinition">   <!-- String Properties -->   <Properties />   <!-- Triggers -->   <Triggers />   <!-- Highlighting Styles -->   <Styles>    <Style Key="DefaultStyle" Name="Text" ForeColor="#000000" BorderColor="#000000" StrikeOutColor="#000000" UnderlineColor="#000000" />    <Style Key="CommentStyleKey" Name="" ForeColor="#006400" BorderColor="#006400" StrikeOutColor="#006400" UnderlineColor="#006400" />    <Style Key="CommentStyleKeyDefault" Name="" ForeColor="#006400" BorderColor="#006400" StrikeOutColor="#006400" UnderlineColor="#006400" />    <Style Key="StringStyleKey" Name="" ForeColor="#0000FF" BorderColor="#0000FF" StrikeOutColor="#0000FF" UnderlineColor="#0000FF" />    <Style Key="StringStyleKeyDefault" Name="" ForeColor="#0000FF" BorderColor="#0000FF" StrikeOutColor="#0000FF" UnderlineColor="#0000FF" />    <Style Key="BracketStyleKey" Name="" />    <Style Key="BracketStyleKeyDefault" Name="" />    <Style Key="AssignStyleKey" Name="" ForeColor="#FF0000" BorderColor="#FF0000" StrikeOutColor="#FF0000" UnderlineColor="#FF0000" />    <Style Key="AssignStyleKeyDefault" Name="" ForeColor="#FF0000" BorderColor="#FF0000" StrikeOutColor="#FF0000" UnderlineColor="#FF0000" />   </Styles>   <!-- Macros -->   <Macros />   <!-- States -->   <States>    <!-- DefaultState State -->    <State Key="DefaultState" TokenKey="DefaultToken" Style="DefaultStyle">     <!-- Child States -->     <ChildStates>      <ChildState Key="Comment" />      <ChildState Key="String" />      <ChildState Key="Bracket" />     </ChildStates>    </State>    <!-- Comment State -->    <State Key="Comment" TokenKey="CommentDefaultToken" Style="CommentStyleKeyDefault">     <!-- Scopes -->     <Scopes>      <Scope BracketHighlight="True">       <RegexPatternGroup Type="StartScope" TokenKey="Comment" Style="CommentStyleKey" PatternValue="⍝" EndBracket="" />       <RegexPatternGroup Type="EndScope" TokenKey="Comment" Style="CommentStyleKey" PatternValue="{LineTerminatorMacro}" StartBracket="" />      </Scope>     </Scopes>    </State>    <!-- String State -->    <State Key="String" TokenKey="StringDefaultToken" Style="StringStyleKeyDefault">     <!-- Scopes -->     <Scopes>      <Scope BracketHighlight="True">       <ExplicitPatternGroup Type="StartScope" TokenKey="String" Style="StringStyleKey" PatternValue="'" EndBracket="" />       <ExplicitPatternGroup Type="EndScope" TokenKey="String" Style="StringStyleKey" PatternValue="'" StartBracket="" />      </Scope>     </Scopes>    </State>    <!-- Bracket State -->    <State Key="Bracket" TokenKey="BracketDefaultToken" Style="BracketStyleKeyDefault">     <!-- Scopes -->     <Scopes>      <Scope BracketHighlight="True">       <ExplicitPatternGroup Type="StartScope" TokenKey="Bracket" Style="BracketStyleKey" PatternValue="(" EndBracket="" />       <ExplicitPatternGroup Type="EndScope" TokenKey="Bracket" Style="BracketStyleKey" PatternValue=")" StartBracket="" />      </Scope>     </Scopes>    </State>    <!-- Assign State -->    <State Key="Assign" TokenKey="AssignDefaultToken" Style="AssignStyleKeyDefault">     <!-- Scopes -->     <Scopes>      <Scope BracketHighlight="True">       <ExplicitPatternGroup Type="StartScope" TokenKey="Assign" Style="AssignStyleKey" PatternValue="←" EndBracket="" />       <ExplicitPatternGroup Type="EndScope" TokenKey="Assign" Style="AssignStyleKey" PatternValue="←" StartBracket="" />      </Scope>     </Scopes>    </State>   </States>   <!-- Example Text -->   <ExampleText><![CDATA[RS ← RecordSet.New '']]></ExampleText>  </SyntaxLanguage> </SyntaxLanguages> 

[Modified 10 years ago]

Comments (1)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Norbert,

I can't read your language definition since it's all on one line.  But anyhow, please take a look at what we did in the ActiproSoftware.Cpp.xml example.  That supports nesting fine.


Actipro Software Support

The latest build of this product (v23.1.2) 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.