Bracket Highlighting on scope start tokens

SyntaxEditor for Windows Forms Forum

Posted 12 years ago by Matt Whitfield
Version: 4.0.0252
Avatar
Hello

I am trying to get bracket highlighting for my SQL editor working for both normal braces and [ ] square braces.

The problem that I have is the following:

select * from [dbo].[mytable] - now if i place the cursor before the first, before the third or after the fourth token, it works as expected. However, if i place the cursor after the second bracket then it highlights the second bracket, but not the first as i would expect.

Here are some sections from my syntax language (largely based on the SQL example)

    <!-- States -->
    <States>
        <!-- Code -->
        <State Key="DefaultState">
            <!-- Patterns Groups -->
            <PatternGroups>
                <!-- Whitespace -->
                <RegexPatternGroup TokenKey="WhitespaceToken" PatternValue="{WhitespaceMacro}+" IsWhitespace="True" />
                <!-- Line Terminators -->
                <RegexPatternGroup TokenKey="LineTerminatorToken" PatternValue="{LineTerminatorMacro}" IsWhitespace="True" />
                <!-- Brackets -->
                <ExplicitPatternGroup Key="OpenParenthesisPatternGroup" TokenKey="OpenParenthesisToken" PatternValue="(" EndBracket="CloseParenthesisPatternGroup" />
                <ExplicitPatternGroup Key="CloseParenthesisPatternGroup" TokenKey="CloseParenthesisToken" PatternValue=")" StartBracket="OpenParenthesisPatternGroup" />
                <!-- Square bracket highlighting -->
                <ExplicitPatternGroup Key="OpenSQParenthesisPatternGroup" TokenKey="DefaultToken" PatternValue="[" EndBracket="CloseSQParenthesisPatternGroup" />
                <ExplicitPatternGroup Key="CloseSQParenthesisPatternGroup" TokenKey="DefaultToken" PatternValue="]" StartBracket="OpenSQParenthesisPatternGroup" />

        <!-- Square Identifiers -->
        <State Key="IdentifierState" TokenKey="IdentifierToken">
            <!-- Scopes -->
            <Scopes>
                <Scope>
                    <ExplicitPatternGroup Key="OpenSQParenthesisPatternGroup" Type="StartScope" TokenKey="DefaultToken" PatternValue="[" EndBracket="CloseSQParenthesisPatternGroup" />
                    <ExplicitPatternGroup Key="CloseSQParenthesisPatternGroup" Type="EndScope" TokenKey="DefaultToken" PatternValue="]" StartBracket="OpenSQParenthesisPatternGroup" />    
                </Scope>
            </Scopes>
            <!-- Patterns Groups -->
            <PatternGroups>
                <!-- Square bracket highlighting -->
                <ExplicitPatternGroup Key="OpenSQParenthesisPatternGroup" TokenKey="DefaultToken" PatternValue="[" EndBracket="CloseSQParenthesisPatternGroup" />
                <ExplicitPatternGroup Key="CloseSQParenthesisPatternGroup" TokenKey="DefaultToken" PatternValue="]" StartBracket="OpenSQParenthesisPatternGroup" />

Hope that's enough info! Thanks in advance.

Comments (5)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Matt,

Could you email the complete language file sample to our support address? Thanks!


Actipro Software Support

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Thanks for the sample. The bracket highlighting syntax for pattern groups within scopes is to put a BracketHighlight="True" in the scope and you don't need those Start/EndBracket attributes in pattern groups themselves.

Then also you are matching your end scope pattern in another pattern within the IdentifierState so by doing that you aren't allowing the scope end pattern to be recognized.

If you make those two changes the highlighting works.


Actipro Software Support

Posted 12 years ago by Matt Whitfield
Avatar
Ok I think i got it - certainly the changes i've made seem to have made it work - so thank you!

One other thing - is this stuff documented anywhere? I've read the topic on bracket highlighting a few times, but it just doesn't make much sense to me. Maybe if i knew a lot more about syntactic and lexical parsing then i'd probably know what the topic was talking about, but the only bit I can see that references how to do the XML syntax is the following sentence:

'Bracket highlighting can be defined in dynamic languages within the language XML definitions. This is done in the pattern group tags.'

Which doesn't exactly tell you what you have to do!! So it's helpful that you've said 'you need an element in the scope tag' which points me to the right section of the documentation in order to find out what i need - but ideally i wouldn't have to bug you about it!

Thanks very much again.
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Thanks Matt,

It should read this instead:
Quote:
Bracket highlighting can be defined in dynamic languages within the language XML definitions. This is done in the Scope tag for scope pattern groups and in the pattern group tags for non-scope pattern groups. See the Dynamic Language XML Definition Specification topics for scope and pattern group tags for details.


Actipro Software Support

Posted 12 years ago by Matt Whitfield
Avatar
Yep I think that would have given me the pointers i'd needed.

But hey, you can't be brilliant at component design *and* documentation - that just wouldn't be fair!

Thanks for the top notch support, as ever.
The latest build of this product (v2018.1 build 0341) was released 9 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.