summaryrefslogtreecommitdiff
path: root/docs/src/source-highlight/ngc.lang
blob: 3835e5b953ff6f2ad8a70f1e40e4c48f9d4715ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# ngc.lang - RS274 G-Code formatting (EMC flavour)
#
#  Michael Haberler 3/2011
#
#  originally based on the Highlight-mode file for gedit,
#  written by Jan Van Gilsen <janvangilsen(at)gmail(dot)com>
#  Installation instructions can be found at:
#  http://wiki.linuxcnc.org/cgi-bin/emcinfo.pl?Highlighting_In_Gedit
#  Version		: 0.3
#  Last Edit	: 10Th Nov 2007, by Jan Van Gilsen
#  Comment 	: added probing and rigid tapping G-codes (new in 2.2)


environment comment delim '\([dD][eE][bB][uU][gG],' ")" begin
	variable =  '#([0-9]{4})'
	variable =  '#[0-9][0-9]?'
	variable =  '#<([^\>]+)>'
end
comment delim "(" ")"
comment start ";"


# numbered parameters (#5xxx)
variable =  '#([0-9]{4})'

# function parameter -  #1 .. #30
variable =  '#[0-9][0-9]?'

# named parameters
variable =  '#<([^\>]+)>'

# math functions and boolean logic
function = "cos|tan|asin|acos|atan|exp|ln|sqrt|fup|fix|abs|or",
	"xor|and|mod|gt|lt|ge|le|eq|ne|exists"
	nonsensitive

# operators
function = '(([-/|\=\+\*])|(\])|(\[))'

# line numbers
comment = '^[n|N]([ |\t]*[0-9]){1,5}'

# O-word lines and their keywords
preproc = '[ \t]*[o|O](([ \t]*[0-9])+|<([[:alpha:]]|_)([[:word:]]|\-)+>)[ \t]*',
	'(sub|endsub|while|endwhile|if|else|endif|do|call|break|continue|return|repeat|endrepeat|elseif)'

# G codes
vardef GCODE = '[g|G]([ \t]*[0])*[ \t]*'
keyword = $GCODE + '1[ \t]*[07-9]'
keyword = $GCODE + '2[ \t]*[018]'
keyword = $GCODE + '3[ \t]*[03]'
keyword = $GCODE + '3[ \t]*3[ \t]*.[ \t]*1'
keyword = $GCODE + '3[ \t]*8[ \t]*.[ \t]*[2-5]'
keyword = $GCODE + '4[ \t]*[1-3][ \t]*.[ \t]*1'
keyword = $GCODE + '4[ \t]*[0-39]'
keyword = $GCODE + '5[ \t]*[3-9]'
keyword = $GCODE + '6[ \t]*[14]'
keyword = $GCODE + '6[ \t]*.[ \t]*1'
keyword = $GCODE + '7[ \t]*6'
keyword = $GCODE + '8[ \t]*[0-9]'
keyword = $GCODE + '9[ \t]*[0-489]'
keyword = $GCODE + '9[ \t]*2[ \t]*.[ \t]*[1-3]'
keyword = $GCODE + '[0-5]'


# M-Codes
vardef MCODE = '[m|M]([ \t]*[0])*[ \t]*'
keyword = $MCODE + '5[ \t]*[0-3]'
keyword = $MCODE + '3[ \t]*0'
keyword = $MCODE + '6[ \t]*0'
keyword = $MCODE + '6[ \t]*[0-9]'
keyword = $MCODE + '7[ \t]*[0-3]'
keyword = $MCODE + '1[ \t]*[0-9][ \t]*[1-9]'
keyword = $MCODE + '1[ \t]*[1-9][ \t]*0'
keyword = $MCODE + '[0-9]'

# Feeds & speeds
keyword = '[f|F|s|S]([ \t]*[0-9])*[ \t]*[.]?([ \t]*[0-9])*'

# T, H
keyword = '[t|T|h|H]([ \t]*[0-9])*'

# Coordinates & arguments; trailing number/expression/params formatted separately
atom = '[x|X|y|Y|z|Z|a|A|b|B|c|C|u|U|v|V|w|W|i|I|j|J|k|K|p|P|q|Q|r|R|l|L](\s*)?'


#    * A number consists of (1) an optional plus or minus sign,
#	followed by (2) zero to many digits, followed, possibly,
#	by (3) one decimal point,
#	followed by (4) zero to many digits - provided that there is at least one digit somewhere in the number.
#
#    * There are two kinds of numbers: integers and decimals. An integer does not have a decimal point in it; a decimal does.
#    * Numbers may have any number of digits, subject to the limitation on line length. Only about seventeen significant figures will be retained, however (enough for all known applications).
#    * A non-zero number with no sign as the first character is assumed to be positive.
number = '[+-]?([[:digit:]]*\.)?[[:digit:]]+'