<?xml version="1.0"?>
<!DOCTYPE hrc PUBLIC "-//Cail Lomecb//DTD Colorer HRC take5//EN"
  "http://colorer.sf.net/2003/hrc.dtd">
<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">
<!--
   Lex(flex) & YACC(Bison) Files Syntax

   Made by Timur Safin <timur@lanit.ru>
   Changed by Artem Zankovich <z_artem@yahoo.com> (27.03.2002)
-->
   <type name="lex" access="public">

      <import type="def"/>
      <import type="c"/>

      <region name="lyText" parent="default"/>
      <region name="lyString" parent="String"/>
      <region name="lyComment" parent="Comment"/>
      <region name="lyCommentEx" parent="CommentContent"/>
      <region name="lySymb" parent="Keyword"/>
      <region name="lySymbEx" parent="Directive"/>
      <region name="lySymbEx0" parent="StringContent"/>
      <region name="lyYaccName" parent="CommentContent"/>


      <scheme name="LYComments">
         <regexp match="/(\/\/.*$)/" region0="lyComment"/>
         <block start="/\/\*/" end="/\*\//" scheme="Comment" region="lyComment" region00="PairStart" region10="PairEnd"/>
      </scheme>

      <scheme name="lyOptionText">
         <inherit scheme="LYComments"/>
         <regexp match="/(&#34;((\\.)|[^\\&#34;])*?&#34;)/" region0="lyString"/>
      </scheme>

      <scheme name="LexSymbols">
         <regexp match="/(\{(\w+)\})/" region1="lySymb" region2="lySymbEx"/>
<!-- POSIX char-classes -->
         <keywords region="lySymb">
            <symb name="[:alnum:]"/>
            <symb name="[:alpha:]"/>
            <symb name="[:blank:]"/>
            <symb name="[:cntrl:]"/>
            <symb name="[:digit:]"/>
            <symb name="[:graph:]"/>
            <symb name="[:lower:]"/>
            <symb name="[:print:]"/>
            <symb name="[:punct:]"/>
            <symb name="[:space:]"/>
            <symb name="[:upper:]"/>
            <symb name="[:xdigit:]"/>
         </keywords>
         <regexp match="/(\\)[\[\]\\]/" region1="lySymb"/>
<!-- other flex regexp symbols -->
         <keywords region="lySymb">
            <symb name="."/>
            <symb name="-"/>
            <symb name="+"/>
            <symb name="*"/>
            <symb name="?"/>
            <symb name="("/>
            <symb name=")"/>
            <symb name="\"/>
            <symb name="/"/>
            <symb name="|"/>
            <symb name="^"/>
            <symb name="$"/>
            <word name="&lt;&lt;EOF&gt;&gt;"/>
         </keywords>
      </scheme>

      <scheme name="lyCompoundCLex">
         <keywords region="lySymbEx">
            <word name="BEGIN"/>
            <word name="ECHO"/>
         </keywords>
         <inherit scheme="PairedBrackets">
            <virtual scheme="PairedBrackets" subst-scheme="lyCompoundCLex"/>
         </inherit>
         <inherit scheme="c">
            <virtual scheme="c" subst-scheme="lyCompoundCLex"/>
         </inherit>
      </scheme>

      <scheme name="lyLexRule">
         <regexp match="/(\\)\&#34;/" region1="lySymb"/>
         <regexp match="/(&lt;[\w,\s\*]+\&gt;)/" region="lySymbEx"/>
         <inherit scheme="LYComments"/>
         <inherit scheme="CString"/>
         <block start="/(\[)/" end="/(\])/" scheme="LexSymbols" region00="PairStart" region10="PairEnd" region01="lySymb" region11="lySymb"/>
         <inherit scheme="LexSymbols"/>
         <block start="/(\s+\{)/" end="/(\})/" scheme="lyCompoundCLex" region00="PairStart" region10="PairEnd" region01="lySymbEx" region11="lySymbEx"/>
         <regexp match="/\s+(\|)\s*$/" region1="lySymbEx"/>
         <block start="/\s+/" end="/$/" scheme="lyCompoundCLex"/>
      </scheme>

      <scheme name="lyCompoundC">
         <regexp match="/\B(\$[\$\d]{,2})/" region0="lySymbEx"/>
         <inherit scheme="PairedBrackets">
            <virtual scheme="PairedBrackets" subst-scheme="lyCompoundC"/>
         </inherit>
         <inherit scheme="c">
            <virtual scheme="c" subst-scheme="lyCompoundC"/>
         </inherit>
      </scheme>

      <scheme name="lyYaccRule">
         <inherit scheme="LYComments"/>
         <block start="/^([\w\.\_]+)\s*(\:)?/" end="/(;)/" scheme="lyYaccRule" region01="lyYaccName" region02="lySymbEx" region10="lySymbEx"/>
         <block start="/^(\s+)(\|)/" end="/(\M;|\|)/" scheme="lyYaccRule" region02="lySymbEx" region10="lySymbEx"/>
         <regexp match="/('..??.??.??')/" region0="lyString"/>
         <regexp match="/\b ([a-zA-Z\d\.\_]+) (\b|$)/x" region0="lyYaccName"/>
         <regexp match="/(\%prec)\s+([\w\.\_]+)/" region1="lySymb" region2="lySymbEx"/>
         <block start="/(\{)/" end="/(\})/" scheme="lyCompoundC" region00="PairStart" region10="PairEnd" region01="lySymbEx" region11="lySymbEx"/>
         <keywords region="lySymbEx">
            <symb name=":"/>
<!--       <symb name="|"/> -->
         </keywords>
      </scheme>

      <scheme name="lyRule"/>

      <scheme name="lySecondPart">
         <inherit scheme="LYComments"/>
<!--  Last (third) C part.
    TODO! What about Delphi Yacc/Lex ? They should embed Pascal-blocks
          instead of C. How we could to recognise it ?... -->
         <block start="/^(\%\%)/" end="/^NeVeRUseD$/" scheme="c" region01="lySymb"/>
<!-- embedded C-block -->
         <block start="/^(\%\{)/" end="/(\%\})/" scheme="c" region00="PairStart" region10="PairEnd" region01="lySymb" region11="lySymb"/>
         <inherit scheme="lyRule"/>
      </scheme>

      <scheme name="lyPerCent">
         <inherit scheme="LYComments"/>
         <regexp match="/('..??.??.??')/" region0="lyString"/>
         <block start="/(option)/" end="/$/" scheme="lyOptionText" region01="lySymb"/>
<!-- Timur: It's mine...-->
         <regexp match="/\b (start-condition) \b/x" region0="lySymb"/>
<!-- YACC/Bison -->
         <regexp match="/\b (token|left|right|nonassoc|start|no_lines|pure_parser|type|expect|raw|token_table) \b/x" region0="lySymb"/>
<!-- LEX/flex -->
         <regexp match="/\b ([xsaceknopr]|pointer|array) \b/x" region0="lySymb"/>
<!-- flex++ -->
         <regexp match="/\b (name|define) \b/x" region0="lySymb"/>
      </scheme>

      <scheme name="LexYacc">
         <inherit scheme="LYComments"/>
<!-- embedded  C block -->
         <block start="/^(\%\{)/" end="/(\%\})/" scheme="c" region00="PairStart" region10="PairEnd" region01="lySymb" region11="lySymb"/>
<!-- Timur's extensions -->
         <block start="/^(\%(lex|syntax)\{)/" end="/(\%\})/" scheme="c" region00="PairStart" region10="PairEnd" region01="lySymb" region11="lySymb"/>
<!-- flex++ specific -->
         <block start="/^(\%header\{)/" end="/(\%\})/" scheme="c" region00="PairStart" region10="PairEnd" region01="lySymb" region11="lySymb"/>
<!-- start second part -->
         <block start="/^(\%\%)/" end="/^NeVeRUseD$/" scheme="lySecondPart" region01="lySymb"/>
<!-- other Lex/Yacc directives -->
         <block start="/^(\%)(union)\s*\{/" end="/(\})/" scheme="c" region00="PairStart" region10="PairEnd" region01="lyCommentEx" region02="lySymb" region11="lySymb"/>
         <block start="/^(\%)/" end="/\M^[\%\S]/" scheme="lyPerCent" region01="lyCommentEx" region11="lySymb"/>
<!-- flex macro definitions -->
         <block start="/^(\w+)(\s+)?=/" end="/$/" scheme="LexSymbols" region="lyString" region01="lyText"/>
      </scheme>

      <scheme name="lex">
         <inherit scheme="LexYacc">
            <virtual scheme="lyRule" subst-scheme="lyLexRule"/>
         </inherit>
      </scheme>

   </type>
</hrc>
