<?xml version="1.0" encoding="UTF-8"?>
<!--

 Authors: Oscar Torrent Artero, Joseba García Etxebarria
 Copyright (C) 2009 Oscar Torrent Artero <q2dg@yahoo.es>
 Copyright (C) 2010 Joseba García Etxebarria <joseba.gar@gmail.com>

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Library General Public
 License as published by the Free Software Foundation; either
 version 2 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Library General Public License for more details.

 You should have received a copy of the GNU Library General Public
 License along with this library; if not, write to the
 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.

-->
<language id="bennugd" _name="BennuGD" version="2.0" _section="Sources">
  <metadata>
    <property name="globs">*.prg</property>
    <property name="line-comment-start">//</property>
    <property name="block-comment-start">/*</property>
    <property name="block-comment-end">*/</property>
  </metadata>

  <styles>
    <style id="comment"           _name="Comment"               map-to="def:comment"/>
    <style id="error"             _name="Error"                 map-to="def:error"/>
    <style id="preprocessor"      _name="Preprocessor"          map-to="def:preprocessor"/>
    <style id="identifier"        _name="Identifier"            map-to="def:identifier"/>
    <style id="operator"          _name="Operator"              map-to="def:operator"/>
    <style id="keywords"          _name="Keyword"               map-to="def:keyword"/>
    <style id="types"             _name="Data Type"             map-to="def:type"/>
    <style id="escaped-character" _name="Escaped Character"     map-to="def:special-char"/>
    <style id="floating-point"    _name="Floating point number" map-to="def:floating-point"/>
    <style id="decimal"           _name="Decimal number"        map-to="def:decimal"/>
    <style id="hexadecimal"       _name="Hexadecimal number"    map-to="def:base-n-integer"/>
    <style id="boolean"           _name="Boolean value"         map-to="def:boolean"/>
    <style id="string"            _name="String"                map-to="def:string"/>
    <style id="char"              _name="Character"             map-to="def:character"/>
  </styles>

  <default-regex-options case-sensitive="false" />

  <definitions>

    <define-regex id="symbolchar">[-!+\\|=:&amp;&gt;&lt;]</define-regex>

    <define-regex id="escaped-character" extended="true">
      \\(             # leading backslash
      [\\\"\'nrbtfav\?] |   # escaped character
      [0-7]{1,3} |          # one, two, or three octal digits
      x[0-9A-Fa-f]+         # 'x' followed by hex digits
      )
    </define-regex>

    <!--Comments -->
    <context id="comment" style-ref="comment" end-at-line-end="true" class-disabled="no-spell-check">
      <start>//</start>
      <include>
        <context ref="def:in-line-comment"/>
      </include>
    </context>

    <context id="comment-multiline" style-ref="comment" class-disabled="no-spell-check">
      <start>/\*</start>
      <end>\*/</end>
      <include>
        <context ref="def:in-comment"/>
      </include>
    </context>

    <context id="close-comment-outside-comment" style-ref="error">
      <match>\*/(?!\*)</match>
    </context>

    <!--Preprocessor -->
    <define-regex id="preproc-start">^\s*#\s*</define-regex>
    <context id="preprocessor" style-ref="preprocessor" end-at-line-end="true">
      <start extended="true">
        \%{preproc-start}
        (define|if(n?def)?|else|elsif|endif)
        \b
      </start>
      <include>
        <context ref="def:line-continue" ignore-style="true"/>
        <context ref="string" ignore-style="true"/>
        <context ref="comment"/>
        <context ref="comment-multiline"/>
      </include>
    </context>

    <!-- Different data-types -->
    <context id="escaped-character" style-ref="escaped-character">
      <match>\%{escaped-character}</match>
    </context>
    
    <context id="string" style-ref="string" end-at-line-end="true">
      <start>L?"</start>
      <end>"</end>
      <include>
        <context ref="escaped-character"/>
        <context ref="def:line-continue"/>
      </include>
    </context>
    
    <context id="char" style-ref="char">
      <match>L?'(\%{escaped-character}|.)'</match>
    </context>
    
    <context id="boolean" style-ref="boolean">
      <keyword>false</keyword>
      <keyword>true</keyword>
    </context>
    
    <context id="float" style-ref="floating-point">
      <match extended="true">
        (?&lt;![\w\.])
        ([0-9]+[Ee][+-]?[0-9]+ |
        ([0-9]*\.[0-9]+ | [0-9]+\.[0-9]*)([Ee][+-]?[0-9]+)?)
        (?![\w\.])
      </match>
    </context>
    
    <context id="decimal-number" style-ref="decimal">
      <match extended="true">
         (?&lt;![\w\.])
         [+-]?([1-9][0-9]*|0)
         (?![\w\.])
       </match>
    </context>
    
    <context id="hexadecimal-number" style-ref="hexadecimal">
      <match extended="true">
         (?&lt;![\w\.])
         [+-]?0x[0-9a-fA-F]+
         (?![\w\.])
      </match>
    </context>
    
    <context id="array-operators" style-ref="identifier">
      <match>(\[|\])</match>
    </context>

    <!--Keywords --> 
    <context id="keywords" style-ref="keywords">
      <keyword>begin</keyword>
      <keyword>break</keyword>
      <keyword>call</keyword> 
      <keyword>case</keyword>
      <keyword>clone</keyword> 
      <keyword>const</keyword> 
      <keyword>continue</keyword>
      <keyword>debug</keyword> 
      <keyword>declare</keyword> 
      <keyword>default</keyword> 
      <keyword>dup</keyword> 
      <keyword>elif</keyword> 
      <keyword>else</keyword> 
      <keyword>elseif</keyword> 
      <keyword>elsif</keyword> 
      <keyword>end</keyword> 
      <keyword>error</keyword> 
      <keyword>exit</keyword>
      <keyword>for</keyword> 
      <keyword>frame</keyword> 
      <keyword>from</keyword> 
      <keyword>function</keyword>
      <keyword>global</keyword> 
      <keyword>goto</keyword>
      <keyword>if</keyword> 
      <keyword>import</keyword> 
      <keyword>include</keyword> 
      <keyword>jmp</keyword>
      <keyword>local</keyword> 
      <keyword>loop</keyword>
      <keyword>mod</keyword> 
      <keyword>mouse</keyword>
      <keyword>next</keyword>
      <keyword>offset</keyword> 
      <keyword>on</keyword> 
      <keyword>onerror</keyword> 
      <keyword>onexit</keyword>
      <keyword>private</keyword> 
      <keyword>process</keyword> 
      <keyword>program</keyword> 
      <keyword>public</keyword>
      <keyword>repeat</keyword> 
      <keyword>resume</keyword> 
      <keyword>return</keyword>
      <keyword>sizeof</keyword> 
      <keyword>step</keyword> 
      <keyword>switch</keyword>
      <keyword>to</keyword>
      <keyword>until</keyword>
      <keyword>while</keyword>
    </context>

    <context id="globals" style-ref="keywords">
      <keyword>argc</keyword>
      <keyword>argv</keyword>
      <keyword>os_id</keyword>
    </context>
    
    <context id="locals" style-ref="keywords">
      <keyword>bigbro</keyword>
      <keyword>father</keyword>
      <keyword>frame_percent</keyword>
      <keyword>id</keyword>
      <keyword>process_type</keyword>
      <keyword>reserved</keyword>
      <keyword>reserved.frame_percent</keyword>
      <keyword>reserved.process_type</keyword>
      <keyword>reserved.saved_priority</keyword>
      <keyword>reserved.saved_status</keyword>
      <keyword>reserved.status</keyword>
      <keyword>saved_priority</keyword>
      <keyword>saved_status</keyword>
      <keyword>smallbro</keyword>
      <keyword>status</keyword>
      <keyword>son</keyword>
    </context>

    <context id="textoperators" style-ref="operator" extend-parent="false">
      <keyword>and</keyword>
      <keyword>band</keyword>
      <keyword>offset</keyword>
      <keyword>bnot</keyword>
      <keyword>bor</keyword>
      <keyword>bxor</keyword>
      <keyword>mod</keyword>
      <keyword>not</keyword>
      <keyword>or</keyword>
      <keyword>xor</keyword>
    </context>

    <context id="operators" style-ref="operator" extend-parent="false">
      <prefix>(?&lt;!\%{symbolchar})</prefix>
      <suffix>(?!\%{symbolchar})</suffix>
      <keyword>==</keyword>
      <keyword>!=</keyword>
      <keyword>!</keyword>
      <keyword>&lt;</keyword>
      <keyword>&gt;</keyword>
      <keyword>&lt;=</keyword>
      <keyword>&gt;=</keyword>
      <keyword>&amp;&amp;</keyword>
      <keyword>&amp;</keyword>
      <keyword>=</keyword>
      <keyword>||</keyword>
      <keyword>|</keyword>
      <keyword>^^</keyword>
      <keyword>^</keyword>
    </context>

    <context id="types" style-ref="types">
      <keyword>byte</keyword>
      <keyword>char</keyword> 
      <keyword>dword</keyword>
      <keyword>float</keyword> 
      <keyword>int</keyword>
      <keyword>pointer</keyword> 
      <keyword>short</keyword> 
      <keyword>signed</keyword> 
      <keyword>string</keyword> 
      <keyword>struct</keyword> 
      <keyword>type</keyword>
      <keyword>unsigned</keyword>
      <keyword>word</keyword>  
    </context>

    <context id="commonmacros" style-ref="preprocessor">
      <keyword>COMPILER_VERSION</keyword>
      <keyword>__DATE__</keyword>
      <keyword>__FILE__</keyword>
      <keyword>__LINE__</keyword>
      <keyword>max_byte</keyword>
      <keyword>max_dword</keyword>
      <keyword>max_int</keyword>
      <keyword>max_sbyte</keyword>
      <keyword>max_short</keyword>
      <keyword>max_word</keyword>
      <keyword>min_byte</keyword>
      <keyword>min_dword</keyword>
      <keyword>min_int</keyword>
      <keyword>min_sbyte</keyword>
      <keyword>min_short</keyword>
      <keyword>min_word</keyword>
      <keyword>null</keyword>
      <keyword>os_beos</keyword>
      <keyword>os_bsd</keyword>
      <keyword>os_dc</keyword>
      <keyword>os_gp32</keyword>
      <keyword>os_linux</keyword>
      <keyword>os_macos</keyword>
      <keyword>os_win32</keyword>
      <keyword>status_dead</keyword>
      <keyword>status_frozen</keyword>
      <keyword>status_killed</keyword>
      <keyword>status_running</keyword>
      <keyword>status_sleeping</keyword>
      <keyword>status_waiting</keyword>
      <keyword>__TIME__ </keyword>
      <keyword>__VERSION__</keyword>
    </context>     

    <context id="bennugd" class="no-spell-check">
      <include>
        <context ref="comment"/>
        <context ref="comment-multiline"/>
        <context ref="close-comment-outside-comment"/>
        <context ref="preprocessor"/>
        <context ref="string"/>
        <context ref="char"/>
        <context ref="boolean"/>
        <context ref="float"/>
        <context ref="decimal-number"/>
        <context ref="hexadecimal-number"/>
        <context ref="array-operators"/>
        <context ref="keywords"/>
        <context ref="globals"/>
        <context ref="locals"/>
        <context ref="textoperators"/>
        <context ref="operators"/>
        <context ref="types"/>
        <context ref="commonmacros"/>
      </include>
    </context>

  </definitions>
</language>

