Posted 18 years ago
by Steven Liu
Hi,
I am working with file format like this:I defined a multi-line content divider:
I use (\n[ ]*\n|\n) as PatternValue because I want to include the next blank line(if there is one) in the scope, so IntelliPrompt would work properly in that blank line. It seems to work, except that the content divider is displayed twice. It seems that when EndScope token spans multiple lines, SyntaxEditor draws divider for every line. Is there a way to only draw one divider at the last line of the EndScope token?
For you reference, here's the complete xml:FYI, the complex EndScope LookAhead pattern for SECTION state is look ahead to find the next SECTION keyword, meanwhile ignore multiple blank lines or comment lines in between. In another words, I don't want to include second and further blank lines in the SECTION state, same for comment lines. It works well.
my semantic parser is very simple:Thanks.
Steven
I am working with file format like this:
SECTION Options1
Option1=Val1
Option2=Val2 !comment1
!comment2
SECTION Options2
Option3=Val3
Option4=Val4
<RegexPatternGroup Type="EndScope" TokenKey="SectionEndToken" Style="DefaultStyle" PatternValue="(\n[ ]*\n|\n)" LookAhead="([ ]*(!.*)?\n)*[ ]*(SECTION|\z)" CaseSensitivity="Insensitive" IsContentDivider="True" />
For you reference, here's the complete xml:
<SyntaxLanguage Key="TEST" LanguageDefinitionVersion="3.0" Secure="True" xmlns="http://ActiproSoftware/SyntaxEditor/3.0/LanguageDefinition">
<Styles>
<Style Key="KeywordStyle" 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">
<ChildStates>
<ChildState Key="SectionState" />
<ChildState Key="CommentState" />
</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[ ]*\n|\n)" LookAhead="([ ]*(!.*)?\n)*[ ]*(SECTION|\z)" CaseSensitivity="Insensitive" IsContentDivider="True" />
</Scope>
</Scopes>
<ChildStates>
<ChildState Key="CommentState" />
</ChildStates>
</State>
<State Key="CommentState" TokenKey="CommentDefaultToken" Style="CommentDefaultStyle">
<Scopes>
<Scope>
<ExplicitPatternGroup Type="StartScope" TokenKey="CommentStartToken" Style="CommentDelimiterStyle" PatternValue="!" />
<RegexPatternGroup Type="EndScope" TokenKey="CommentEndToken" Style="CommentDelimiterStyle" PatternValue="." LookAhead ="\n" />
</Scope>
</Scopes>
</State>
</States>
</SyntaxLanguage>
my semantic parser is very simple:
Public Overrides Sub GetTokenOutliningAction(ByVal tokenStream As TokenStream, ByRef outliningKey As String, ByRef tokenAction As OutliningNodeAction)
' Get the token
Dim token As token = tokenStream.Peek()
' generic parser
Dim state As String
If token.Key.EndsWith("StartToken") Then
state = token.Key.Remove(token.Key.Length - 10, 10)
If state <> "String" And state <> "Comment" Then
outliningKey = state & "Block"
tokenAction = OutliningNodeAction.Start
End If
ElseIf token.Key.EndsWith("EndToken") Then
state = token.Key.Remove(token.Key.Length - 8, 8)
If state <> "String" And state <> "Comment" Then
outliningKey = state & "Block"
tokenAction = OutliningNodeAction.End
End If
End If
End Sub
Steven