Posted 18 years ago
by Steven Liu
Hi,
I am scratching my head for this one. I am trying to define a language like this:comments and #IF/#ENDIF are allowed, but not shown in the sample text for simplicity. My xml is:
However when I load the files, only the first "section" is upcased and highlighted. strange.
One of these two undesirable changes will make it work:
1. change all "section" keywrods to upcase, or
2. In SectionState SectionEndToken definition, change LookAhead pattern from "{EndGroupLookAheadMacro}" to the original regex "([ ]*((#IF|!).*)?\n)*[ ]*(SECTION|\z)"
Please help. Thanks.
Steven
[Modified at 08/25/2006 11:01 AM]
I am scratching my head for this one. I am trying to define a language like this:
section Options1
Option1=Val1
Option2=Val2
section Options2
Option1=Val1
Option2=Val2
section Options3
Option1=Val1
Option2=Val2
<SyntaxLanguage Key="TEST" LanguageDefinitionVersion="3.0" Secure="True" xmlns="http://ActiproSoftware/SyntaxEditor/3.0/LanguageDefinition">
<!-- Macros -->
<Macros>
<Macro Key="CommentLineMacro" Value="!.*" />
<Macro Key="EndGroupMacro" Value="\n" />
<Macro Key="EndGroupLookAheadMacro" Value="([ ]*((#IF|!).*)?\n)*[ ]*(SECTION|\z)" />
</Macros>
<Styles>
<Style Key="KeywordStyle" ForeColor="Blue" BackColor="Default" Bold="False" Italic="False" Underline="False" />
<Style Key="IfWordStyle" 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>
<State Key="DefaultState">
<PatternGroups>
<ExplicitPatternGroup TokenKey="IfStartToken" Style="IfWordStyle" PatternValue="#IF" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect" />
<ExplicitPatternGroup TokenKey="IfEndToken" Style="IfWordStyle" PatternValue="#ENDIF" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect" />
<RegexPatternGroup TokenKey="CommentLineToken" Style="CommentDefaultStyle" PatternValue="!.*" LookAhead="\n" CaseSensitivity="Insensitive" />
</PatternGroups>
<ChildStates>
<ChildState Key="SectionState" />
</ChildStates>
</State>
<State Key="SectionState">
<Scopes>
<Scope>
<ExplicitPatternGroup Type="StartScope" TokenKey="SectionStartToken" Style="KeywordStyle" PatternValue="SECTION" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect" />
<RegexPatternGroup Type="EndScope" TokenKey="SectionEndToken" Style="DefaultStyle" PatternValue="\n" LookAhead="{EndGroupLookAheadMacro}" CaseSensitivity="Insensitive" IsContentDivider="True" />
</Scope>
</Scopes>
<PatternGroups>
<ExplicitPatternGroup TokenKey="IfStartToken" Style="IfWordStyle" PatternValue="#IF" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect" />
<ExplicitPatternGroup TokenKey="IfEndToken" Style="IfWordStyle" PatternValue="#ENDIF" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect" />
<RegexPatternGroup TokenKey="CommentLineToken" Style="CommentDefaultStyle" PatternValue="!.*" LookAhead="\n" CaseSensitivity="Insensitive" />
</PatternGroups>
</State>
</States>
</SyntaxLanguage>
One of these two undesirable changes will make it work:
1. change all "section" keywrods to upcase, or
2. In SectionState SectionEndToken definition, change LookAhead pattern from "{EndGroupLookAheadMacro}" to the original regex "([ ]*((#IF|!).*)?\n)*[ ]*(SECTION|\z)"
Please help. Thanks.
Steven
[Modified at 08/25/2006 11:01 AM]