2007-07-09 05:56:22 -05:00

336 lines
11 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!--
Author: Archit Baweja <bighead@users.sourceforge.net>
Copyright (C) 2004 Archit Baweja <bighead@users.sourceforge.net>
Copyright (C) 2005 Michael Witrant <mike@lepton.fr>
Copyright (C) 2006 Gabriel Bauman <gbauman@gmail.com>
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-->
<language id="ruby" _name="Ruby" version="2.0" _section="Scripts">
<metadata>
<property name="mimetypes">application/x-ruby;text/x-ruby</property>
<property name="globs">*.rb</property>
<property name="line-comment-start">#</property>
</metadata>
<styles>
<style id="comment" _name="Comment" map-to="def:comment"/>
<style id="attribute-definition" _name="Attribute Definition" map-to="def:data-type"/>
<style id="module-handler" _name="Module handler" map-to="def:preprocessor"/>
<style id="keyword" _name="Keyword" map-to="def:keyword"/>
<style id="floating-point" _name="Floating point" map-to="def:floating-point"/>
<style id="decimal" _name="Decimal" map-to="def:decimal"/>
<style id="base-n-integer" _name="Base-N integer" map-to="def:base-n-integer"/>
<style id="numeric-literal" _name="Numeric literal" map-to="def:base-n-integer"/>
<style id="string" _name="String" map-to="def:string"/>
<style id="builtin" _name="Builtin" map-to="def:data-type"/>
<style id="constant" _name="Constant" map-to="def:data-type"/>
<style id="variable" _name="Variable" map-to="def:function"/>
</styles>
<definitions>
<context id="multiline-comment" style-ref="comment">
<start>^=begin</start>
<end>^=end</end>
<include>
<context ref="def:escape"/>
<context ref="def:line-continue"/>
<context ref="def:in-comment"/>
</include>
</context>
<context id="attribute-definitions" style-ref="attribute-definition">
<keyword>attr</keyword>
<keyword>attr_writer</keyword>
<keyword>attr_reader</keyword>
<keyword>attr_accessor</keyword>
</context>
<context id="definitions" style-ref="keyword">
<keyword>alias</keyword>
<keyword>class</keyword>
<keyword>module</keyword>
<keyword>def</keyword>
<keyword>undef</keyword>
</context>
<context id="pseudo-variables" style-ref="variable">
<keyword>self</keyword>
<keyword>super</keyword>
<keyword>nil</keyword>
<keyword>false</keyword>
<keyword>true</keyword>
<keyword>__FILE__</keyword>
<keyword>__LINE__</keyword>
</context>
<context id="module-handlers" style-ref="module-handler">
<keyword>require</keyword>
<keyword>include</keyword>
<keyword>load</keyword>
</context>
<context id="keywords" style-ref="keyword">
<keyword>BEGIN</keyword>
<keyword>END</keyword>
<keyword>and</keyword>
<keyword>begin</keyword>
<keyword>break</keyword>
<keyword>case</keyword>
<keyword>catch</keyword>
<keyword>defined?</keyword>
<keyword>do</keyword>
<keyword>else</keyword>
<keyword>elsif</keyword>
<keyword>end</keyword>
<keyword>ensure</keyword>
<keyword>for</keyword>
<keyword>if</keyword>
<keyword>in</keyword>
<keyword>next</keyword>
<keyword>not</keyword>
<keyword>or</keyword>
<keyword>private</keyword>
<keyword>protected</keyword>
<keyword>public</keyword>
<keyword>redo</keyword>
<keyword>rescue</keyword>
<keyword>retry</keyword>
<keyword>return</keyword>
<keyword>then</keyword>
<keyword>throw</keyword>
<keyword>unless</keyword>
<keyword>until</keyword>
<keyword>when</keyword>
<keyword>while</keyword>
<keyword>yield</keyword>
</context>
<context id="builtins" style-ref="builtin">
<keyword>Array</keyword>
<keyword>Bignum</keyword>
<keyword>Binding</keyword>
<keyword>Class</keyword>
<keyword>Continuation</keyword>
<keyword>Dir</keyword>
<keyword>Exception</keyword>
<keyword>FalseClass</keyword>
<keyword>File::Stat</keyword>
<keyword>File</keyword>
<keyword>Fixnum</keyword>
<keyword>Float</keyword>
<keyword>Hash</keyword>
<keyword>Integer</keyword>
<keyword>IO</keyword>
<keyword>MatchData</keyword>
<keyword>Method</keyword>
<keyword>Module</keyword>
<keyword>NilClass</keyword>
<keyword>Numeric</keyword>
<keyword>Object</keyword>
<keyword>Proc</keyword>
<keyword>Range</keyword>
<keyword>Regexp</keyword>
<keyword>String</keyword>
<keyword>Struct::Tms</keyword>
<keyword>Struct</keyword>
<keyword>Symbol</keyword>
<keyword>Symbol</keyword>
<keyword>ThreadGroup</keyword>
<keyword>Thread</keyword>
<keyword>Time</keyword>
<keyword>TrueClass</keyword>
</context>
<context id="class-variables" style-ref="variable">
<match>@@[a-zA-Z_][a-zA-Z0-9_]*</match>
</context>
<context id="instance-variables" style-ref="variable">
<match>@[a-zA-Z_][a-zA-Z0-9_]*</match>
</context>
<context id="global-variables" style-ref="variable">
<match>\$[a-zA-Z_][a-zA-Z0-9_]*</match>
</context>
<context id="predefined-variables" style-ref="variable">
<match>\$(-[a-zA-Z]|\pP)</match>
</context>
<context id="symbols" style-ref="string">
<match>(?&lt;!:):[a-zA-Z0-9_]+</match>
</context>
<context id="regexp-variables" style-ref="variable">
<match>\$[1-9][0-9]*</match>
</context>
<context id="constants" style-ref="constant">
<match>(::)?\b[A-Z][A-Za-z0-9_]*\b</match>
</context>
<define-regex id="float" extended="true">
( (\d+)?\.\d+ | \d+\. ) |
( (\d+|(\d+)?\.\d+|\d+\.)[eE][+-]?\d+ )
</define-regex>
<context id="float" style-ref="floating-point">
<match>(?&lt;![\w\.])\%{float}(?![\w\.])</match>
</context>
<context id="decimal" style-ref="decimal">
<match>(?&lt;![\w\.])([1-9][0-9]*|0)[lL]?(?![\w\.])</match>
</context>
<context id="octal" style-ref="base-n-integer">
<match>(?&lt;![\w\.])0[0-7]+[lL]?(?![\w\.])</match>
</context>
<context id="hex" style-ref="base-n-integer">
<match>(?&lt;![\w\.])0[xX][0-9A-Fa-f]+[lL]?(?![\w\.])</match>
</context>
<context id="numeric-literal" style-ref="numeric-literal">
<match>\?((\\[MC]-){1,2}|\\?)\S</match>
</context>
<!-- in double quotes and backticks -->
<context id="simple-interpolation">
<start>#</start>
<end></end>
<include>
<context ref="class-variables"/>
<context ref="instance-variables"/>
<context ref="global-variables"/>
<context ref="predefined-variables"/>
</include>
</context>
<!-- in double quotes and backticks -->
<!-- FIXME: really would like for the syntax highlight to go back
to none here, as any ruby code could go here -->
<context id="complex-interpolation">
<start>#{</start>
<end>}</end>
<include>
<context ref="ruby"/>
</include>
</context>
<!-- ruby strings do not end at line end,
so we cannot use def:string
(parts lifted from perl.lang) -->
<context id="double-quoted-string" style-ref="string">
<start>"</start>
<end>"</end>
<include>
<context ref="def:escape"/>
<context ref="def:line-continue"/>
<context ref="complex-interpolation"/>
<context ref="simple-interpolation"/>
</include>
</context>
<context id="single-quoted-string" style-ref="string">
<start>'</start>
<end>'</end>
<include>
<context ref="def:escape"/>
<context ref="def:line-continue"/>
</include>
</context>
<context id="backtick-quoted-string" style-ref="string">
<start>`</start>
<end>`</end>
<include>
<context ref="def:escape"/>
<context ref="def:line-continue"/>
<context ref="complex-interpolation"/>
<context ref="simple-interpolation"/>
</include>
</context>
<context id="heredoc-string" style-ref="string" style-inside="true">
<start>&lt;&lt;(\w+)</start>
<end>\%{1@start}</end>
<include>
<context ref="def:escape"/>
<context ref="def:line-continue"/>
<context ref="complex-interpolation"/>
<context ref="simple-interpolation"/>
</include>
</context>
<context id="heredoc-single-quoted-string" style-ref="string" style-inside="true">
<start>&lt;&lt;'(\w+)'</start>
<end>\%{1@start}</end>
<include>
<context ref="def:escape"/>
<context ref="def:line-continue"/>
</include>
</context>
<context id="heredoc-double-quoted-string" style-ref="string" style-inside="true">
<start>&lt;&lt;"(\w+)"</start>
<end>\%{1@start}</end>
<include>
<context ref="def:escape"/>
<context ref="def:line-continue"/>
<context ref="complex-interpolation"/>
<context ref="simple-interpolation"/>
</include>
</context>
<context id="ruby">
<include>
<context ref="def:shebang"/>
<context ref="def:shell-like-comment"/>
<context ref="multiline-comment"/>
<context ref="heredoc-string"/>
<context ref="heredoc-single-quoted-string"/>
<context ref="heredoc-double-quoted-string"/>
<context ref="double-quoted-string"/>
<context ref="single-quoted-string"/>
<context ref="backtick-quoted-string"/>
<context ref="attribute-definitions"/>
<context ref="definitions"/>
<context ref="pseudo-variables"/>
<context ref="module-handlers"/>
<context ref="keywords"/>
<context ref="builtins"/>
<context ref="class-variables"/>
<context ref="instance-variables"/>
<context ref="global-variables"/>
<context ref="predefined-variables"/>
<context ref="symbols"/>
<context ref="regexp-variables"/>
<context ref="constants"/>
<context ref="float"/>
<context ref="decimal"/>
<context ref="octal"/>
<context ref="hex"/>
<context ref="numeric-literal"/>
</include>
</context>
</definitions>
</language>