Immediate state transition to child language

SyntaxEditor for Windows Forms Forum

Posted 9 years ago by Joachim Schwieren
Avatar
Hi, due to the fact that we want to encrypt all our dynamic syntax language files, we have to remove all "filename" references from the XML file of parent languages that point to child languages and then we have to add this references again at runtime in code.

How can we make an immediate transition in this siutation ?

    <State Key="ASPDirectiveCodeState" Filename="VBScript.xml" ChildLanguageBackColor="WhiteSmoke">
      <!-- Scopes -->
      <Scopes>
        <Scope>
          <ExplicitPatternGroup Type="StartScope" TokenKey="ASPDirectiveStartToken" Style="ASPDelimiterStyle" PatternValue="&lt;%" />
          <ExplicitPatternGroup Type="EndScope" TokenKey="ASPDirectiveEndToken" Style="ASPDelimiterStyle" PatternValue="%&gt;" />
        </Scope>
      </Scopes>
    </State>
I now remove Filename="VBScript.xml" ChildLanguageBackColor="WhiteSmoke" from the XML file and the reference to the child language is gone; now how can I add this reference again from code? I have already loaded the VBScript.xml with encryption manually but how can I assign it to the parent language so that it behaves in the same as if would have been loaded normally with the reference to the XML file in the language definition?

Would be nice if you could give an example.

Thanks for your help!

Joe

Comments (2)

Posted 9 years ago by Joachim Schwieren
Avatar
Hi,

ok that was not too difficult at all; I solved it by doing this in code:

SyntaxLanguageHTML.LexicalStates["ASPDirectiveCodeState"].LexicalStateTransitionLexicalState = SyntaxLanguageVBScript.DefaultLexicalState;
SyntaxLanguageHTML.LexicalStates["ASPDirectiveCodeState"].LexicalStateTransitionLexicalState.DefaultHighlightingStyle.BackColor = Color.WhiteSmoke;

But I also have languages that use a more complex lexical state transition. Here I did not manage to reproduce the that in code. This is the original XML definition; the part that is commented out will be dropped from the XML file and has to be "reconstructed" in code:

    <State Key="JScriptStartTagState" TokenKey="JScriptStartTagDefaultToken" Style="TagNameStyle">
      <!-- Scopes -->
      <Scopes>
        <Scope>
          <ExplicitPatternGroup Type="StartScope" TokenKey="StartTagStartToken" Style="TagDelimiterStyle" PatternValue="&lt;" LookAhead="script" />
          <RegexPatternGroup Type="EndScope" TokenKey="StartTagEndToken" Style="TagDelimiterStyle" PatternValue="/? &gt;" />
          <!--<StateTransition Filename="JavaScript.xml" ChildLanguageBackColor="WhiteSmoke">
            <ExplicitPatternGroup TokenKey="EndTagStartToken" Style="TagDelimiterStyle" PatternValue="&lt;/" LookAhead="script" />
          </StateTransition>-->
        </Scope>
      </Scopes>
      <!-- Child States -->
      <ChildStates>
        <ChildState Key="StartTagAttributeState" />
      </ChildStates>
    </State>
Can you tell me how I can add

<StateTransition Filename="JavaScript.xml" ChildLanguageBackColor="WhiteSmoke">
            <ExplicitPatternGroup TokenKey="EndTagStartToken" Style="TagDelimiterStyle" PatternValue="&lt;/" LookAhead="script" />
          </StateTransition>
to my language in code? Thanks a lot for your help!

Regards,

Joe
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Joachim,

One thing you could try (not sure if you realized it) was that if you load up your unencypted language set (all languages merged) and then export it back out using encryption, it will actually persist all your languages in a single file. Then you can just load that. Perhaps give that a try.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) 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.