[gtksourceview] Added NVidia CG language



commit 37930825be8774f80ea8d1a0ea4a111236c7807a
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date:   Tue Jan 5 12:50:52 2010 +0100

    Added NVidia CG language

 gtksourceview/language-specs/Makefile.am  |    1 +
 gtksourceview/language-specs/cg.lang      |  231 +++++++++++++++++++++++++++++
 gtksourceview/language-specs/testfiles.sh |   20 +++
 3 files changed, 252 insertions(+), 0 deletions(-)
---
diff --git a/gtksourceview/language-specs/Makefile.am b/gtksourceview/language-specs/Makefile.am
index f797be6..d6ebf63 100644
--- a/gtksourceview/language-specs/Makefile.am
+++ b/gtksourceview/language-specs/Makefile.am
@@ -8,6 +8,7 @@ LANGUAGES =			\
 	boo.lang		\
 	changelog.lang		\
 	c.lang			\
+	cg.lang			\
 	chdr.lang		\
 	cmake.lang		\
 	cpp.lang		\
diff --git a/gtksourceview/language-specs/cg.lang b/gtksourceview/language-specs/cg.lang
new file mode 100644
index 0000000..0938dea
--- /dev/null
+++ b/gtksourceview/language-specs/cg.lang
@@ -0,0 +1,231 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Authors: Jesse van den Kieboom <jessevdk gnome org>
+ Copyright (C) 2010 Jesse van den Kieboom <jessevdk gnome org>
+
+ 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="cg" _name="CG Shader Language" version="2.0" _section="Sources">
+    <metadata>
+      <property name="globs">*.cg</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="bindings"          _name="Bindings"            map-to="def:special-constant"/>
+        <style id="included-file"     _name="Included File"       map-to="def:string"/>
+        <style id="keyword"           _name="Keyword"             map-to="def:keyword"/>
+        <style id="type"              _name="Data Type"           map-to="def:type"/>
+        <style id="storage-class"     _name="Storage Class"       map-to="def:builtin"/>
+        <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="octal"             _name="Octal number"        map-to="def:base-n-integer"/>
+        <style id="hexadecimal"       _name="Hexadecimal number"  map-to="def:base-n-integer"/>
+        <style id="boolean"           _name="Boolean value"       map-to="def:boolean"/>
+        <style id="swizzle"           _name="Swizzle operator"    map-to="def:operator"/>
+        <style id="function"          _name="Function"            map-to="def:function"/>
+        <style id="builtin"           _name="Builtin"             map-to="def:preprocessor"/>
+    </styles>
+
+    <definitions>
+        <!-- http://en.wikipedia.org/wiki/C_syntax#Strings -->
+        <define-regex id="escaped-character" extended="true">
+            \\(                   # leading backslash
+            [\\\"\'nrtfav\?e] |   # escaped character
+            [0-7]{1,3} |          # one, two, or three octal digits
+            x[0-9A-Fa-f]{0,2}     # 'x' followed by zero, one, or two hex digits
+            )
+        </define-regex>
+
+        <context id="cg" class="no-spell-check">
+            <include>
+                <!-- Comments -->
+                <context id="comment" style-ref="comment" end-at-line-end="true" class="comment" class-disabled="no-spell-check">
+                    <start>//</start>
+                    <include>
+                      <context ref="def:in-line-comment"/>
+                    </include>
+                </context>
+
+                <context id="comment-multiline" style-ref="comment" class="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="include" style-ref="preprocessor">
+                    <match extended="true">
+                            \%{preproc-start}
+                            (include|import)\s*
+                            (".*?"|&lt;.*&gt;)
+                    </match>
+                    <include>
+                        <context id="included-file" sub-pattern="2" style-ref="included-file"/>
+                    </include>
+                </context>
+
+                <!-- http://www.lysator.liu.se/c/ANSI-C-grammar-l.html -->
+                <context id="float" style-ref="floating-point">
+                    <match extended="true">
+                        (?&lt;![\w\.])
+                        ((\.[0-9]+ | [0-9]+\.[0-9]*) ([Ee][+-]?[0-9]*)? |
+                         ([0-9]+[Ee][+-]?[0-9]*))
+                        [fFlL]?
+                        (?![\w\.])
+                    </match>
+                </context>
+
+                <context id="hexadecimal" style-ref="hexadecimal">
+                    <match extended="true">
+                        (?&lt;![\w\.])
+                        0[xX][a-fA-F0-9]+[uUlL]*
+                        (?![\w\.])
+                    </match>
+                </context>
+
+                <context id="octal" style-ref="octal">
+                    <match extended="true">
+                        (?&lt;![\w\.])
+                        0[0-7]+[uUlL]*
+                        (?![\w\.])
+                    </match>
+                </context>
+
+                <context id="decimal" style-ref="decimal">
+                    <match extended="true">
+                        (?&lt;![\w\.])
+                        [0-9]+[uUlL]*
+                        (?![\w\.])
+                    </match>
+                </context>
+
+                <!-- Keywords -->
+                <context id="keywords" style-ref="keyword">
+                    <keyword>break</keyword>
+                    <keyword>case</keyword>
+                    <keyword>continue</keyword>
+                    <keyword>default</keyword>
+                    <keyword>else</keyword>
+                    <keyword>for</keyword>
+                    <keyword>if</keyword>
+                    <keyword>return</keyword>
+                    <keyword>struct</keyword>
+                    <keyword>switch</keyword>
+                    <keyword>while</keyword>
+                </context>
+
+                <context id="types" style-ref="type">
+                    <keyword>bool</keyword>
+                    <keyword>float</keyword>
+                    <keyword>float2</keyword>
+                    <keyword>float3</keyword>
+                    <keyword>float4</keyword>
+                    <keyword>float2x2</keyword>
+                    <keyword>float3x3</keyword>
+                    <keyword>float4x4</keyword>
+                    <keyword>int</keyword>
+                    <keyword>half</keyword>
+                    <keyword>fixed</keyword>
+                    <keyword>void</keyword>
+                    <keyword>sampler1D</keyword>
+                    <keyword>sampler2D</keyword>
+                    <keyword>sampler3D</keyword>
+                    <keyword>samplerRECT</keyword>
+                    <keyword>samplerCUBE</keyword>
+                </context>
+
+                <context id="storage-class" style-ref="storage-class">
+                    <keyword>uniform</keyword>
+                    <keyword>out</keyword>
+                    <keyword>inout</keyword>
+                    <keyword>in</keyword>
+                    <keyword>varying</keyword>
+                </context>
+
+                <context id="bindings" style-ref="bindings">
+                    <keyword>POSITION</keyword>
+                    <keyword>NORMAL</keyword>
+                </context>
+                
+                <context id="color-bindings" style-ref="bindings">
+                    <match extended="true">COLOR[0-3]?</match>
+                </context>
+
+                <context id="texunit-bindings" style-ref="bindings">
+                    <match extended="true">TEXUNIT([0-9]|1[0-5])?</match>
+                </context>
+                 
+                <context id="texcoord-bindings" style-ref="bindings">
+                    <match extended="true">TEXCOORD[0-7]?</match>
+                </context>
+                 
+                <context id="swizzle">
+                    <match extended="true">\.([xyzw]+|[rgba]+)</match>
+                    <include>
+                        <context id="swizzle-operator" sub-pattern="1" style-ref="swizzle"/>
+                    </include>
+                </context>
+                 
+                <!-- C99 booleans -->                
+                <context id="boolean" style-ref="boolean">
+                    <keyword>true</keyword>
+                    <keyword>false</keyword>
+                </context>
+                
+                <context id="builtin">
+                    <match extended="true">
+                        (mul|lit|lerp|saturate|abs|cos|acos|sin|asin|tan|atan|all|any|ceil|clamp|
+                        cosh|cross|degress|determinant|dot|exp|exp2|floor|fmod|frac|frexp|isfinite|
+                        isinf|isnan|ldexp|log|log2|log10|max|min|modf|noise|pow|radians|round|
+                        rsqrt|sign|sincos|sinh|smoothstep|step|sqrt|tanh|transpose|distance|
+                        faceforward|length|normalize|reflect|refract|tex1D|tex2D|tex3D|
+                        tex1Dproj|tex2Dproj|tex3Dproj|texRECT|texRECTproj|texCUBE|texCUBEproj|
+                        ddx|ddy|debug)\s*\(
+                    </match>
+                    <include>
+                        <context id="builtin-name" sub-pattern="1" style-ref="builtin"/>
+                    </include>
+                </context>
+                
+                <context id="function">
+                    <match extended="true">
+                        ([a-zA-Z_][a-zA-Z_0-9]*)\s*\(
+                    </match>
+                    <include>
+                        <context id="function-name" sub-pattern="1" style-ref="function"/>
+                    </include>
+                </context>
+            </include>
+        </context>
+    </definitions>
+</language>
diff --git a/gtksourceview/language-specs/testfiles.sh b/gtksourceview/language-specs/testfiles.sh
index 3732787..ef3aad5 100755
--- a/gtksourceview/language-specs/testfiles.sh
+++ b/gtksourceview/language-specs/testfiles.sh
@@ -80,6 +80,26 @@ void main(void)
 }
 EOFEOF
 
+cat > $dir/file.cg << EOFEOF
+struct OurOutputType
+{
+	float4 position : POSITION;
+	float4 color : COLOR;
+};
+
+OurOutputType
+main(float4           position : POSITION,
+     uniform float4x4 modelViewProj)
+{
+	OurOutputType OUT;
+
+	OUT.position = mul(modelViewProj, position);
+	OUT.color = position;
+
+	return OUT;
+}
+EOFEOF
+
 cat > $dir/file.cu << EOFEOF
 #include "cuMatrix.h"
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]