Trouble Creating Language Definition File

SyntaxEditor for Windows Forms Forum

Posted 19 years ago by Filipe Batista - Software/Hardware Developer, Cristaltec spa
Avatar
I'm having trouble getting my script language to fold correctly.

The problem is to get my structure :


MENU name

OBJECT name

code

END

END

to fold using the same EndScope Key.

I'ld appreciate if you could help me.

filipebatista@vodafone.pt

Comments (16)

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Could you email us a simple example of the language def and semantic parser you're using to do this?


Actipro Software Support

Posted 19 years ago by Filipe Batista - Software/Hardware Developer, Cristaltec spa
Avatar

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

    <!-- String Properties -->
    <Properties>
        <Property Key="Creator" Value="Actipro Software LLC" />
        <Property Key="Copyright" Value="Copyright (c) 2001-2005 Actipro Software LLC.  All rights reserved." />
    </Properties>

    <!-- Triggers -->
    <Triggers>
        <KeyPressTrigger Key="MemberListTrigger" Character=".">
            <KeyPressTriggerValidStates>
                <KeyPressTriggerValidState State="DefaultState" />
            </KeyPressTriggerValidStates>
        </KeyPressTrigger>
    </Triggers>

    <!-- Highlighting Styles -->    
    <Styles>
        <Style Key="CollapsibleTextStyle" Name="Collapsible Text" ForeColor="Gray" BackColor="Default" Bold="False" Italic="False" Underline="False" />
        <Style Key="ReservedWordStyle" ForeColor="Blue" BackColor="Default" Bold="False" Italic="False" Underline="False" />
        <Style Key="NativeTypeStyle" ForeColor="Blue" BackColor="Default" Bold="False" Italic="False" Underline="False" />
        <Style Key="OperatorStyle" ForeColor="Black" BackColor="Default" Bold="False" Italic="False" Underline="False" />
        <Style Key="ReservedWordOperatorStyle" ForeColor="Blue" BackColor="Default" Bold="False" Italic="False" Underline="False" />
        <Style Key="NumberStyle" ForeColor="Black" BackColor="Default" Bold="False" Italic="False" Underline="False" />
        <Style Key="StringDelimiterStyle" ForeColor="Black" BackColor="Default" Bold="False" Italic="False" Underline="False" />
        <Style Key="StringDefaultStyle" ForeColor="Black" 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" />
        <Style Key="PreProcessorDirectiveKeywordStyle" Name="Pre-Processor Directive Keyword" ForeColor="Blue" BackColor="Default" Bold="False" Italic="False" Underline="False" />
        <Style Key="PreProcessorDirectiveDefaultStyle" Name="Pre-Processor Directive Default" ForeColor="Black" BackColor="Default" Bold="False" Italic="False" Underline="False" />
    </Styles>
    
    <!-- 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" />
                <!-- Exit Reserved Words -->
                <ExplicitPatternGroup TokenKey="StopReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="STOP" />
                </ExplicitPatternGroup>
                <!-- Foldable Start Reserved Words -->
                <ExplicitPatternGroup TokenKey="MenuReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="MENU" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="ObjectReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="OBJECT" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnBut1ReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONBUT1" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnBut2ReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONBUT2" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnBut3ReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONBUT3" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnBut4ReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONBUT4" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnBut5ReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONBUT5" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnBut6ReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONBUT6" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnBut7ReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONBUT7" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnBut8ReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONBUT8" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnBut9ReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONBUT7" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnBut9ReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONBUT7" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnBut0ReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONBUT0" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnUpReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONUP" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnDownReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONDOWN" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnLeftReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONLEFT" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnRightReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONRIGHT" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnTickReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONTICK" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnMenuEnterReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONMENUENTER" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnMenuVisibleReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONMENUVISIBLE" />
                </ExplicitPatternGroup>            
                <ExplicitPatternGroup TokenKey="OnMenuExitReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONMENUEXIT" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnProcessReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONPROCESS" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnKeyboardReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONKEYBOARD" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnCommReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONCOMM" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnCommRawReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONCOMMRAW" />
                </ExplicitPatternGroup>
                <ExplicitPatternGroup TokenKey="OnCollisionReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="ONCOLLISION" />
                </ExplicitPatternGroup>






                <!-- Foldable End Reserved Words -->
                <ExplicitPatternGroup TokenKey="EndReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPattern Value="END" />
                </ExplicitPatternGroup>

                <!-- Punctuation -->
                <ExplicitPatternGroup TokenKey="PunctuationToken">
                    <ExplicitPatterns>
                        . ,
                    </ExplicitPatterns>
                </ExplicitPatternGroup>
                <!-- Native Types -->
                <ExplicitPatternGroup TokenKey="NativeTypeToken" Style="NativeTypeStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPatterns>
                        INT REAL STRING
                    </ExplicitPatterns>
                </ExplicitPatternGroup>
                <!-- Reserved Word Operators -->
                <ExplicitPatternGroup TokenKey="ReservedWordOperatorToken" Style="ReservedWordOperatorStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPatterns>
                        AND OR
                    </ExplicitPatterns>
                </ExplicitPatternGroup>
                <!-- Reserved Words -->
                <ExplicitPatternGroup TokenKey="ReservedWordToken" Style="ReservedWordStyle" LookBehind="[^\.]" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect">
                    <ExplicitPatterns>
                        SET
                    </ExplicitPatterns>
                </ExplicitPatternGroup>
                <!-- Identifier -->
                <RegexPatternGroup TokenKey="IdentifierToken" PatternValue="(_ | {AlphaMacro})({WordMacro})*" />
                <!-- Operators -->
                <ExplicitPatternGroup TokenKey="OperatorToken" Style="OperatorStyle">
                    <ExplicitPatterns>
                        = &lt;&gt; 
                        += -= *= /= \= ^= &amp;=
                        + - * / \ ^ &amp; 
                        &lt;= &lt; &gt;= &gt; 
                    </ExplicitPatterns>
                </ExplicitPatternGroup>
                <!-- Numbers -->
                <RegexPatternGroup TokenKey="RealNumberToken" Style="NumberStyle" LookAhead="{NonWordMacro}">
                    <RegexPattern Value="{DigitMacro}* \. {DigitMacro}+ ([Ee] [\+\-]? {DigitMacro}+)?" />
                    <RegexPattern Value="{DigitMacro}+ [Ee] [\+\-]? {DigitMacro}+" />
                </RegexPatternGroup>
                <RegexPatternGroup TokenKey="IntegerNumberToken" Style="NumberStyle" PatternValue="{DigitMacro}+" LookAhead="{NonWordMacro}" />
                <RegexPatternGroup TokenKey="HexIntegerNumberToken" Style="NumberStyle" PatternValue="&amp; [hH] {HexDigitMacro}+" LookAhead="{NonWordMacro}" />
            </PatternGroups>
            <!-- Child States -->
            <ChildStates>
                <ChildState Key="StringState" />
                <ChildState Key="CommentState" />
                <ChildState Key="PreProcessorDirectiveState" />
            </ChildStates>
        </State>
        
        <!-- Strings -->
        <State Key="StringState" TokenKey="StringDefaultToken" Style="StringDefaultStyle">
            <!-- Scopes -->
            <Scopes>
                <Scope>
                    <ExplicitPatternGroup Type="StartScope" TokenKey="StringStartToken" Style="StringDelimiterStyle" PatternValue="&quot;" />
                    <RegexPatternGroup Type="EndScope" TokenKey="StringEndToken" Style="StringDelimiterStyle" PatternValue="[\&quot;\n]" />    
                </Scope>
            </Scopes>
            <!-- Patterns Groups -->
            <PatternGroups>
                <ExplicitPatternGroup TokenKey="StringEscapedCharacterToken" PatternValue="&quot;&quot;" />
                <RegexPatternGroup TokenKey="StringDefaultToken2" PatternValue="[^\&quot;\n]+" />
            </PatternGroups>
        </State>
        
        <!-- Comments -->
        <State Key="CommentState" TokenKey="CommentDefaultToken" Style="CommentDefaultStyle">
            <!-- Scopes -->
            <Scopes>
                <Scope>
                    <ExplicitPatternGroup Type="StartScope" TokenKey="CommentStartToken" Style="CommentDelimiterStyle" PatternValue="'" />
                    <RegexPatternGroup Type="EndScope" TokenKey="CommentEndToken" Style="CommentDelimiterStyle" PatternValue="{LineTerminatorMacro}" IsWhitespace="True" />    
                </Scope>
                <Scope>
                    <ExplicitPatternGroup Type="StartScope" TokenKey="CommentStartToken" Style="CommentDelimiterStyle" PatternValue="REM" LookBehind="[^\.]" LookAhead="{NonWordMacro}" />
                    <RegexPatternGroup Type="EndScope" TokenKey="CommentEndToken" Style="CommentDelimiterStyle" PatternValue="{LineTerminatorMacro}" IsWhitespace="True" />    
                </Scope>
            </Scopes>
            <!-- Patterns Groups -->
            <PatternGroups>
                <RegexPatternGroup TokenKey="CommentDefaultToken" PatternValue="{NonLineTerminatorMacro}+" />
            </PatternGroups>
        </State>

        <!-- Pre-Processor Directives -->
        <State Key="PreProcessorDirectiveState" TokenKey="PreProcessorDirectiveDefaultToken" Style="PreProcessorDirectiveDefaultStyle">
            <!-- Scopes -->
            <Scopes>
                <Scope>
                    <ExplicitPatternGroup Type="StartScope" TokenKey="RegionPreProcessorDirectiveStartToken" Style="PreProcessorDirectiveKeywordStyle" PatternValue="#Region" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect" />
                    <RegexPatternGroup Type="EndScope" TokenKey="PreProcessorDirectiveEndToken" Style="DefaultStyle" PatternValue="{LineTerminatorMacro}" IsWhitespace="True" />    
                </Scope>
                <Scope>
                    <ExplicitPatternGroup Type="StartScope" TokenKey="EndRegionPreProcessorDirectiveStartToken" Style="PreProcessorDirectiveKeywordStyle" PatternValue="#End Region" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect" />
                    <RegexPatternGroup Type="EndScope" TokenKey="PreProcessorDirectiveEndToken" Style="DefaultStyle" PatternValue="{LineTerminatorMacro}" IsWhitespace="True" />    
                </Scope>
            </Scopes>
            <!-- Patterns Groups -->
            <PatternGroups>
                <RegexPatternGroup TokenKey="PreProcessorDirectiveDefaultToken" PatternValue="{NonLineTerminatorMacro}+" />
            </PatternGroups>
        </State>
    </States>

    <!-- Example Text -->
    <ExampleText>
        <![CDATA[
INT DEMOSOUNDFLAG
INT SHOWMODEFLAG
INT FACTORYDEFAULTSFLAG
INT MASTERAUDIOLEVEL


MENU General


    OBJECT TEXT DUMMY

        ONBUT1

            IF CURSOR=1
                IF MASTERAUDIOLEVEL > 0
                    SUB MASTERAUDIOLEVEL, 1
                    SETVOLUME MASTERAUDIOLEVEL
                    PLAYSFX "SOUNDS\STAY.WAV", 0
                ENDIF
            ELSEIF CURSOR=2
                SET DEMOSOUNDFLAG, 0
            ELSEIF CURSOR=3
                SET SHOWMODEFLAG, 0
            ELSEIF CURSOR=4
                IF FACTORYDEFAULTSFLAG = 1
                    //////////////////////
                    // LOAD DEFAULTS FACTORY VALUES
                    /////////////////////
                ENDIF
            ELSEIF CURSOR=5
                GOTOMENU Tech    
            ENDIF
        END


        ONBUT2
            IF CURSOR=1
                IF MASTERAUDIOLEVEL < 10
                    ADD MASTERAUDIOLEVEL, 1
                    SETVOLUME MASTERAUDIOLEVEL
                    PLAYSFX "SOUNDS\STAY.WAV", 0
                ENDIF
            ELSEIF CURSOR=2
                SET DEMOSOUNDFLAG, 1
            ELSEIF CURSOR=3
                SET SHOWMODEFLAG, 1
            ENDIF
        END


        ONBUT3


        END

        ONBUT4
        END

        ONBUT5
        END

        
        ONUP
            IF CURSOR > 1
                SUB CURSOR, 1
            ENDIF

        END

        ONDOWN
            IF CURSOR < 5
                ADD CURSOR, 1
            ENDIF
        END

    END


    OBJECT IMAGE, title
        IMAGE        "General"
        COLOR        255, 255, 255, 255
        POSWH        150, 25, 512, 64
        TEXCOORDS    0, 0, 512, 64
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END




    OBJECT  TEXT, AudioVolume
        POSITION    100,110,0,0
        COLOR        255, 200, 60, 255
        FONT        "techfontsmall",0
        TEXT         ""    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END


    OBJECT  TEXT, DemoSound
        POSITION    100,140,0,0
        COLOR        255, 200, 60, 255
        FONT        "techfontsmall",0
        TEXT         ""    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END



    OBJECT  TEXT, ShowMode
        POSITION    100,170,0,0
        COLOR        255, 200, 60, 255
        FONT        "techfontsmall",0
        TEXT         ""    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END



    OBJECT  TEXT, FactoryDefaults
        POSITION    100,200,0,0
        COLOR        255, 200, 60, 255
        FONT        "techfontsmall",0
        TEXT         ""    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END


    OBJECT  TEXT, AamsComms
        POSITION    180,290,0,0
        COLOR        255, 255, 255, 255
        FONT        "tech",0
        TEXT         ""    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END


    OBJECT  TEXT, Rx
        POSITION    90,340,0,0
        COLOR        255, 255, 255, 255
        FONT        "tech",0
        TEXT         "RX"    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END

    OBJECT  TEXT, Tx
        POSITION    90,465,0,0
        COLOR        255, 255, 255, 255
        FONT        "tech",0
        TEXT         "TX"    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END


    OBJECT FRAME, RXframe
        COLOR                128, 128, 128, 255
        POSWH                150, 320, 500, 105
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END

    OBJECT FRAME, TXframe
        COLOR                128, 128, 128, 255
        POSWH                150, 450, 500, 105
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END


    OBJECT RECT, RXBackground
        COLOR                0, 0, 128, 128
        POSWH                152, 322, 496, 101
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END

    OBJECT RECT, TXBackground
        COLOR                0, 0, 128, 128
        POSWH                152, 452, 496, 101
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END


////////////////// RX LINES


    OBJECT  TEXT, RxLine1
        POSITION    157,322,0,0
        COLOR        255, 255, 255, 255
        FONT        "techfontsmall",0
        TEXT         "LINE1"    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END

    OBJECT  TEXT, RxLine2
        POSITION    157,341,0,0
        COLOR        255, 255, 255, 255
        FONT        "techfontsmall",0
        TEXT         "LINE2"    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END

    OBJECT  TEXT, RxLine3
        POSITION    157,361,0,0
        COLOR        255, 255, 255, 255
        FONT        "techfontsmall",0
        TEXT         "LINE3"    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END

    OBJECT  TEXT, RxLine4
        POSITION    157,381,0,0
        COLOR        255, 255, 255, 255
        FONT        "techfontsmall",0
        TEXT         "LINE4"    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END

    OBJECT  TEXT, RxLine5
        POSITION    157,401,0,0
        COLOR        255, 255, 255, 255
        FONT        "techfontsmall",0
        TEXT         "LINE5"    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END


////////////////// TX LINES


    OBJECT  TEXT, TxLine1
        POSITION    157,452,0,0
        COLOR        255, 255, 255, 255
        FONT        "techfontsmall",0
        TEXT         "LINE1"    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END

    OBJECT  TEXT, TxLine2
        POSITION    157,471,0,0
        COLOR        255, 255, 255, 255
        FONT        "techfontsmall",0
        TEXT         "LINE2"    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END

    OBJECT  TEXT, TxLine3
        POSITION    157,491,0,0
        COLOR        255, 255, 255, 255
        FONT        "techfontsmall",0
        TEXT         "LINE3"    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END

    OBJECT  TEXT, TxLine4
        POSITION    157,511,0,0
        COLOR        255, 255, 255, 255
        FONT        "techfontsmall",0
        TEXT         "LINE4"    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END

    OBJECT  TEXT, TxLine5
        POSITION    157,531,0,0
        COLOR        255, 255, 255, 255
        FONT        "techfontsmall",0
        TEXT         "LINE5"    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END

///////////////////////


    OBJECT  TEXT, CounterAudio
        POSITION    500,110,500,0
        COLOR        255, 200, 60, 255
        FONT        "techfontsmall",2
        TEXT         "0"    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END


    OBJECT  TEXT, CounterDemo
        POSITION    490,140,0,0
        COLOR        255, 200, 60, 255
        FONT        "techfontsmall",0
        TEXT         ""    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END


    OBJECT  TEXT, CounterShow
        POSITION    490,170,0,0
        COLOR        255, 200, 60, 255
        FONT        "techfontsmall",0
        TEXT         ""    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END


    OBJECT  TEXT, CounterFactory
        POSITION    490,200,0,0
        COLOR        255, 200, 60, 255
        FONT        "techfontsmall",0
        TEXT         ""    
        EFFECTON    FADEIN, 1, 3
        EFFECTOFF    FADEOUT, 1, 3
    END





    OBJECT  TEXT, Back
        POSITION    100,230,0,0
        COLOR        255, 200, 60, 255
        FONT        "tech",0
        TEXT         "&"    
        EFFECTON    SLIDELEFT, 1, 3
        EFFECTOFF    SLIDERIGHTUP, 1, 3
    END







    OBJECT  TIMER, TimerCursor
        TIMERPERIOD 50
            ONTICK

                IF VARYPOSITION < -2
                    SET POSFLAG, 1
                    SET VARYPOSITION, -2
                ENDIF
        
        
                IF VARYPOSITION > 2
                    SET POSFLAG, 0
                    SET VARYPOSITION, 2
                ENDIF


                IF POSFLAG = 1
                    ADD VARYPOSITION, 1
                ELSE
                    SUB VARYPOSITION, 1
                ENDIF    
            END
    END

    


    
 ///////////////////////////////////////////////////////////////////


        
    ONMENUENTER
    


        ACTIVATE Dummy

        SETBACKDROPCOMPONENT TECHBACKDROP
        
        SET CURSOR, 5

        SETDEBUGWATCHCONSOLEFONT "Debug"
        SETDEBUGWATCHCONSOLECOLOUR 255, 255, 255, 255



        

    END


    ONMENUEXIT
        SET CURSOR, 7
    END



    ONKEYBOARD

    
    END


    



    

    ONPROCESS

        ADDDEBUGWATCH cursor
        ADDDEBUGWATCH varyposition


        
        SWITCH LANGUAGE
            CASE 0
                SETTEXT AudioVolume, "AUDIO VOLUME LEVEL ............................"
                SETTEXT DemoSound,"DEMO SOUND ............................................."
                SETTEXT ShowMode,    "SHOW MODE ..............................................."
                SETTEXT FactoryDefaults,"FACTORY DEFAULTS ..............................."
                SETTEXT AamsComms,"AAMS COMMUNICATIONS"
                IF DemoSoundFlag=0
                    SETTEXT CounterDemo,"OFF"
                ELSE
                    SETTEXT CounterDemo,"ON"
                ENDIF

                IF ShowModeFlag=0
                    SETTEXT CounterShow,"OFF"
                ELSE
                    SETTEXT CounterShow,"ON"
                ENDIF

                IF FactoryDefaultsFlag=0
                    SETTEXT CounterFactory,"SELECT"
                ELSE
                    SETTEXT CounterFactory,"PRESS START"
                ENDIF
            ENDCASE

            CASE 1
                SETTEXT AudioVolume, "AUDIO VOLUME LEVEL ............................"
                SETTEXT DemoSound,"DEMO SOUND ............................................."
                SETTEXT ShowMode,    "SHOW MODE ..............................................."
                SETTEXT FactoryDefaults,"FACTORY DEFAULTS ..............................."
                SETTEXT AamsComms,"AAMS COMMUNICATIONS"
                IF DemoSoundFlag=0
                    SETTEXT CounterDemo,"OFF"
                ELSE
                    SETTEXT CounterDemo,"ON"
                ENDIF

                IF ShowModeFlag=0
                    SETTEXT CounterShow,"OFF"
                ELSE
                    SETTEXT CounterShow,"ON"
                ENDIF

                IF FactoryDefaultsFlag=0
                    SETTEXT CounterFactory,"SELECT"
                ELSE
                    SETTEXT CounterFactory,"PRESS START"
                ENDIF

            ENDCASE

        ENDSWITCH


        IF CURSOR = 4
            SET FactoryDefaultsFlag, 1
        ELSE
            SET FactoryDefaultsFlag, 0
        ENDIF


        SETTEXT CounterAudio, MASTERAUDIOLEVEL
        
        
        SWITCH CURSOR

            CASE 1
                SET TEMP_R1, AudioVolume.X1 + varyposition
                SET TEMP_R2, AudioVolume.Y1
                SETPOSITION AudioVolume, TEMP_R1, TEMP_R2
                SET TEMP_R2, DemoSound.Y1
                SETPOSITION DemoSound, 100, TEMP_R2

                SETCOLOR AudioVolume, 255,255,60,255
                SETCOLOR CounterAudio, 255,255,60,255
                SETCOLOR DemoSound, 255,200,60,255
                SETCOLOR CounterDemo, 255,200,60,255
                SETCOLOR ShowMode, 255,200,60,255
                SETCOLOR CounterShow, 255,200,60,255
                SETCOLOR FactoryDefaults, 255,200,60,255
                SETCOLOR CounterFactory, 255,200,60,255
                SETCOLOR Back, 255,200,60,255
            ENDCASE

            CASE 2
                SET TEMP_R2, AudioVolume.Y1
                SETPOSITION AudioVolume, 100, TEMP_R2
                SET TEMP_R1, DemoSound.X1 + varyposition
                SET TEMP_R2, DemoSound.Y1
                SETPOSITION DemoSound, TEMP_R1, TEMP_R2
                SET TEMP_R2, ShowMode.Y1
                SETPOSITION ShowMode, 100, TEMP_R2

                SETCOLOR AudioVolume, 255,200,60,255
                SETCOLOR CounterAudio, 255,200,60,255
                SETCOLOR DemoSound, 255,255,60,255
                SETCOLOR CounterDemo, 255,255,60,255
                SETCOLOR ShowMode, 255,200,60,255
                SETCOLOR CounterShow, 255,200,60,255
                SETCOLOR FactoryDefaults, 255,200,60,255
                SETCOLOR CounterFactory, 255,200,60,255
                SETCOLOR Back, 255,200,60,255

            ENDCASE

            CASE 3
                SET TEMP_R2, DemoSound.Y1
                SETPOSITION DemoSound, 100, TEMP_R2
                SET TEMP_R1, ShowMode.X1 + varyposition
                SET TEMP_R2, ShowMode.Y1
                SETPOSITION ShowMode, TEMP_R1, TEMP_R2
                SET TEMP_R2, FactoryDefaults.Y1
                SETPOSITION FactoryDefaults, 100, TEMP_R2

                SETCOLOR AudioVolume, 255,200,60,255
                SETCOLOR CounterAudio, 255,200,60,255
                SETCOLOR DemoSound, 255,200,60,255
                SETCOLOR CounterDemo, 255,200,60,255
                SETCOLOR ShowMode, 255,255,60,255
                SETCOLOR CounterShow, 255,255,60,255
                SETCOLOR FactoryDefaults, 255,200,60,255
                SETCOLOR CounterFactory, 255,200,60,255
                SETCOLOR Back, 255,200,60,255

            ENDCASE


            CASE 4
                SET TEMP_R2, ShowMode.Y1
                SETPOSITION ShowMode, 100, TEMP_R2
                SET TEMP_R1, FactoryDefaults.X1 + varyposition
                SET TEMP_R2, FactoryDefaults.Y1
                SETPOSITION FactoryDefaults, TEMP_R1, TEMP_R2
                SET TEMP_R2, Back.Y1
                SETPOSITION Back, 100, TEMP_R2

                SETCOLOR AudioVolume, 255,200,60,255
                SETCOLOR CounterAudio, 255,200,60,255
                SETCOLOR DemoSound, 255,200,60,255
                SETCOLOR CounterDemo, 255,200,60,255
                SETCOLOR ShowMode, 255,200,60,255
                SETCOLOR CounterShow, 255,200,60,255
                SETCOLOR FactoryDefaults, 255,255,60,255
                SETCOLOR CounterFactory, 255,255,60,255
                SETCOLOR Back, 255,200,60,255

            ENDCASE

            CASE 5
                SET TEMP_R2, FactoryDefaults.Y1
                SETPOSITION FactoryDefaults, 100, TEMP_R2

                SET TEMP_R1, Back.X1 + varyposition
                SET TEMP_R2, Back.Y1
                SETPOSITION Back, TEMP_R1, TEMP_R2

                SETCOLOR AudioVolume, 255,200,60,255
                SETCOLOR CounterAudio, 255,200,60,255
                SETCOLOR DemoSound, 255,200,60,255
                SETCOLOR CounterDemo, 255,200,60,255
                SETCOLOR ShowMode, 255,200,60,255
                SETCOLOR CounterShow, 255,200,60,255
                SETCOLOR FactoryDefaults, 255,200,60,255
                SETCOLOR CounterFactory, 255,200,60,255
                SETCOLOR Back, 255,255,60,255

            ENDCASE

        ENDSWITCH
        

    END

END
STOP


        ]]>
    </ExampleText>
    
</SyntaxLanguage>

using System;
using System.Collections;
using System.Diagnostics;
using System.Windows.Forms;
using ActiproSoftware.SyntaxEditor;

namespace TestApplication {

    /// <summary>
    /// Provides an implementation of a VB.NET language semantic parser that can perform automatic outlining.
    /// </summary>
    public class SemanticVBDotNetParser : SemanticDefaultParser {

        private ArrayList LiFo = new ArrayList();

        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <c>SemanticVBDotNetParser</c> class. 
        /// </summary>
        /// <remarks>
        /// The default constructor initializes all fields to their default values.
        /// </remarks>
        public SemanticVBDotNetParser() {
        }

        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Gets a <see cref="ActiproSoftware.SyntaxEditor.AutomaticOutliningSupportType"/> that indicates the automatic outlining support.
        /// </summary>
        /// <value>A <see cref="ActiproSoftware.SyntaxEditor.AutomaticOutliningSupportType"/> that indicates the automatic outlining support.</value>
        public override AutomaticOutliningSupportType AutomaticOutliningSupportType { 
            get {
                return AutomaticOutliningSupportType.SingleLanguageOnly;
            }
        }

        /// <summary>
        /// Returns token parsing information for automatic outlining that determines if the current <see cref="Token"/>
        /// in the <see cref="TokenStream"/> starts or ends an outlining node.
        /// </summary>
        /// <param name="tokenStream">A <see cref="TokenStream"/> that is positioned at the <see cref="Token"/> requiring outlining data.</param>
        /// <param name="outliningKey">Returns the outlining node key to assign.  A <see langword="null"/> should be returned if the token doesn't start or end a node.</param>
        /// <param name="tokenAction">Returns the <see cref="OutliningNodeAction"/> to take for the token.</param>
        public override void GetTokenOutliningAction(TokenStream tokenStream, ref string outliningKey, ref OutliningNodeAction tokenAction) {
            // Get the token
            Token token = tokenStream.Peek();

            // See if the token starts or ends an outlining node
            switch (token.Key) {
                case "MenuReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "MenuBlock";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnMenuEnterReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnMenuEnterBlock";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnMenuVisibleReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnMenuVisibleBlock";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnMenuExitReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnMenuExitBlock";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnProcessReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnProcessBlock";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnKeyboardReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnKeyboardBlock";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnCommReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnCommBlock";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnCommRawReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnCommRawBlock";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnCollisionReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnCollisionBlock";
                    tokenAction = OutliningNodeAction.Start;
                    break;

                case "ObjectReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "ObjectBlock";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnBut1ReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnBut1Block";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnBut2ReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnBut2Block";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnBut3ReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnBut3Block";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnBut4ReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnBut4Block";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnBut5ReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnBut5Block";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnBut6ReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnBut6Block";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnBut7ReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnBut7Block";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnBut8ReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnBut8Block";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnBut9ReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnBut9Block";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnBut0ReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnBut0Block";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnUpReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnUpBlock";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnDownReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnDownBlock";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnLeftReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnLeftBlock";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnRightReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnRigthBlock";
                    tokenAction = OutliningNodeAction.Start;
                    break;
                case "OnTickReservedWordToken":
                    LiFo.Add(token);
                    outliningKey = "OnTickBlock";
                    tokenAction = OutliningNodeAction.Start;
                    break;


                case "EndReservedWordToken":
                    if (LiFo.Count > 0)
                    {
                        Token Li = (Token)LiFo[LiFo.Count - 1];
                        switch (Li.Key)
                        {
                            case "MenuReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "MenuBlock";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnMenuEnterReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnMenuEnterBlock";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnMenuVisibleReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnMenuVisibleBlock";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnMenuExitReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnMenuExitBlock";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnProcessReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnProcessBlock";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnKeyboardReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnKeyboardBlock";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnCommReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnCommBlock";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnCommRawReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnCommRawBlock";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnCollisionReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnCollisionBlock";
                                tokenAction = OutliningNodeAction.End;
                                break;

                            case "ObjectReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "ObjectBlock";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnBut1ReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnBut1Block";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnBut2ReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnBut2Block";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnBut3ReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnBut3Block";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnBut4ReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnBut4Block";
                                tokenAction = OutliningNodeAction.End;
                                break;                            
                            case "OnBut5ReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnBut5Block";
                                tokenAction = OutliningNodeAction.End;
                                break;                            
                            case "OnBut6ReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnBut6Block";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnBut7ReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnBut7Block";
                                tokenAction = OutliningNodeAction.End;
                                break;                            
                            case "OnBut8ReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnBut8Block";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnBut9ReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnBut9Block";
                                tokenAction = OutliningNodeAction.End;
                                break;                            
                            case "OnBut0ReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnBut0Block";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnUpReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnUpBlock";
                                tokenAction = OutliningNodeAction.End;
                                break;                            
                            case "OnDownReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnDownBlock";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnLeftReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnLeftBlock";
                                tokenAction = OutliningNodeAction.End;
                                break;                            
                            case "OnRightReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnRightBlock";
                                tokenAction = OutliningNodeAction.End;
                                break;
                            case "OnTickReservedWordToken":
                                LiFo.Remove(Li);
                                outliningKey = "OnTickBlock";
                                tokenAction = OutliningNodeAction.End;
                                break;
                        }
                    }
                    break;
            }
        }

        /// <summary>
        /// Allows for performing semantic parsing following a lexical parse.
        /// </summary>
        /// <param name="document">The <see cref="Document"/> to parse.</param>
        /// <param name="modification">The <see cref="DocumentModification"/> that caused the parse.</param>
        public override void PostParse(Document document, DocumentModification modification) {
            // If programmatically setting the text of a document...
            if (modification.HasFlag(DocumentModificationFlags.ProgrammaticTextParse)) {
                // Collapse all outlining region nodes
                document.Outlining.RootNode.CollapseDescendants("RegionPreProcessorDirective");
            }
        }

        /// <summary>
        /// Allows for setting the collapsed text for the specified <see cref="OutliningNode"/>.
        /// </summary>
        /// <param name="node">The <see cref="OutliningNode"/> that is requesting collapsed text.</param>
        public override void SetOutliningNodeCollapsedText(OutliningNode node) {
            TokenCollection tokens = node.Document.Tokens;
            int tokenIndex = tokens.IndexOf(node.StartOffset);
            string tokenKey = tokens[tokenIndex].Key;
          
            switch (tokenKey) {
                case "MenuReservedWordToken":
                case "OnMenuEnterReservedWordToken": 
                case "OnMenuVisibleReservedWordToken": 
                case "OnMenuExitReservedWordToken": 
                case "OnProcessReservedWordToken": 
                case "OnKeyboardReservedWordToken": 
                case "OnCommReservedWordToken": 
                case "OnCommRawReservedWordToken": 
                case "OnCollisionReservedWordToken": 

                case "OnBut1ReservedWordToken": 
                case "OnBut2ReservedWordToken": 
                case "OnBut3ReservedWordToken": 
                case "OnBut4ReservedWordToken": 
                case "OnBut5ReservedWordToken":
                case "OnBut6ReservedWordToken":
                case "OnBut7ReservedWordToken": 
                case "OnBut8ReservedWordToken": 
                case "OnBut9ReservedWordToken":
                case "OnBut0ReservedWordToken":
                case "OnUpReservedWordToken":
                case "OnDownReservedWordToken":
                case "OnLeftReservedWordToken":
                case "OnRightReservedWordToken":
                case "OnTickReservedWordToken":
                {
                    string collapsedText = String.Empty;
                    string collapsedTextPlus = String.Empty;

                    while (++tokenIndex < tokens.Count) 
                    {
                        if (tokens[tokenIndex].IsWhitespace)
                            continue;

                        switch (tokens[tokenIndex].Key) {
                            case "LineTerminatorToken":
                            case "OpenParenthesisPatternGroup":
                                continue;
                            default:
                                collapsedText = tokens.Document.GetTokenText(tokens[tokenIndex]);
                                break;
                        }
                        break;
                    }

                    switch (tokenKey) {
                        case "MenuReservedWordToken":
                            node.CollapsedText = String.Format("MENU {0}", collapsedText.Trim());
                            break;
                        case "OnMenuEnterReservedWordToken":
                            node.CollapsedText = String.Format("ONMENUENTER");
                            break;
                        case "OnMenuVisibleReservedWordToken":
                            node.CollapsedText = String.Format("ONMENUVISIBLE");
                            break;
                        case "OnMenuExitReservedWordToken":
                            node.CollapsedText = String.Format("ONMENUEXIT");
                            break;
                        case "OnProcessReservedWordToken":
                            node.CollapsedText = String.Format("ONPROCESS");
                            break;
                        case "OnKeyboardReservedWordToken":
                            node.CollapsedText = String.Format("ONKEYBOARD");
                            break;
                        case "OnCommReservedWordToken":
                            node.CollapsedText = String.Format("ONCOMM");
                            break;
                        case "OnCommRawReservedWordToken":
                            node.CollapsedText = String.Format("ONCOMMRAW");
                            break;
                        case "OnCollisionReservedWordToken":
                            node.CollapsedText = String.Format("ONCOLLISION");
                            break;

                        case "ObjectReservedWordToken":
                            node.CollapsedText = String.Format("OBJECT {0}", collapsedText.Trim());
                            break;
                        case "OnBut1ReservedWordToken":
                            node.CollapsedText = String.Format("ONBUT1");
                            break;
                        case "OnBut2ReservedWordToken":
                            node.CollapsedText = String.Format("ONBUT2");
                            break;
                        case "OnBut3ReservedWordToken":
                            node.CollapsedText = String.Format("ONBUT3");
                            break;
                        case "OnBut4ReservedWordToken":
                            node.CollapsedText = String.Format("ONBUT4");
                            break;
                        case "OnBut5ReservedWordToken":
                            node.CollapsedText = String.Format("ONBUT5");
                            break;
                        case "OnBut6ReservedWordToken":
                            node.CollapsedText = String.Format("ONBUT6");
                            break;
                        case "OnBut7ReservedWordToken":
                            node.CollapsedText = String.Format("ONBUT7");
                            break;
                        case "OnBut8ReservedWordToken":
                            node.CollapsedText = String.Format("ONBUT8");
                            break;
                        case "OnBut9ReservedWordToken":
                            node.CollapsedText = String.Format("ONBUT9");
                            break;
                        case "OnBut0ReservedWordToken":
                            node.CollapsedText = String.Format("ONBUT0");
                            break;
                        case "OnUpReservedWordToken":
                            node.CollapsedText = String.Format("ONUP");
                            break;
                        case "OnDownReservedWordToken":
                            node.CollapsedText = String.Format("ONDOWN");
                            break;
                        case "OnLeftReservedWordToken":
                            node.CollapsedText = String.Format("ONLEFT");
                            break;
                        case "OnRightReservedWordToken":
                            node.CollapsedText = String.Format("ONRIGHT");
                            break;
                        case "OnTickReservedWordToken":
                            node.CollapsedText = String.Format("ONTICK");
                            break;

                    }
                    break;
                }

                case "ObjectReservedWordToken":
                {
                    string collapsedText = String.Empty;
                    while (++tokenIndex < tokens.Count) 
                    {
                        if (tokens[tokenIndex].Key == "LineTerminatorToken")
                            break;

                        collapsedText += tokens.Document.GetTokenText(tokens[tokenIndex]);
                    }
                    collapsedText = collapsedText.Trim();
                    if (collapsedText.StartsWith("\""))
                        collapsedText = collapsedText.Substring(1);
                    if (collapsedText.EndsWith("\""))
                        collapsedText = collapsedText.Substring(0, collapsedText.Length - 1);
                    if (collapsedText.Length == 0)
                        collapsedText = "...";
                    node.CollapsedText = String.Format("OBJECT {0}", collapsedText.Trim());

                    break;
                }

            }
        }

    }
}
<a href="mailto:"></a><a href="mailto:"></a>
Posted 19 years ago by Filipe Batista - Software/Hardware Developer, Cristaltec spa
Avatar
If you fold the last onprocess and the onkeyboard folds, and then select the empty lines and delete them the fold will
desincronize and get crazy even if LexicalParserLineLookAhead and LexicalParserLineLookBehind set to 255.

This is caused because 255 lookbehind lines can't get the parser to the begining of the text.

Solution might be to set LexicalParserLineLookAhead and LexicalParserLineLookBehind to -1 and make it reparse from
the begining to the end.

Tryed to manally reparse ontextchanged but it looses the folded state information and expands every fold.

Please give me some hint on how to solve this 'hitech' problem.

Thanks in advance

Filipe Batista


PS : If you think that there is another better way to make this folding parse, please advise.

[Modified at 08/26/2005 09:35 AM]
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Well you don't want to make the lookbehind go that far because it means that it will parse that many lines back during every parse, which can really slow things down.

Remember that you don't have to use our SemanticDefaultParser, since it is a simplistic outlining implementation. For complex languages, a custom one would be better. We provide you with all the methods you need to maintain the outlining nodes from the Document.Outlining object. There you can open and close nodes, etc. So if you make a class that inherits SemanticParser then you can work with the outlining node hierarchy yourself. In this scenario that might be best.


Actipro Software Support

Posted 18 years ago by Filipe Batista - Software/Hardware Developer, Cristaltec spa
Avatar
Hi,

Can you please send me sample source on how to contruct the OutliningNode tree from the PerformAutomaticOutlining in SemanticParser derived class. Maybe the code you use getting from
PerformAutomaticOutlining to GetTokenOutliningAction.

Best Regards,
Filipe Batista
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Filipe,

The code we had to write for PerformAutomaticOutlining is extremely complex. But essentially what we do is try to only modify an outlining node range that was changed by lexical parsing. We then incrementally go through the node tree and compare it to whether the tokens say a node should start or end. We use methods off of Document.Outlining to build and modify the outlining tree as needed.


Actipro Software Support

Posted 18 years ago by Filipe Batista - Software/Hardware Developer, Cristaltec spa
Avatar
Hi,

Please send me the contructor sample for OutliningNode, Please.

I need to make he OutliningNode Tree by my self, as my language format requires that.

Filipe Batista

[Modified at 09/08/2005 05:02 AM]
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
As I said, you need to use the various methods on the Document.Outlining object to create nodes. You don't create them directly.

Look in the documentation under "General Features / Outlining". On that page, go to "Modifying the Outlining Hierarchy". That tells you all the methods to use.

If you are doing your own automatic outlining, then make sure you only use the methods designated as for that.


Actipro Software Support

Posted 18 years ago by Filipe Batista - Software/Hardware Developer, Cristaltec spa
Avatar
Hi,

How can i set Token.Key in PreParse?

Filipe Batista
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Token.Key is set by the lexical parser so it's read only for you. However you can set Token.SemanticParseData to whatever object you want. That property is like a "Tag" property.


Actipro Software Support

Posted 18 years ago by Filipe Batista - Software/Hardware Developer, Cristaltec spa
Avatar
Hi,

I'm setting SemanticParseData for all token on PreParse but when i try to get data on :

private void editor_SelectionChanged(object sender, SelectionEventArgs e) {

// Get information about the current token
Token token = editor.Document.Tokens.GetTokenAtOffset(editor.Caret.Offset);

Identity identity = (Identity)token.SemanticParseData;
// Update the panels
if (identity != null) languagePanel.Text = token.Language.Key + "; " + identity.Name;
if (identity == null) languagePanel.Text = token.Language.Key;

}

i keep getting identity equal to null, it seems that tokens loose SemanticParseData outside the SemanticDefaultParser.

Can you help me?

Filipe Batista
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
We don't have any code in SyntaxEditor that gets or sets that property so it's not us modifying it. PreParse should be firing before the SelectionChanged event does. You can check that by maybe printing DateTime.Now out to the console window in each. And if that is working correctly perhaps you're looking at the wrong Token?


Actipro Software Support

Posted 18 years ago by Filipe Batista - Software/Hardware Developer, Cristaltec spa
Avatar
Hi,

Now i replace all EndToken Key's value by it's correspndent Begin in PreParse and put it in SemanticParseData and then in GetTokenOutliningAction i switch the value of SemanticParseData.

What appens is that when i load a document it does't outline it seems that the outlining is being done after lexic parse, and then after SemanticDefaultParser redoes the GetTokenOutliningAction it does't refresh the outlining.

But if i go to the end of the line that begins the outlining fold and type something it does refresh that brunch until the parent Node inside the root node.

I think that when the document is loaded the DocumentModification goes with no lines modified info, so the GetTokenOutliningAction does't do anithing.


I'm getting crazy, please help me...

Filipe Batista
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I'm a little lost with what you are trying to do. As I said, writing outlining code is extremely complex and took us weeks to get ours working right.

But if you are trying to write your own automatic outlining mechanism then you should NOT inherit from SemanticDefaultParser. Inherit from SemanticParser instead. SemanticParser.PreParse occurs first, then lexical parsing, then SemanticParser.PerformAutomaticOutlining, then SemanticParser.PostParse.

When a document is loaded the entire document is lexically parsed and outlined.


Actipro Software Support

Posted 18 years ago by Filipe Batista - Software/Hardware Developer, Cristaltec spa
Avatar
Hi,

I've tryed, but don't have any sample on how to perform manual outlining using SemanticParser's PerformAutomaticOutlining, can you send me a sample on how to construct the outlining tree?

Filipe Batista
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
As I said, it's extremely complex code (hundreds of lines) to do it right so there isn't a simple sample to provide.

What we do is have a master loop going through all the modified characters. We also track the outlining node that is at or contains each offset. As we loop through the offsets, we call GetTokenOutliningAction to determine if you (the developer) wants a node to start or end at each token.

Here's some sample logic... If we find that you want a node to start but there isn't one at that offset, we call Outlining.Add (use the overload made for automatic outlining) to create an "open" node, meaning we only know the start offset at this point. If you wanted to start a node, but there is another existing node already ending at that offset, we first call Outlining.Open for the the existing node to make sure it doesn't end there any more since a new node is supposed to start there. This is just a sample of the logic and it gets very complex just to do those sorts of things.

To recap though, the help topic I previously mentioned tells you want methods you can use to modify the node hierarchy in automatic outlining mode.

These methods can be used:
Outlining.Add - Adds a new outlining node at the specified start offset while in automatic outlining mode.
Outlining.Close - Closes the specified outlining node while in automatic outlining mode.
Outlining.Open - Opens the specified outlining node while in automatic outlining mode.
Outlining.Remove - Removes the specified <see cref="OutliningNode"/> from the hierarchy.

By using those methods and some very complicated logic, you can build an automatic outlining parser.


Actipro Software Support

The latest build of this product (v24.1.0) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.