# Colorer-take5 be5 design usecases

## Prologue/Epilogue inherit feature

Minor improvement over inheritance usability. Allows to shortcut HRC code development. Outlines most common inheritance usecase.

    <hrc>

    <type name="lang">
      <scheme name="lang"/>
      <scheme name="expression"/>
      <scheme name="keywords"/>
    </type>

    <type name="ext">
      <scheme name="ext">
        <inherit scheme="lang:lang">
          <virtual scheme="lang:expression" prologue="expression.prologue"/>
        </inherit>
      </scheme>
      <scheme name="expression.prologue">
        <!-- Additional behaviour for lang:expression -->
        <regexp />
      </scheme>
    </type>

    <type name="ext2">
      <scheme name="ext2">
        <inherit scheme="lang:lang">
          <virtual scheme="lang:expression" subst="expression"/>
          <virtual scheme="lang:keywords" prologue="keywords.prologue" epilogue="keywords.epilogue"/>
        </inherit>
      </scheme>
      <scheme name="expression">
        <!-- Additional behaviour for lang:expression -->
        <regexp />
        <!-- No need to redefine lang:keywords virtualization - applied automatically -->
        <inherit scheme="lang:expression"/>
      </scheme>

      <scheme name="keywords.prologue">
        <keywords />
      </scheme>
      <scheme name="keywords.epilogue">
        <keywords />
      </scheme>

    </type>

    </hrc>

## Inheritance behaviour change

Old behaviour: When a level of inherit substitution is applied, it becomes disabled for new schemes, invoked because of <virtual> rules.
New behaviour: Only lower levels of inheritance are disabled when applying a particular <virtual> rule. This level's <virtual> rules (including the applied one) are still valid and active.

    <hrc>

    <type name="jsp">

      <scheme name="jsp">
        <block start="/(&lt;\%\@)/" end="/(\%\>)/" scheme="header-tag" region="Insertion" region00="OpenTag" region10="CloseTag" region01="def:PairStart" region11="def:PairEnd"/>
        <!--
          ASP inheritance with common ASP and HTML parameters improvements.
        -->
        <inherit scheme="asp:html">
          <virtual scheme="asp:Insertion" prologue="Insertion.prologue"/>
          <virtual scheme="asp:targetLanguage" subst-scheme="TypeDeclaration"/>
          <!-- Refer to "prologue-epilogue.hrc" improvement document -->
          <virtual scheme="html:htmlCoreTags" prologue="coreTags.prologue" epilogue="coreTags.epilogue"/>
        </inherit>
      </scheme>

      <scheme name="Insertion.prologue">
        <block start="/(&lt;\%--)/" end="/(--\%\>)/" scheme="def:Comment" region="def:Comment" region00="def:PairStart" region10="def:PairEnd"/>
        <!--
            Do not need "asp:Insertion" inheritance, because "prologue" is used,
            Do not need additional re-virtualization because already reused from "jsp" scheme
        -->
      </scheme>

      <!-- Redefined Java type for JSP with inverse insertion and comment fixup -->
      <scheme name="TypeDeclaration">
        <regexp match="/\/\/.*$/ix" region="def:Comment"/>
        <!-- Do not need to specify now targetLanguage re-virtualization. Already reused from "jsp" scheme -->
        <inherit scheme="InverseInsertion"/>
        <block start="/(\\&quot;)/" end="/(\\&quot;)/" scheme="def:Comment" region="def:String" region00="def:PairStart" region10="def:PairEnd"/>
        <inherit scheme="java:TypeDeclaration">
           <virtual scheme="java:TypeDeclaration" subst-scheme="TypeDeclaration"/>
        </inherit>
      </scheme>

      <scheme name="coreTags.prologue">
         <keywords region="OpenTag">
            <word name="jsp:include"/>
            <word name="jsp:forward"/>
            <word name="jsp:getproperty"/>
            <word name="jsp:setproperty"/>
            <word name="jsp:useBean"/>
            <word name="jsp:param"/>
         </keywords>
         <regexp match="/\bjsp\:\w+\b/" region="OpenTag"/>
      </scheme>
      <scheme name="coreTags.epilogue">
         <keywords region="OpenTag">
            <word name="c:set"/>
            <word name="c:out"/>
            <word name="c:forEach"/>
            <word name="x:parse"/>
            <word name="x:transform"/>
            <word name="x:param"/>
         </keywords>
      </scheme>

    </type>

    Old code:

    <type name="jsp">
       <scheme name="jsp">
          <!-- FIX!!! -->
          <block start="/(&lt;\%\@)/" end="/(\%\>)/" scheme="header-tag" region="Insertion" region00="OpenTag" region10="CloseTag" region01="def:PairStart" region11="def:PairEnd"/>
          <inherit scheme="asp:html">
             <virtual scheme="asp:Insertion" subst-scheme="Insertion"/>
             <virtual scheme="targetLanguage" subst-scheme="TypeDeclaration"/>
             <virtual scheme="html:htmlCoreTags" subst-scheme="coreTags"/>
          </inherit>
       </scheme>

       <scheme name="Insertion">
         <block start="/(&lt;\%--)/" end="/(--\%\>)/" scheme="def:Comment"
                 region="def:Comment" region00="def:PairStart" region10="def:PairEnd"/>
         <inherit scheme='asp:Insertion'>
           <virtual scheme="targetLanguage" subst-scheme="TypeDeclaration"/>
           <virtual scheme="html:htmlCoreTags" subst-scheme="coreTags"/>
         </inherit>
       </scheme>

       <scheme name="TypeDeclaration">
          <regexp match="/\/\/.*$/ix" region="def:Comment"/>
          <inherit scheme="InverseInsertion">
             <virtual scheme="targetLanguage" subst-scheme="TypeDeclaration"/>
          </inherit>
          <block start="/(\\&quot;)/" end="/(\\&quot;)/" scheme="def:Comment"
                 region="def:String" region00="def:PairStart" region10="def:PairEnd"/>
          <inherit scheme="java:TypeDeclaration">
             <virtual scheme="java:TypeDeclaration" subst-scheme="TypeDeclaration"/>
          </inherit>
       </scheme>

       <scheme name="coreTags">
          <keywords region="OpenTag">
             <word name="jsp:include"/>
             <word name="jsp:forward"/>
             <word name="jsp:getproperty"/>
             <word name="jsp:setproperty"/>
             <word name="jsp:useBean"/>
             <word name="jsp:param"/>
          </keywords>
          <regexp match="/\bjsp\:\w+\b/" region="OpenTag"/>
          <inherit scheme="html:htmlCoreTags"/>
          <keywords region="OpenTag">
             <word name="c:set"/>
             <word name="c:out"/>
             <word name="c:forEach"/>
             <word name="x:parse"/>
             <word name="x:transform"/>
             <word name="x:param"/>
          </keywords>
       </scheme>
    </type>

## Region inheritance feature

Allows HRC regions parametrization. Allows heavier flexibility in highlighting and implementing multiple color styles.

    <hrc>

    <type name="lang">

      <region name="Common"/>

      <scheme name="expression">
        <regexp match="/someexpr/" region="Common"/>
      </scheme>

    </type>

    <type name="ext">

      <region name="ExtSyntax"/>
      <region name="OtherContext"/>

      <scheme name="ext">
        <inherit scheme="lang:expression">
          <virtual region="lang:Common" subst="ExtSyntax"/>
        </inherit>
      </scheme>

      <scheme name="othercontext">
        <inherit scheme="ext">
          <virtual region="ExtSyntax" subst="OtherContext"/>
        </inherit>
      </scheme>

    </type>

    </hrc>