Unable to load xml file

SyntaxEditor for Windows Forms Forum

Posted 18 years ago by Steven Liu
Avatar
I am trying to define a simple language that only contains #IF and #ENDIF pre-processor directives, nothing else. the xml file is:

<SyntaxLanguage Key="TEST" LanguageDefinitionVersion="3.0" Secure="True" xmlns="http://ActiproSoftware/SyntaxEditor/3.0/LanguageDefinition">

    <Styles>
        <Style Key="IfWordStyle" ForeColor="Blue" BackColor="Default" Bold="False" Italic="False" Underline="False" />
    </Styles>
 
    <States> 
        <State Key="DefaultState">
            <ChildStates>
                <ChildState Key="IfState" />
                <ChildState Key="EndIfState" />
            </ChildStates>
        </State>
        <State Key="IfState">
            <Scopes>
                <Scope>
                    <ExplicitPatternGroup Type="StartScope" TokenKey="IfStartToken" Style="IfWordStyle" PatternValue="#IF" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect" />
                    <RegexPatternGroup Type="EndScope" TokenKey="IfStartToken2" Style="DefaultStyle" PatternValue="\n" CaseSensitivity="Insensitive" />
                </Scope>
            </Scopes>
        </State> 
        <State Key="EndIfState">
            <Scopes>
                <Scope>
                    <ExplicitPatternGroup Type="StartScope" TokenKey="IfEndToken" Style="IfWordStyle" PatternValue="#" LookAhead="ENDIF{NonWordMacro}" CaseSensitivity="AutoCorrect" />
                    <RegexPatternGroup Type="EndScope" TokenKey="IfEndToken2" Style="IfWordStyle" PatternValue="ENDIF" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect" />
                </Scope>
            </Scopes>
        </State> 
    </States> 
</SyntaxLanguage>
FYI, I define EndIfState in a way that will not consume \n char.

SyntaxEditor cannot load that file. As I was trying to narrow down to the cause, I found that it will load if I make 2 undesirable changes to EndIfSate:
1. Change LookAhead="ENDIF{NonWordMacro}" to LookAhead="ENDIF"
2. Change EndScope's CaseSensitivity="AutoCorrect" to CaseSensitivity="Insensitive"

the modifed EndIfState is:

        <State Key="EndIfState">
            <Scopes>
                <Scope>
                    <ExplicitPatternGroup Type="StartScope" TokenKey="IfEndToken" Style="IfWordStyle" PatternValue="#" LookAhead="ENDIF" CaseSensitivity="AutoCorrect" />
                    <RegexPatternGroup Type="EndScope" TokenKey="IfEndToken2" Style="IfWordStyle" PatternValue="ENDIF" LookAhead="{NonWordMacro}" CaseSensitivity="Insensitive" />
                </Scope>
            </Scopes>
        </State> 
Would you shed some light on this? Thanks.

Steven

Comments (2)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You have a couple problems here. You need to add a space before the {NonWordMacro} in the LookAhead so that the pattern parser knows you are referencing a macro.

Second, Regex patterns don't support AutoCorrect features. The Output window in VS tells you this when you try to load the language. Not sure if you noticed that:

AN EXCEPTION OCCURRED WHILE LOADING A LANGUAGE DEFINITION:
An error occurred while loading the DynamicSyntaxLanguage 'TEST':
A CaseSensitivity setting of 'AutoCorrect' is not permitted on regex lexical pattern groups.
The problem occurred near line 26, position 22


Actipro Software Support

Posted 18 years ago by Steven Liu
Avatar
Thanks. Inserted a space before macro reference, and changed RegexPatternGroup to ExplicitPatternGroup. Works like a charm.
Steven
The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.