Posted 20 years ago
by Steven Liu
Trying to create syntax definition file for this:
I created 2 states: SectionState and CommentState.
Since SectionState has no closing keyword, it needs to look ahead to the next SECTION keyword to terminate current scope:
PatternValue="\n" LookAhead="[ \n]*SECTION"
There's still a problem: the "!comment" line consumes "\n", so "SECTION s2" is not recognized. To fix this, I changed the EndScope pattern of CommentState from "\n" to "$", so the "\n" is left over to end the SECTION scope.
(Complete syntax definition is attached at the end).
This solution appears OK, but I encountered a NullReferenceException when I do this:
position cursor at the end of "!comment" line, press backspace key 3 times to delete character "t", "n", "e", then re-type "e","n","t".
Would you please take a look? Thanks a lot.
Steven Liu
SECTION s1
a=1
!comment
SECTION s2
b=1
Since SectionState has no closing keyword, it needs to look ahead to the next SECTION keyword to terminate current scope:
PatternValue="\n" LookAhead="[ \n]*SECTION"
There's still a problem: the "!comment" line consumes "\n", so "SECTION s2" is not recognized. To fix this, I changed the EndScope pattern of CommentState from "\n" to "$", so the "\n" is left over to end the SECTION scope.
(Complete syntax definition is attached at the end).
This solution appears OK, but I encountered a NullReferenceException when I do this:
position cursor at the end of "!comment" line, press backspace key 3 times to delete character "t", "n", "e", then re-type "e","n","t".
Would you please take a look? Thanks a lot.
Steven Liu
<SyntaxLanguage Key="TEST" LanguageDefinitionVersion="2.0" Secure="True" xmlns="http://ActiproSoftware/SyntaxEditor/2.0/LanguageDefinition">
<!-- Highlighting Styles -->
<Styles>
<Style Key="SectionWordStyle" ForeColor="Blue" BackColor="Default" Bold="False" Italic="False" Underline="False" />
<Style Key="CommentDelimiterStyle" ForeColor="Green" BackColor="Default" Bold="False" Italic="False" Underline="False" />
<Style Key="CommentDefaultStyle" ForeColor="Green" BackColor="Default" Bold="False" Italic="False" Underline="False" />
</Styles>
<!-- States -->
<States>
<!-- Code -->
<State Key="DefaultState">
<!-- Child States -->
<ChildStates>
<ChildState Key="SectionState" />
<ChildState Key="CommentState" />
</ChildStates>
</State>
<State Key="SectionState" >
<!-- Scopes -->
<Scopes>
<Scope>
<ExplicitPatternGroup Type="StartScope" Token="SectionStartToken" Style="SectionWordStyle" PatternValue="SECTION" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect" />
<RegexPatternGroup Type="EndScope" Token="SectionEndToken" Style="DefaultStyle" PatternValue="\n" LookAhead="[ \n]*SECTION" CaseSensitivity="Insensitive" IsContentDivider="True" />
</Scope>
</Scopes>
<ChildStates>
<ChildState Key="CommentState" />
</ChildStates>
</State>
<State Key="CommentState" Token="CommentDefaultToken" Style="CommentDefaultStyle">
<!-- Scopes -->
<Scopes>
<Scope>
<ExplicitPatternGroup Type="StartScope" Token="CommentStartToken" Style="CommentDelimiterStyle" PatternValue="!" />
<RegexPatternGroup Type="EndScope" Token="CommentEndToken" Style="CommentDelimiterStyle" PatternValue="$" />
</Scope>
</Scopes>
</State>
</States>
</SyntaxLanguage>