Macro case sensitivity problem

SyntaxEditor for Windows Forms Forum

Posted 18 years ago by Steven Liu
Avatar
Hi,

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

comments and #IF/#ENDIF are allowed, but not shown in the sample text for simplicity. My xml is:

<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>
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]

Comments (5)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The problem in this case seems to be that macros are case sensitive.
And when you use them in an insensitive lexical pattern group, the macro
part has already been compiled as case sensitive and is merged in as such.

I suppose we could do one of two things... add a CaseSensitivity on the Macro tag.
Or keep the macro "generic" and then based on whether it is merged into a case
sensitive pattern group or not, change its sensitivity.

What is everyone's opinions?


Actipro Software Support

Posted 18 years ago by Steven Liu
Avatar
I like the idea that a macro follows the case sensitivity of the pattern group where it is used. This way users don't have to remember which case sensitivity has precedence, and there is one less keyword to deal with.
Thanks.
Steven
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I like that option best too.


Actipro Software Support

Posted 18 years ago by Steven Liu
Avatar
Hi,
Do you plan to have more 3.x maintance release before 4.0 release?
Steven
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes there will probably be one or more maintenance releases for 3.1 in the future. However any major new features will be put in 4.0 from now on.


Actipro Software Support

The latest build of this product (v24.1.1) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.