1<?xml version="1.0" encoding="UTF-8"?> 2<!-- 3 4 This file is part of GtkSourceView 5 6 Authors: Jesse van den Kieboom <jessevdk@gnome.org> 7 Copyright (C) 2010 Jesse van den Kieboom <jessevdk@gnome.org> 8 9 GtkSourceView is free software; you can redistribute it and/or 10 modify it under the terms of the GNU Lesser General Public 11 License as published by the Free Software Foundation; either 12 version 2.1 of the License, or (at your option) any later version. 13 14 GtkSourceView is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 Lesser General Public License for more details. 18 19 You should have received a copy of the GNU Lesser General Public License 20 along with this library; if not, see <http://www.gnu.org/licenses/>. 21 22--> 23<language id="cg" _name="CG Shader Language" version="2.0" _section="Source"> 24 <metadata> 25 <property name="globs">*.cg</property> 26 <property name="line-comment-start">//</property> 27 <property name="block-comment-start">/*</property> 28 <property name="block-comment-end">*/</property> 29 </metadata> 30 31 <styles> 32 <style id="comment" name="Comment" map-to="def:comment"/> 33 <style id="error" name="Error" map-to="def:error"/> 34 <style id="preprocessor" name="Preprocessor" map-to="def:preprocessor"/> 35 <style id="bindings" name="Bindings" map-to="def:special-constant"/> 36 <style id="included-file" name="Included File" map-to="def:string"/> 37 <style id="keyword" name="Keyword" map-to="def:keyword"/> 38 <style id="type" name="Data Type" map-to="def:type"/> 39 <style id="storage-class" name="Storage Class" map-to="def:builtin"/> 40 <style id="escaped-character" name="Escaped Character" map-to="def:special-char"/> 41 <style id="floating-point" name="Floating point number" map-to="def:floating-point"/> 42 <style id="decimal" name="Decimal number" map-to="def:decimal"/> 43 <style id="octal" name="Octal number" map-to="def:base-n-integer"/> 44 <style id="hexadecimal" name="Hexadecimal number" map-to="def:base-n-integer"/> 45 <style id="boolean" name="Boolean value" map-to="def:boolean"/> 46 <style id="swizzle" name="Swizzle operator" map-to="def:operator"/> 47 <style id="function" name="Function" map-to="def:function"/> 48 <style id="builtin" name="Builtin" map-to="def:preprocessor"/> 49 </styles> 50 51 <definitions> 52 <!-- http://en.wikipedia.org/wiki/C_syntax#Strings --> 53 <define-regex id="escaped-character" extended="true"> 54 \\( # leading backslash 55 [\\\"\'nrtfav\?e] | # escaped character 56 [0-7]{1,3} | # one, two, or three octal digits 57 x[0-9A-Fa-f]{0,2} # 'x' followed by zero, one, or two hex digits 58 ) 59 </define-regex> 60 61 <context id="cg" class="no-spell-check"> 62 <include> 63 <!-- Comments --> 64 <context id="comment" style-ref="comment" end-at-line-end="true" class="comment" class-disabled="no-spell-check"> 65 <start>//</start> 66 <include> 67 <context ref="def:in-line-comment"/> 68 </include> 69 </context> 70 71 <context id="comment-multiline" style-ref="comment" class="comment" class-disabled="no-spell-check"> 72 <start>/\*</start> 73 <end>\*/</end> 74 <include> 75 <context ref="def:in-comment"/> 76 </include> 77 </context> 78 79 <context id="close-comment-outside-comment" style-ref="error"> 80 <match>\*/(?!\*)</match> 81 </context> 82 83 <!-- Preprocessor --> 84 <define-regex id="preproc-start">^\s*#\s*</define-regex> 85 86 <context id="include" style-ref="preprocessor"> 87 <match extended="true"> 88 \%{preproc-start} 89 (include|import)\s* 90 (".*?"|<.*>) 91 </match> 92 <include> 93 <context id="included-file" sub-pattern="2" style-ref="included-file"/> 94 </include> 95 </context> 96 97 <!-- http://www.lysator.liu.se/c/ANSI-C-grammar-l.html --> 98 <context id="float" style-ref="floating-point"> 99 <match extended="true"> 100 (?<![\w\.]) 101 ((\.[0-9]+ | [0-9]+\.[0-9]*) ([Ee][+-]?[0-9]*)? | 102 ([0-9]+[Ee][+-]?[0-9]*)) 103 [fFlL]? 104 (?![\w\.]) 105 </match> 106 </context> 107 108 <context id="hexadecimal" style-ref="hexadecimal"> 109 <match extended="true"> 110 (?<![\w\.]) 111 0[xX][a-fA-F0-9]+[uUlL]* 112 (?![\w\.]) 113 </match> 114 </context> 115 116 <context id="octal" style-ref="octal"> 117 <match extended="true"> 118 (?<![\w\.]) 119 0[0-7]+[uUlL]* 120 (?![\w\.]) 121 </match> 122 </context> 123 124 <context id="decimal" style-ref="decimal"> 125 <match extended="true"> 126 (?<![\w\.]) 127 [0-9]+[uUlL]* 128 (?![\w\.]) 129 </match> 130 </context> 131 132 <!-- Keywords --> 133 <context id="keywords" style-ref="keyword"> 134 <keyword>break</keyword> 135 <keyword>case</keyword> 136 <keyword>continue</keyword> 137 <keyword>default</keyword> 138 <keyword>else</keyword> 139 <keyword>for</keyword> 140 <keyword>if</keyword> 141 <keyword>return</keyword> 142 <keyword>struct</keyword> 143 <keyword>switch</keyword> 144 <keyword>while</keyword> 145 </context> 146 147 <context id="types" style-ref="type"> 148 <keyword>bool</keyword> 149 <keyword>float</keyword> 150 <keyword>float2</keyword> 151 <keyword>float3</keyword> 152 <keyword>float4</keyword> 153 <keyword>float2x2</keyword> 154 <keyword>float3x3</keyword> 155 <keyword>float4x4</keyword> 156 <keyword>int</keyword> 157 <keyword>half</keyword> 158 <keyword>fixed</keyword> 159 <keyword>void</keyword> 160 <keyword>sampler1D</keyword> 161 <keyword>sampler2D</keyword> 162 <keyword>sampler3D</keyword> 163 <keyword>samplerRECT</keyword> 164 <keyword>samplerCUBE</keyword> 165 </context> 166 167 <context id="storage-class" style-ref="storage-class"> 168 <keyword>uniform</keyword> 169 <keyword>out</keyword> 170 <keyword>inout</keyword> 171 <keyword>in</keyword> 172 <keyword>varying</keyword> 173 </context> 174 175 <context id="bindings" style-ref="bindings"> 176 <keyword>POSITION</keyword> 177 <keyword>NORMAL</keyword> 178 </context> 179 180 <context id="color-bindings" style-ref="bindings"> 181 <match extended="true">COLOR[0-3]?</match> 182 </context> 183 184 <context id="texunit-bindings" style-ref="bindings"> 185 <match extended="true">TEXUNIT([0-9]|1[0-5])?</match> 186 </context> 187 188 <context id="texcoord-bindings" style-ref="bindings"> 189 <match extended="true">TEXCOORD[0-7]?</match> 190 </context> 191 192 <context id="swizzle"> 193 <match extended="true">\.([xyzw]+|[rgba]+)</match> 194 <include> 195 <context id="swizzle-operator" sub-pattern="1" style-ref="swizzle"/> 196 </include> 197 </context> 198 199 <!-- C99 booleans --> 200 <context id="boolean" style-ref="boolean"> 201 <keyword>true</keyword> 202 <keyword>false</keyword> 203 </context> 204 205 <context id="builtin"> 206 <match extended="true"> 207 (mul|lit|lerp|saturate|abs|cos|acos|sin|asin|tan|atan|all|any|ceil|clamp| 208 cosh|cross|degress|determinant|dot|exp|exp2|floor|fmod|frac|frexp|isfinite| 209 isinf|isnan|ldexp|log|log2|log10|max|min|modf|noise|pow|radians|round| 210 rsqrt|sign|sincos|sinh|smoothstep|step|sqrt|tanh|transpose|distance| 211 faceforward|length|normalize|reflect|refract|tex1D|tex2D|tex3D| 212 tex1Dproj|tex2Dproj|tex3Dproj|texRECT|texRECTproj|texCUBE|texCUBEproj| 213 ddx|ddy|debug)\s*\( 214 </match> 215 <include> 216 <context id="builtin-name" sub-pattern="1" style-ref="builtin"/> 217 </include> 218 </context> 219 220 <context id="function"> 221 <match extended="true"> 222 ([a-zA-Z_][a-zA-Z_0-9]*)\s*\( 223 </match> 224 <include> 225 <context id="function-name" sub-pattern="1" style-ref="function"/> 226 </include> 227 </context> 228 </include> 229 </context> 230 </definitions> 231</language> 232