Posted 20 years ago by bnott
Avatar
Hello,

I am extending the XML language you provide. Right now what I am trying to do is make certain tags, based on the tag name, be in a particular state. Is this the best way to do it?
  
<State Key="MyStartTagState" Token="MyStartTagDefaultToken" Style="MyTagNameStyle">
   <!-- Scopes -->
   <Scopes>
       <Scope>
           <ExplicitPatternGroup Type="StartScope" Token="MyStartTagStartToken" Style="MyTagDelimiterStyle" PatternValue="<" 
              LookAhead="my:tag1|my:tag2|my:tag3" />
           <RegexPatternGroup Type="EndScope" Token="MyStartTagEndToken" Style="MyTagDelimiterStyle" PatternValue="/? >" />    
       </Scope>
   </Scopes>

   <!-- Patterns Groups -->
   <PatternGroups>
       <RegexPatternGroup Token="MyStartTagNameToken" Style="MyTagNameStyle" LookAhead="{NonWordMacro}" PatternValue="{TagNameMacro}+" />
   </PatternGroups>

   <!-- Child States -->
   <ChildStates>
       <ChildState Key="MyStartTagAttributeState" />
   </ChildStates>
</State>

<State Key="MyEndTagState" Token="MyEndTagDefaultToken" Style="MyTagNameStyle">
    <!-- Scopes -->
    <Scopes>
        <Scope>
            <ExplicitPatternGroup Type="StartScope" Token="MyEndTagStartToken" Style="MyTagDelimiterStyle" PatternValue="</" 
                LookAhead="my:tag1|my:tag2|my:tag3" " />
            <ExplicitPatternGroup Type="EndScope" Token="MyEndTagEndToken" Style="MyTagDelimiterStyle" PatternValue=">" />    
        </Scope>
    </Scopes>
    <!-- Patterns Groups -->
    <PatternGroups>
        <RegexPatternGroup Token="MyEndTagDefaultToken" PatternValue="[^>]+" />
    </PatternGroups>
</State>


[ 10-25-2004: Message edited by: bnott ]

Comments (2)

Posted 20 years ago by bnott
Avatar
Small update, i changed it to:
  
   LookAhead="my: (tag1 | tag2 | tag3) {NonTagNameMacro}"
Is there a better way to do this than a potentially gigantic LookAhead list?
Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Right now there isn't a better way to do it unless you use a semantic parser PostProcess phase and reassign CustomHighlightingStyles depending on the token's text. But that won't alter the state. We're open to all suggestions if you have any though.


Actipro Software Support

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.