gcode.lang
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!-- 3 4 Author: Nick Drobchenko<nick@cnc-club.ru> 5 Copyright (C) 2009 Nick Drobchenko<nick@cnc-club.ru> 6 7 This library is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 21 --> 22 <language id="gcode" _name="Gcode" version="2.0" _section="Others"> 23 <metadata> 24 <property name="mimetypes"></property> 25 <property name="globs">*.nc;*.ngc</property> 26 <property name="block-comment-start">(</property> 27 <property name="block-comment-end">)</property> 28 </metadata> 29 30 <styles> 31 <style id="comment" _name="Comment" map-to="def:comment"/> 32 <style id="inline-comment" _name="Inline-Comment" map-to="def:comment"/> 33 <style id="variable" _name="Variable" map-to="def:identifier"/> 34 <style id="flow-control-codes" _name="Flow-control Codes" map-to="def:preprocessor"/> 35 <style id="math" _name="math" map-to="def:identifier"/> 36 <style id="motion" _name="Motion" map-to="def:keyword"/> 37 <style id="parameter" _name="Parameter" map-to="def:keyword"/> 38 <style id="distance-mode" _name="Distance Mode" map-to="def:string"/> 39 <style id="feed-rate-mode" _name="Feed Rate Mode" map-to="def:string"/> 40 <style id="spindle-control" _name="Spindle-Control" map-to="def:error"/> 41 <style id="coolant" _name="Coolant" map-to="def:identifier"/> 42 <style id="tool-length-offset" _name="Tool Length Offset" map-to="def:string"/> 43 <style id="stopping" _name="Stopping" map-to="def:error"/> 44 <style id="units" _name="Units" map-to="def:string"/> 45 <style id="plane-selection" _name="Plane Selection (affects G2, G3, G81...G89, G40...G42)" map-to="def:type"/> 46 <style id="cutter-radius-compensation" _name="Cutter Radius Compensation" map-to="def:string"/> 47 <style id="path-control-mode" _name="Path Control Mode" map-to="def:string"/> 48 <style id="return-mode-in-canned-cycles" _name="Return Mode in Canned Cycles" map-to="def:string"/> 49 <style id="other-modal-codes" _name="Other Modal Codes" map-to="def:type"/> 50 <style id="input-output-codes" _name="Input/Output Codes" map-to="def:string"/> 51 <style id="non-modal-nodes" _name="Non-modal Codes" map-to="def:floating-point"/> 52 <style id="parameter-value" _name="Parameter's value" map-to="def:floating-point"/> 53 <style id="messages" _name="Messages" map-to="def:floating-point"/> 54 55 </styles> 56 <default-regex-options case-sensitive="false"/> 57 58 <definitions> 59 60 <context id="block-comment" style-ref="comment"> 61 <start>\(</start> 62 <end>\)</end> 63 </context> 64 65 <context id="inline-comment" end-at-line-end="true" style-ref="comment"> 66 <start>;</start> 67 </context> 68 69 70 <context id="variable" style-ref="variable"> 71 <match>#([0-9]+|<[a-zA-Z_0-9\-]+>)</match> 72 </context> 73 74 <context id="math" style-ref="math"> 75 <keyword>ATAN|ABS|ACOS|ASIN|COS|EXP|FIX|FUP|ROUND|LN|SIN|SQRT|TAN|MOD|EQ|NE|GT|GE|LT|LE|AND|OR|XOR</keyword> 76 </context> 77 78 <context id="motion" style-ref="motion"> 79 <keyword>G0?[01234]{1}</keyword> 80 <keyword>G8[0-3]</keyword> 81 <keyword>G(73|85|89|33(.1)?|76)</keyword> 82 </context> 83 84 <context id="motion-r" style-ref="motion"> 85 <match>G38\.[2..5]</match> 86 </context> 87 88 <context id="distance-mode" style-ref="distance-mode"> 89 <keyword>G9[01](.1)?</keyword> 90 <keyword>G0?[78]</keyword> 91 </context> 92 93 <context id="feed-rate-mode" style-ref="feed-rate-mode"> 94 <keyword>G9[345]</keyword> 95 </context> 96 97 <context id="spindle-control" style-ref="spindle-control"> 98 <match>M0?[345]|G9[67]</match> 99 100 </context> 101 102 <context id="coolant" style-ref="coolant"> 103 <keyword>M0?[789]</keyword> 104 </context> 105 106 <context id="tool-length-offset" style-ref="tool-length-offset"> 107 <keyword>G43(.1)?</keyword> 108 <keyword>G49</keyword> 109 </context> 110 111 <context id="stopping" style-ref="stopping"> 112 <keyword>M0?[012]</keyword> 113 <keyword>M30</keyword> 114 <keyword>M60</keyword> 115 </context> 116 117 <context id="units" style-ref="units"> 118 <keyword>G2[01]</keyword> 119 </context> 120 121 <context id="plane-selection" style-ref="plane-selection"> 122 <keyword>G1[789]</keyword> 123 </context> 124 125 <context id="cutter-radius-compensation" style-ref="cutter-radius-compensation"> 126 <keyword>G40</keyword> 127 <keyword>G4[12](.1)?</keyword> 128 </context> 129 130 <context id="path-control-mode" style-ref="path-control-mode"> 131 <keyword>G61(.1)?</keyword> 132 <keyword>G64</keyword> 133 </context> 134 135 <context id="return-mode-in-canned-cycles" style-ref="return-mode-in-canned-cycles"> 136 <keyword>G9[89]</keyword> 137 </context> 138 139 <context id="other-modal-codes-r" style-ref="other-modal-codes"> 140 <match>[FST]</match> 141 </context> 142 143 <context id="other-modal-codes" style-ref="other-modal-codes"> 144 <keyword>M5[0-8]</keyword> 145 <keyword>G5[4-9]</keyword> 146 <keyword>G59(.[123])?</keyword> 147 </context> 148 149 <context id="input-output-codes" style-ref="input-output-codes"> 150 <keyword>M6[2345678]</keyword> 151 </context> 152 153 <context id="non-modal-nodes" style-ref="non-modal-nodes"> 154 <keyword>M6</keyword> 155 <keyword>M06</keyword> 156 <keyword>G10</keyword> 157 <keyword>G28(.1)?</keyword> 158 <keyword>G30(.1)?</keyword> 159 <keyword>G53</keyword> 160 <keyword>G92(.[123])?</keyword> 161 </context> 162 163 <context id="non-modal-nodes-m" style-ref="non-modal-nodes"> 164 <match>M1[1..9]{2}</match> 165 </context> 166 167 <context id="non-modal-nodes-g10" style-ref="non-modal-nodes"> 168 <match>G10\s*L[12]0?</match> 169 </context> 170 171 <context id="messages" style-ref="messages"> 172 <match>^MSG|DEBUG|PRINT</match> 173 </context> 174 175 176 <context id="flow-control-codes" style-ref="flow-control-codes"> 177 <keyword>o[ \t]*\d+</keyword> 178 <keyword>sub|endsub|while|endwhile|if|else|endif|do|call|break|continue|return</keyword> 179 </context> 180 181 <context id="parameter" style-ref="parameter"> 182 <match>(?<![a-zA-Z])[XYZABCUVWPQRIJKHLED]{1}</match> 183 </context> 184 185 <context id="gcode"> 186 <include> 187 <context ref="block-comment" /> 188 <context ref="inline-comment" /> 189 <context ref="variable" /> 190 <context ref="math" /> 191 <context ref="motion" /> 192 <context ref="motion-r" /> 193 <context ref="distance-mode" /> 194 <context ref="feed-rate-mode" /> 195 <context ref="spindle-control" /> 196 <context ref="coolant" /> 197 <context ref="tool-length-offset" /> 198 <context ref="stopping" /> 199 <context ref="units" /> 200 <context ref="plane-selection" /> 201 <context ref="cutter-radius-compensation" /> 202 <context ref="path-control-mode" /> 203 <context ref="return-mode-in-canned-cycles" /> 204 <context ref="other-modal-codes" /> 205 <context ref="flow-control-codes" /> 206 <context ref="input-output-codes" /> 207 <context ref="non-modal-nodes" /> 208 <context ref="non-modal-nodes-m" /> 209 <context ref="non-modal-nodes-g10" /> 210 <context ref="messages" /> 211 <context ref="parameter" /> 212 <context ref="other-modal-codes-r" /> 213 </include> 214 </context> 215 </definitions> 216 </language>