Posted 17 years ago
by Joris Koster
-
Paragon Decision Technology
Version: 3.1.0222
Platform: .NET 2.0
Environment: Windows XP (32-bit)
Recently we made some minor changes to our language definition, but we found it had some unforeseen consequences. We changed something to the scope definition, that fixed one of our own issues. The steps to reproduce the crash is below. We've tried to isolate the problem in the smallest language def possible.
1) Open the C# Sample Editor application
2) Load the following custom language:3) Insert an exclamation mark ('!') in front of the 'if' token
4) Move the caret in front of the 'endif' token
5) Insert another exclamation mark ('!')
As you can see, the idea is to comment out the if condition on the code block. We found that changing the code block to 'Func1(Func2())' does not cause any problem.
Joris
1) Open the C# Sample Editor application
2) Load the following custom language:
<SyntaxLanguage Key="MyLanguage" LanguageDefinitionVersion="3.0" Secure="False" xmlns="http://ActiproSoftware/SyntaxEditor/3.0/LanguageDefinition" >
<!-- Macros -->
<Macros>
<Macro Key="IdentifierMacro" Value="({AlphaMacro}|\_)({WordMacro})*" />
</Macros>
<!-- Highlighting Styles -->
<Styles>
<Style Key="ReservedWordStyle" Name="Keyword" ForeColor="Blue" BackColor="Default" Bold="False" Italic="False" Underline="False" />
<Style Key="StringStyle" Name="String" ForeColor="Gray" BackColor="Default" Bold="False" Italic="True" Underline="False" />
<Style Key="CommentStyle" Name="Comment" ForeColor="Green" BackColor="Default" Bold="False" Italic="True" Underline="False" />
<Style Key="PunctuatorStyle" Name="Punctuator" ForeColor="Black" BackColor="Default" Bold="False" Italic="False" Underline="False" />
<Style Key="IdentifierStyle" Name="Identifier" ForeColor="Black" BackColor="Default" Bold="False" Italic="False" Underline="False" />
</Styles>
<!-- States -->
<States>
<!-- Code -->
<State Key="DefaultState">
<Scopes>
<Scope BracketHighlight="True">
<ExplicitPatternGroup Type="StartScope" TokenKey="BracketStartToken" TokenID="22" Style="PunctuatorStyle" PatternValue="(" />
<ExplicitPatternGroup Type="EndScope" TokenKey="BracketEndToken" TokenID="23" Style="PunctuatorStyle" PatternValue=")" />
</Scope>
<Scope>
<ExplicitPatternGroup Type="StartScope" TokenKey="IfStartToken" TokenID="12" Style="ReservedWordStyle" PatternValue="if" LookAhead="{NonWordMacro}" />
<RegexPatternGroup Type="EndScope" TokenKey="EndIfStartToken" TokenID="13" Style="ReservedWordStyle" PatternValue="endif" IsWhitespace="True" />
</Scope>
</Scopes>
<!-- Patterns Groups -->
<PatternGroups>
<!-- Identifiers -->
<RegexPatternGroup TokenKey="IdentifierToken" TokenID="36" Style="IdentifierStyle" PatternValue="(?!(endif)\b)({IdentifierMacro})" />
<!-- Whitespace -->
<RegexPatternGroup TokenKey="DefaultToken" TokenID="0" PatternValue="({LineTerminatorWhitespaceMacro})+" IsWhitespace="True" />
</PatternGroups>
<!-- Child States -->
<ChildStates>
<ChildState Key="DefaultState" />
<ChildState Key="StringState" />
<ChildState Key="SingleLineCommentState" />
</ChildStates>
</State>
<!-- Strings -->
<State Key="StringState" ID="4" TokenKey="StringDefaultToken" TokenID="25" Style="StringStyle">
<!-- Scopes -->
<Scopes>
<Scope>
<ExplicitPatternGroup Type="StartScope" TokenKey="StringStartToken" TokenID="24" PatternValue=""" />
<RegexPatternGroup Type="EndScope" TokenKey="StringEndToken" TokenID="26" PatternValue="[\"\n]" />
</Scope>
</Scopes>
</State>
<!-- Comments -->
<State Key="SingleLineCommentState" ID="6" TokenKey="CommentDefaultToken" TokenID="39" Style="CommentStyle">
<!-- Scopes -->
<Scopes>
<Scope>
<ExplicitPatternGroup Type="StartScope" TokenKey="CommentStartToken" TokenID="38" PatternValue="!" />
<RegexPatternGroup Type="EndScope" TokenKey="CommentEndToken" TokenID="41" PatternValue="{LineTerminatorMacro}" IsWhitespace="True" />
</Scope>
</Scopes>
</State>
</States>
<!-- Example Text -->
<ExampleText>
<![CDATA[
if 1
Func1(Func2(""));
endif;
]]>
</ExampleText>
</SyntaxLanguage>
4) Move the caret in front of the 'endif' token
5) Insert another exclamation mark ('!')
As you can see, the idea is to comment out the if condition on the code block. We found that changing the code block to 'Func1(Func2())' does not cause any problem.
Joris