Debian Codegraph @

data/syntax/gcode.xml

raw
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE language
3 [
4 <!--
5 single . as number
6 1.2. is not a number (two .)
7 spaces are ignored (1 2 . 3 4 is a valid number)
8 -->
9 <!ENTITY number "&cmd_number;|[.]\s*(\d[\s\d]*+)?(?![.])">
10 <!ENTITY cmd_number "\d[\s\d]*+([.][\s\d]*+)?(?![.])">
11 <!ENTITY int "\d[\s\d]*+(?![.])">
12 ]>
13 <!--
14
15 G-code syntax highlighting for KatePart
16
17 Copy this file to : ~/.kde/share/apps/katepart/syntax/
18
19 Copyright © 2016 by Fernand Veilleux ([email protected])
20
21 This library is free software; you can redistribute it and/or
22 modify it under the terms of the GNU Library General Public
23 License as published by the Free Software Foundation; either
24 version 2 of the License, or (at your option) any later version.
25
26 This library is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 Library General Public License for more details.
30
31 You should have received a copy of the GNU Library General Public
32 License along with this library; if not, write to the
33 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
34 Boston, MA 02110-1301, USA.
35
36 -->
37 <language name="G-Code"
38 version="12"
39 kateversion="5.0"
40 section="3D"
41 extensions="*.ngc;*.gcode"
42 mimetype="text/ngc"
43 author="Fernand Veilleux ([email protected])"
44 license="LGPLv2+">
45
46 <!-- https://reprap.org/wiki/G-code -->
47 <!-- http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Example_G-Code_Programs -->
48 <!-- https://docs.duet3d.com/en/User_manual/Reference/Gcode_meta_commands -->
49
50 <highlighting>
51 <list name="operators">
52 <item>and</item>
53 <item>or</item>
54 <item>xor</item>
55 <item>eq</item>
56 <item>ne</item>
57 <item>gt</item>
58 <item>ge</item>
59 <item>lt</item>
60 <item>le</item>
61 <item>mod</item>
62 </list>
63
64 <list name="functions">
65 <item>abs</item>
66 <item>acos</item>
67 <item>asin</item>
68 <item>atan</item>
69 <item>atan2</item>
70 <item>cos</item>
71 <item>datetime</item>
72 <item>degrees</item>
73 <item>exists</item>
74 <item>exp</item>
75 <item>fix</item>
76 <item>floor</item>
77 <item>fup</item>
78 <item>isnan</item>
79 <item>ln</item>
80 <item>max</item>
81 <item>min</item>
82 <item>mod</item>
83 <item>radians</item>
84 <item>random</item>
85 <item>round</item>
86 <item>sin</item>
87 <item>sqrt</item>
88 <item>tan</item>
89 </list>
90
91 <list name="o_sub">
92 <item>sub</item>
93 <item>endsub</item>
94 <item>call</item>
95 <item>return</item>
96 </list>
97
98 <list name="keyword">
99 <item>do</item>
100 <item>while</item>
101 <item>endwhile</item>
102 <item>repeat</item>
103 <item>endrepeat</item>
104 <item>break</item>
105 <item>continue</item>
106 <item>if</item>
107 <item>elseif</item>
108 <item>else</item>
109 <item>endif</item>
110 <!-- meta command -->
111 <item>abort</item>
112 <item>echo</item>
113 <item>var</item>
114 <item>global</item>
115 <item>set</item>
116 </list>
117
118 <list name="named constants">
119 <item>false</item>
120 <item>iterations</item>
121 <item>line</item>
122 <item>null</item>
123 <item>pi</item>
124 <item>result</item>
125 <item>true</item>
126 </list>
127
128 <contexts>
129 <context name="Alert" attribute="Alert" lineEndContext="#pop" fallthrough="true" fallthroughContext="alert">
130 <RegExpr String="^\s*[nN]\s*&int;" attribute="Line Number" column="0"/>
131 <DetectSpaces attribute="Normal Text"/>
132 <DetectChar char="%" attribute="M-word"/>
133 <AnyChar String="[]" attribute="Brackets"/>
134 <DetectChar char="(" lookAhead="1" context="parenthese"/>
135 <DetectChar char="#" lookAhead="1" context="hash1"/>
136 <AnyChar String="+-*/=:" attribute="Operator"/>
137 <DetectChar char="&quot;" attribute="String" context="string"/>
138 <DetectChar char="{" attribute="Operator" context="expression"/>
139 <DetectChar char=";" attribute="Comment" context="comment"/>
140 <RegExpr String="&number;" attribute="Number"/>
141 <RegExpr String="[abcu-z](?=[\s+\-\d#\[.{;]|$)" insensitive="1" attribute="Coordinate"/>
142 <RegExpr String="[gG]\s*(&cmd_number;|(?=[\[#]))" attribute="G-word"/>
143 <RegExpr String="[deh-lpqr@^](?=[\s+\-\d#\[.&quot;{;]|$)" insensitive="1" attribute="G-options"/>
144 <!-- exlude M1nn commands -->
145 <RegExpr String="[mM]\s*((?!1\s*\d\s*\d\s*(?=[^\d.]|$))&cmd_number;|[+#\[])" attribute="M-word"/>
146 <RegExpr String="[fF](?=\s*[+\d#\[.&quot;{])|[tsTS](?=\s*[+\d#\[&quot;{])" attribute="Tool"/>
147 <RegExpr String="[mM]&cmd_number;" attribute="M-word (user)"/>
148 <RegExpr String="[oO](\s*(&number;|&lt;\s*+[^>]+&gt;|$|(?=;))|\s+|(?=;))" attribute="O-word"/>
149 <keyword String="functions" attribute="Function"/>
150 <keyword String="operators" attribute="Operator"/>
151 <keyword String="o_sub" attribute="Sub-program"/>
152 <keyword String="keyword" attribute="Keyword" context="meta_command"/>
153 </context>
154
155 <context name="parenthese" attribute="Alert" lineEndContext="#pop">
156 <RegExpr String="\(\s*(PRINT|DEBUG|MSG|AXIS|(PROBE(CLOSE|OPEN))|(LOG(OPEN|CLOSE|APPEND|[\s,])))[^\)]*\)"
157 insensitive="1" attribute="Message" context="#pop"/>
158 <RangeDetect char="(" char1=")" attribute="Comment" context="#pop"/>
159 <DetectChar char="(" attribute="Alert" context="#pop!alert"/>
160 </context>
161
162 <context name="hash1" attribute="Alert" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!alert">
163 <RegExpr String="#\s*(&int;|&lt;\s*_[^>]*&gt;)" attribute="Param (global)" context="#pop"/>
164 <RegExpr String="#(?=\s*+(\[|#\s*[&lt;\[]))|#\s*+(#(?!\s*#)|&lt;\s*+[^>]+&gt;)" attribute="Param (local)" context="#pop"/>
165 </context>
166
167 <context name="string" attribute="String" lineEndContext="#pop">
168 <Detect2Chars char="&quot;" char1="&quot;" lookAhead="1" context="quot1"/>
169 <DetectChar char="&quot;" attribute="String" context="#pop"/>
170 <DetectChar char="'" attribute="Special String Char"/>
171 <RegExpr String="[^'&quot;]+" attribute="String"/>
172 </context>
173 <context name="quot1" attribute="String" lineEndContext="#pop">
174 <DetectChar char="&quot;" attribute="Special String Char" context="quot2"/>
175 </context>
176 <context name="quot2" attribute="String" lineEndContext="#pop">
177 <DetectChar char="&quot;" attribute="String" context="#pop#pop"/>
178 </context>
179
180 <context name="expression" attribute="Normal Text" lineEndContext="#pop">
181 <keyword String="functions" attribute="Function"/>
182 <DetectIdentifier attribute="Normal Text"/>
183 <DetectSpaces attribute="Normal Text"/>
184 <DetectChar char="}" attribute="Operator" context="#pop"/>
185 <IncludeRules context="expression_common"/>
186 </context>
187
188 <context name="expression_common" attribute="Normal Text" lineEndContext="#pop">
189 <AnyChar String="+-*/=:!#&lt;>&amp;|^,?" attribute="Operator"/>
190 <AnyChar String="[]" attribute="Brackets"/>
191 <DetectChar char="&quot;" attribute="String" context="string"/>
192 <DetectChar char="{" attribute="Operator" context="expression"/>
193 <DetectChar char=";" attribute="Comment" context="comment"/>
194 <RegExpr String="&cmd_number;|[.]\s*&int;" attribute="Number"/>
195 <Int attribute="Alert"/>
196 </context>
197
198 <context name="meta_command" attribute="Normal Text" lineEndContext="#pop">
199 <DetectSpaces attribute="Normal Text"/>
200 <keyword String="named constants" attribute="Constant"/>
201 <keyword String="functions" attribute="Function"/>
202 <keyword String="operators" attribute="Operator"/>
203 <DetectIdentifier attribute="Normal Text"/>
204 <DetectChar char="#" lookAhead="1" context="hash1"/>
205 <DetectChar char="(" lookAhead="1" context="parenthese"/>
206 <IncludeRules context="expression_common"/>
207 </context>
208
209 <context name="alert" attribute="Alert" lineEndContext="#pop">
210 <RegExpr String="[^;(]+" attribute="Alert"/>
211 <DetectChar char=";" attribute="Comment" context="comment"/>
212 <DetectChar char="(" lookAhead="1" context="parenthese"/>
213 </context>
214
215 <context name="comment" attribute="Comment" lineEndContext="#pop">
216 <DetectSpaces/>
217 <IncludeRules context="##Comments"/>
218 <DetectIdentifier/>
219 </context>
220 </contexts>
221
222 <itemDatas>
223 <itemData name="Normal Text" defStyleNum="dsNormal" spellChecking="0"/>
224 <itemData name="Brackets" defStyleNum="dsNormal" spellChecking="0"/>
225 <itemData name="Comment" defStyleNum="dsComment"/>
226 <itemData name="Coordinate" defStyleNum="dsNormal" color="#A57800" bold="1" italic="0" spellChecking="0"/>
227 <itemData name="Function" defStyleNum="dsFunction" color="#800080" bold="1" italic="1" spellChecking="0"/>
228 <itemData name="G-options" defStyleNum="dsNormal" color="#800080" bold="1" italic="0" spellChecking="0"/>
229 <itemData name="G-word" defStyleNum="dsNormal" selColor="#FFFFFF" bold="1" italic="0" spellChecking="0"/>
230 <itemData name="Keyword" defStyleNum="dsNormal" bold="1" italic="1" spellChecking="0"/>
231 <itemData name="Line Number" defStyleNum="dsComment" spellChecking="0"/>
232 <itemData name="Message" defStyleNum="dsNormal" italic="1"/>
233 <itemData name="M-word" defStyleNum="dsNormal" color="#A07400" bold="0" italic="0" spellChecking="0"/>
234 <itemData name="M-word (user)" defStyleNum="dsNormal" color="#A07400" bold="1" italic="1" spellChecking="0"/>
235 <itemData name="String" defStyleNum="dsString"/>
236 <itemData name="Special String Char" defStyleNum="dsSpecialChar" spellChecking="false"/>
237 <itemData name="Number" defStyleNum="dsDecVal" color="#A64C00" bold="1" italic="0" spellChecking="0"/>
238 <itemData name="Operator" defStyleNum="dsOperator" color="#000080" bold="1" italic="0" spellChecking="0"/>
239 <itemData name="O-word" defStyleNum="dsControlFlow" color="#BB7B40" bold="0" italic="0" spellChecking="0"/>
240 <itemData name="Param (global)" defStyleNum="dsVariable" color="#149E05" bold="0" italic="0" spellChecking="0"/>
241 <itemData name="Param (local)" defStyleNum="dsVariable" color="#0950AB" bold="0" italic="0" spellChecking="0"/>
242 <itemData name="Sub-program" defStyleNum="dsKeyword" color="#700070" bold="0" italic="0" spellChecking="0"/>
243 <itemData name="Tool" defStyleNum="dsNormal" color="#0000D6" bold="1" italic="0" spellChecking="0"/>
244 <itemData name="Alert" defStyleNum="dsError" spellChecking="0"/>
245 <itemData name="Constant" defStyleNum="dsConstant" spellChecking="0"/>
246 </itemDatas>
247 </highlighting>
248
249 <general>
250 <folding indentationsensitive="1"/>
251 <comments>
252 <comment name="singleLine" start=";"/>
253 </comments>
254 <keywords casesensitive="0"/>
255 </general>
256 </language>
257 <!-- kate: replace-tabs on; indent-width 2; tab-width 2; -->