<?xml version="1.0" encoding="Windows-1251"?>
<!DOCTYPE hrc SYSTEM "../hrc.dtd">
<?xml-stylesheet type="text/xsl" href="../hrc.xsl"?>

<hrc version="take5"
     xmlns="http://colorer.sf.net/2003/hrc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://colorer.sf.net/2003/hrc http://colorer.sf.net/2003/hrc.xsd">

<type name="regexp">

<annotation>
 <documentation>
 
 REGEXP package: any types of regular expressions.
 
 std.*   - base schemes for all types of regexp
 pcre.*  - schemes for PSRE (used in php, js, etc...)
 posix.* - schemes for POSIX 1003.2 regexp (used in php, sql, etc...)
 perl.*  - schemes for perl-like regexp (advansed PSRE) 
 hrc.*   - schemes for colorer-like regexp (used in hrc)
 
 </documentation>

 <contributors>
 <![CDATA[
  Eugene Efremov <4mirror@mail.ru> 
 ]]>
 </contributors>

 <appinfo><todo>
 <![CDATA[
  1.Символы \b\B выделяются в posix. Это надо будет убрать.
  2.Планируется добавить scheme.* - регекспы в стиле xml scheme.
  3.Планируется добавить распознавание unicode (пока там заглушка).
 ]]> 
 </todo></appinfo>

</annotation>

<region name="Symbol" description="ESC-Symbols: \(,\n,\r,etc" parent="def:StringContent"/>
<region name="MetaSymb" description="Metasymbols: *,+,$,etc" parent="def:Symbol"/>
<region name="MetaSymbStrong" description="Structrural metasymbols: |,etc" parent="def:SymbolStrong"/>
<region name="SymbClass" description="Symbol's class: \d,\w,etc." parent="def:Var"/>
<region name="Operator" description="Assertions and operators: \B, ?!, etc." parent="def:Keyword"/>
<region name="SpecOperator" description="Special operators : \1, etc." parent="def:KeywordStrong"/>
<region name="Quote" description="Qoutes: (),{},[]" parent="MetaSymb"/>
<region name="SpecQuote" description="Special qoutes" parent="MetaSymbStrong"/>
<region name="SpecArea" description="Special areas: (?i:), etc." parent="def:Keyword"/>
<region name="InsertArea" description="Special areas: (?i:), etc." parent="def:Insertion"/>


<entity name='hex' value="[0-9a-fA-F]"/>


<scheme name="string"/> <!-- Заглушка, на ее место подставлять строку языка -->

<scheme name="code"> <!-- Заглушка, на ее место подставлять код языка -->
 <regexp match="/./" region0="def:Error" priority="low"/>
</scheme>

<!-- Базовый модуль -->

<scheme name="std.base.core">
 <inherit scheme="string"/>
 <regexp match="/\\[dsw]/" region0="SymbClass"/>   <!-- Классы символов -->
 <regexp match="/\\[^a-z1-9]/" region0="Symbol"/> <!-- Квотирование -->
 <regexp match="/\\[nrt]/" region0="Symbol"/> <!-- спецсимволы  -->
</scheme>

<scheme name="std.base"> <!-- Общее для всех частей регэкспа -->
 <inherit scheme="string"/>
 <regexp match="/[\^]/" region0="MetaSymb"/>   <!-- Спецсимвол ^ -->
 <regexp match="/\\x%hex;{2}/" region0="Symbol"/> <!-- hex число  -->
 <regexp match="/\\[DSW]/" region0="SymbClass"/>   <!-- Классы символов -->
 <inherit scheme="std.base.core"/>
 <regexp match="/\\[0-9a-fA-F]/" region0="SpecOperator"/>    <!-- Классы символов -->
 <regexp match="/\\./" region0="def:Error"/>       <!-- таких символов нет  --> 
</scheme>

<scheme name="std.class"> <!-- class [] -->
 <inherit scheme="string"/>
 <regexp match="/[\-]\M[^\]\-]/" region0="MetaSymb"/> <!-- A-Z -->
 <inherit scheme="std.base"/>
</scheme>

<scheme name="std.symbs">
 <inherit scheme="string"/>
 <regexp match="/[\.\*\+\$\?]/" region0="MetaSymb" priority="low"/> <!-- спецсимволы -->
 <regexp match="/\|/" region0="MetaSymbStrong" priority="low"/> <!-- спецсимвол | -->
 <regexp match="/\\[Bb]/i" region0="Operator"/> <!-- претензии (без \A\Z\z) -->
</scheme>

<scheme name="std.number">
 <inherit scheme="string"/>
 <regexp match="/\d/" region0="def:Number" />
 <keywords region="def:Symbol">
  <symb name=","/>
  <symb name=" "/>
 </keywords>
 <regexp match='/./' region0="def:Error" priority="low"/>
</scheme>

<scheme name="std.regexp">
 <inherit scheme="string"/>
 <!--regexp match="/\\c\[/" region0="Symbol"/-->
 <block start="/(\()/" end="/(\))/" scheme="std.regexp"
  region00="Quote" region01="def:PairStart"
  region10="Quote" region11="def:PairEnd"
 /> 
 <block start="/(\[)/" end="/([^\\]\[)?~2((\]))/x" scheme="std.class"
  region00="Quote" region01="def:PairStart"
  region12="Quote" region13="def:PairEnd"
 />   
 <block start="/(\{)/" end="/(\})/" scheme="std.number" 
  region00="Quote" region01="def:PairStart"
  region10="Quote" region11="def:PairEnd"
 />   
 <block start="/\(?#1(\?\{)/" end="/(\})/" scheme="code" region="InsertArea"
  region00="SpecQuote" region01="def:PairStart"
  region10="SpecQuote" region11="def:PairEnd"
 />
 <inherit scheme="std.symbs"/>
 <inherit scheme="std.base"/>
</scheme>



<!--      -->
<!-- PCRE -->
<!--      -->



<scheme name="pcre.base">
 <inherit scheme="string"/>
 <regexp match="/\\o[0-7]{3}/" region0="Symbol"/> <!-- oct число  -->
 <regexp match="/\\[aenrtfv]/" region0="Symbol"/> <!-- спецсимволы  -->
 <regexp match="/\\c./" region0="Symbol"/>       <!-- спецсимволы  -->
 <regexp match="/\\[0-9a-fA-F]{2}/" region0="SpecOperator"/>     <!-- Классы символов -->
 <inherit scheme="std.base"/>
</scheme>

<scheme name="pcre.symbs">
 <inherit scheme="std.symbs"/>
 <regexp match="/\\[BbZAa]/i" region0="Operator"/> <!-- претензии (\A\Z\z - в т.ч) -->
</scheme>

<scheme name="pcre.choise">
 <regexp match="/~\s*%hex;{0,2}\s*/" region0="def:Number" />
 <block start="/~(\?&lt;?[\=\!])/" end="/\M\)/" 
  scheme="pcre.regexp" region01="Operator"
 /> 
 <regexp match="/./" region0="def:Error" priority="low"/>
</scheme>

<scheme name="pcre.modif"> <!-- Заглушка, на ее место - спецсимволы -->
 <regexp match="/./" region0="def:Error" priority="low"/>
</scheme>


<!-- Регексп в общем виде -->
<scheme name="pcre.regexp">
 <inherit scheme="string"/>
 <block start="/(\()(\?&lt;?[\=\!])/" end="/(\))/" scheme="pcre.regexp"
  region00="def:PairStart" region01="Quote" region02="Operator"
  region10="def:PairEnd" region11="Quote"
 /> 
 <block start="/(\s\s+|\x09)\#/" end="/$/" 
  scheme="def:Comment" region="def:Comment"
 />
 <block start="/(\()(\?\#)/" end="/(\))/" 
  scheme="def:Comment" region="def:Comment"
  region00="def:PairStart" region01="Quote" region02="SpecOperator"
  region10="def:PairEnd" region11="Quote"
 /> 
 <block start="/\(?#1(\?)\M[\w\-]*\:/" end="/(\:)/" 
  scheme="pcre.modif" region="SpecArea"
  region00="def:PairStart" region01="SpecQuote" 
  region10="def:PairEnd" region11="SpecQuote"
 /> 
 <block start="/(\()(\?)\M\w[\w\-]*\)/" end="/(\))/" 
  scheme="pcre.modif" region="SpecArea"
  region00="def:PairStart" region01="SpecQuote" region02="SpecQuote"
  region10="def:PairEnd" region11="SpecQuote"
 /> 

 <block start="/\(?#1(\?\()/" end="/(\))/" scheme="pcre.choise" 
  region00="SpecQuote" region01="def:PairStart"
  region10="SpecQuote" region11="def:PairEnd"
 />   
 <inherit scheme="std.regexp">
  <virtual scheme="std.base" subst-scheme="pcre.base"/>
  <virtual scheme="std.symbs" subst-scheme="pcre.symbs"/>
  <virtual scheme="std.regexp" subst-scheme="pcre.regexp"/>
 </inherit>
</scheme>



<!--      -->
<!-- POSIX 1003.2 -->
<!--      -->


<scheme name="posix.liter.class">
 <keywords region="SymbClass">
  <word name="alpha"/>
  <word name="alnum"/>
  <word name="ascii"/>
  <word name="blank"/>
  <word name="cntrl"/>
  <word name="digit"/>
  <word name="graph"/>
  <word name="lower"/>
  <word name="print"/>
  <word name="punct"/>
  <word name="space"/>
  <word name="upper"/>  
  <word name="word"/>
  <word name="xdigit"/>
 </keywords>
 <regexp match="/\^/" region0="MetaSymb"/>
 <regexp match="/(\:)?#1&gt;(\:)?=/" region0="Operator"/>
 <regexp match="/(\:)?#1&lt;(\:)?=/" region0="Operator"/>
</scheme>

<scheme name="posix.liter.bracket">
 <block start="/(\[\:)/" end="/(\:\])/" scheme="posix.liter.class" 
  region00="def:PairStart" region01="Quote" 
  region10="def:PairEnd" region11="Quote" />
</scheme>

<scheme name="posix.class">
 <regexp match="/[\^\-]/" region0="MetaSymb"/>
 <inherit scheme="posix.liter.bracket"/>
 <block start="/(\[\=)/" end="/(\=\])/" scheme="string" 
  region00="def:PairStart" region01="Quote" 
  region10="def:PairEnd" region11="Quote" /> 
 <block start="/(\[\.)/" end="/(\.\])/" scheme="string" 
  region00="def:PairStart" region01="Quote" 
  region10="def:PairEnd" region11="Quote" /> 
 <inherit scheme="std.class">
  <virtual scheme="std.base" subst-scheme="std.base.core"/>
  <virtual scheme="std.class" subst-scheme="posix.class"/>
 </inherit>
</scheme>


<scheme name="posix.regexp"> 
 <inherit scheme="std.regexp">
  <virtual scheme="std.base" subst-scheme="std.base.core"/>
  <virtual scheme="std.class" subst-scheme="posix.class"/>
  <virtual scheme="std.regexp" subst-scheme="posix.regexp"/>
 </inherit>
</scheme>



<!--      -->
<!-- perl-like -->
<!--      -->

<scheme name="unicode.charter"/> <!-- Not realised -->

<scheme name="perl.modif">
 <keywords region="SpecArea">
  <symb name="-" region="MetaSymb"/>
  <symb name="i"/>
  <symb name="m"/>
  <symb name="s"/>
  <symb name="x"/>  
 </keywords>
 <inherit scheme="pcre.modif"/>
</scheme>

<scheme name="perl.posix.liter.class">
 <keywords region="SymbClass">
  <word name="IsAlpha"/>
  <word name="IsAlnum"/>
  <word name="IsASCII"/>
  <word name="IsSpace"/>
  <word name="IsCntrl"/>
  <word name="IsDigit"/>
  <word name="IsGraph"/>
  <word name="IsLower"/>
  <word name="IsPrint"/>
  <word name="IsPunct"/>
  <word name="IsSpace"/>
  <word name="IsSpacePerl"/>
  <word name="IsUpper"/>
  <word name="IsWord"/>
  <word name="IsXDigit"/>
 </keywords>  
</scheme>

<scheme name="perl.posix.liter.bracket">
 <block start="/(\\[pP])(\{)/" end="/(\})/" scheme="perl.posix.liter.class"
  region00="def:PairStart" region01="Operator" region02="Quote" 
  region10="def:PairEnd" region11="Quote" />
</scheme>
<scheme name="perl.unicode.liter.bracket">
 <block start="/(\\N)(\{)/" end="/(\})/" 
  scheme="unicode.charter" region="def:CharacterContent"
  region00="def:PairStart" region01="Operator" region02="Quote" 
  region10="def:PairEnd" region11="Quote" />
</scheme>
<scheme name="perl.quote">
 <block start="/(\\Q)/" end="/(\\E)/" scheme="string" 
  region00="def:PairStart" region01="Operator"
  region10="Operator" region11="def:PairEnd" 
 /> 
</scheme>

<scheme name="perl.base">
 <inherit scheme="string"/>
 <regexp match="/(\\x)(\{)(%hex;+)(\})/" 
  region1="SymbClass" region2="Quote" 
  region3="def:NumberHex" region4="Quote"
 />
 <inherit scheme="perl.unicode.liter.bracket"/>
 <inherit scheme="perl.posix.liter.bracket"/>
 <inherit scheme="posix.liter.bracket"/>
 <regexp match="/\\o[0-7]*/" region0="def:Error"/> <!-- HЕ oct число  -->
 <regexp match="/\\[0-7]{3}/" region0="Symbol"/> <!-- oct число  -->
 <inherit scheme="pcre.base"/> 
</scheme>

<scheme name="perl.symbs">
 <inherit scheme="std.symbs"/>
 <regexp match="/\\[Pp]P/" region0="SymbClass" />
 <regexp match="/\\[XC]/" region0="SymbClass" />
 <regexp match="/\\[LlUuE]/" region0="Operator"/>
</scheme>

<scheme name="perl.regexp">
 <inherit scheme="string"/>
 <inherit scheme="posix.liter.bracket"/>
 <inherit scheme="perl.quote"/>
 <block start="/(\()(\?&gt;)/" end="/(\))/" scheme="perl.regexp"
  region00="def:PairStart" region01="Quote" region02="Operator"
  region10="def:PairEnd" region11="Quote"
 />  
 <block start="/\(?#1(\?{1,2}\{)/" end="/(\})/" 
  scheme="code" region="InsertArea"
  region00="SpecQuote" region01="def:PairStart"
  region10="SpecQuote" region11="def:PairEnd"
 />
 
 <inherit scheme="pcre.regexp">
  <virtual scheme="pcre.base" subst-scheme="perl.base"/>
  <virtual scheme="pcre.symbs" subst-scheme="perl.symbs"/>
  <virtual scheme="pcre.modif" subst-scheme="perl.modif"/>
  <virtual scheme="pcre.regexp" subst-scheme="perl.regexp"/>
 </inherit>
</scheme>



<!-- Colorer HRC -->


<scheme name="hrc.base">
 <inherit scheme="string"/>
 <!--regexp match="/&amp;((lt)|(gt)|(amp)|(quot));/" region0="dParam2"/>
 <regexp match="/&lt;|&amp;/" region0="def:Error"/-->
 <regexp match="/\\[ul]/" region0="SymbClass"/>   <!-- Классы символов -->
 <regexp match="/\\[ypYP](%hex;|\{\w*?\})/i" region0="SpecOperator"/>  <!-- colorer operators -->
 <inherit scheme="std.base"/>
</scheme>

<scheme name="hrc.symbs">
 <inherit scheme="string"/>
 <regexp match="/\?[\#\~]\d+/" region0="Operator"/>  <!-- операторы просмотра -->
 <regexp match="/\?[\!\=]/" region0="Operator"/>  <!-- операторы просмотра -->
 <regexp match="/\~/" region0="SpecOperator"/>       <!-- спецсимволы -->
 <regexp match="/\\C/i" region0="SymbClass"/>    <!-- Классы символов -->
 <regexp match="/\\[mM]/i" region0="SpecOperator"/>  <!-- colorer operators -->
 <regexp match="/\%%xml:Name;\;/" region="xml:EntityRef"/>
 <inherit scheme="std.symbs"/>
</scheme>

<scheme name="hrc.regexp"> 
 <inherit scheme="std.regexp">
  <virtual scheme="std.base" subst-scheme="hrc.base"/>
  <virtual scheme="std.symbs" subst-scheme="hrc.symbs"/>
  <virtual scheme="std.regexp" subst-scheme="hrc.regexp"/>
 </inherit>
</scheme>


<!-- заглушка для создания типа -->

<scheme name="regexp">
 <block start="/(\/)/" end="/(\/([mgeioxs]*))/" 
  scheme="perl.regexp" region="def:String"
  region00="SpecQuote" region01="def:PairStart"
  region10="SpecQuote" region11="def:PairEnd" region12="SpecArea"
 />
</scheme>
</type>
</hrc>
