Skip to content

Commit 5c01468

Browse files
committed
Refactored some Regex. Fixed Issue #40
1 parent cc0727c commit 5c01468

File tree

1 file changed

+37
-15
lines changed

1 file changed

+37
-15
lines changed

syntaxes/gcode.tmLanguage.json

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616
"include": "#bracket-expression"
1717
},
1818
{
19-
"include": "#keywords"
19+
"include": "#control"
20+
},
21+
{
22+
"include": "#gcodes"
23+
},
24+
{
25+
"include": "#mcodes"
2026
},
2127
{
2228
"include": "#operators"
@@ -54,12 +60,28 @@
5460
}
5561
]
5662
},
57-
"keywords": {
63+
"control": {
5864
"patterns": [
5965
{
60-
"match": "(GOTO(?>\\d+))|(IF)|(EQ)|(NE)|(LT)|(GT)|(LE)|(GE)|(DO ?(?>\\d+))|(WHILE)|(WH)|(END ?(?>\\d+))|(AND)|(OR)|(XOR)|(THEN)|(ELSE)|(ENDIF)",
66+
"match": "(GOTO\\s?\\d*)",
67+
"name": "keyword.control.gcode"
68+
},
69+
{
70+
"match": "(EQ|NE|LT|GT|LE|GE|AND|OR|XOR)",
6171
"name": "keyword.control.gcode"
6272
},
73+
{
74+
"match": "(DO\\s?\\d*|WHILE|WH|END|IF|THEN|ELSE|ENDIF)",
75+
"name": "keyword.control.gcode"
76+
},
77+
{
78+
"match": "([\\%])",
79+
"name": "string.gcode"
80+
}
81+
]
82+
},
83+
"gcodes": {
84+
"patterns": [
6385
{
6486
"match": "[gG](1)?5[4-9](.1)?\\s?(P[0-9]{1,3})?",
6587
"name": "constant.numeric.gcode"
@@ -75,29 +97,29 @@
7597
{
7698
"match": "[gG][0-9]{1,3}(\\.[0-9])?",
7799
"name": "markup.bold.gcode"
78-
},
100+
}
101+
]
102+
},
103+
"mcodes": {
104+
"patterns": [
79105
{
80106
"match": "[mM][0-9]{1,3}",
81107
"name": "keyword.operator.quantifier.regexp.gcode"
82-
},
83-
{
84-
"match": "([\\%])",
85-
"name": "string.gcode"
86108
}
87109
]
88110
},
89111
"operators": {
90112
"patterns": [
91113
{
92-
"match": "(SIN)|(COS)|(TAN)|(ASIN)|(ACOS)|(ATAN)|(FIX)|(FUP)|(LN)|(ROUND)|(SQRT)",
114+
"match": "(SIN|COS|TAN|ASIN|ACOS|ATAN|FIX|FUP|LN|ROUND|SQRT)",
93115
"name": "support.constant.math.gcode"
94116
},
95117
{
96-
"match": "(FIX)|(FUP)|(ROUND)|(ABS)|(MOD)",
118+
"match": "(FIX|FUP|ROUND|ABS|MOD)",
97119
"name": "support.constant.math.gcode"
98120
},
99121
{
100-
"match": "(\\+)|(\\*)|(\\/)|(\\*\\*)",
122+
"match": "(\\+|\\*|\\/|\\*\\*)",
101123
"name": "support.constant.math.gcode"
102124
},
103125
{
@@ -157,15 +179,15 @@
157179
"tools": {
158180
"patterns": [
159181
{
160-
"match": "([dD])\\s?(\\d*\\.?\\d*|(?=[#\\[]))",
182+
"match": "([dD])\\s?(\\d+(\\.\\d*)?|(?=[#\\[]))",
161183
"name": "constant.character.gcode"
162184
},
163185
{
164-
"match": "([hH])\\s?(\\d*\\.?\\d*|(?=[#\\[]))",
186+
"match": "([hH])\\s?(\\d+(\\.\\d*)?|(?=[#\\[]))",
165187
"name": "constant.character.gcode"
166188
},
167189
{
168-
"match": "([tT])\\s?(\\d*\\.?\\d*|(?=[#\\[]))",
190+
"match": "([tT])\\s?(\\d+(\\.\\d*)?|(?=[#\\[]))",
169191
"name": "constant.character.gcode"
170192
}
171193
]
@@ -219,4 +241,4 @@
219241
]
220242
}
221243
}
222-
}
244+
}

0 commit comments

Comments
 (0)