@duet3d/monacotokens 3.7.0-alpha.10 → 3.7.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,9 +24,12 @@ function generateMonarchLanguage(fdmMode) {
24
24
  // G53 acting as a same-line prefix (e.g. "G53 G1 X10") - highlight as a modifier, distinct from both
25
25
  // line numbers (type) and regular codes (keyword)
26
26
  [/[gG]53(?=[\s]+[gGmMtT][0-9-])/, "regexp", "afterG53"],
27
- // G/M/T-codes (including bare G53 on its own line, which behaves like a regular command)
27
+ // G/M/T-codes (including bare G53 on its own line, which behaves like a regular command).
28
+ // M-codes get their own state because T is a valid M-code parameter letter, whereas inside
29
+ // a G-code's parameter list T starts a new T-code on the same line
28
30
  [/[gG][0123](?=\D)/, "keyword", fdmMode ? "normalGcode" : "moveGcode"],
29
- [/[gGmM]\d+(\.\d+)?/, "keyword", "normalGcode"],
31
+ [/[gG]\d+(\.\d+)?/, "keyword", "normalGcode"],
32
+ [/[mM]\d+(\.\d+)?/, "keyword", "normalMcode"],
30
33
  [/[tT](?=\{)/, "keyword", "normalGcodeWithT"],
31
34
  [/[tT]-?\d+/, "keyword", "normalGcodeWithT"],
32
35
  // meta keywords
@@ -52,10 +55,12 @@ function generateMonarchLanguage(fdmMode) {
52
55
  afterG53: [
53
56
  // whitespace between the G53 prefix and the following G/M/T-code
54
57
  [/[ \t]+/, ""],
55
- // next G/M/T-code - replace this state with the code's own state so its parameters
56
- // are parsed normally and any trailing T letters are treated as parameters, not T-codes
58
+ // next G/M/T-code - replace this state with the code's own state so its parameters are
59
+ // parsed normally; M-codes switch to normalMcode where T is treated as a parameter letter,
60
+ // while G-codes switch to normalGcode where a trailing T starts a new T-code
57
61
  [/[gG][0123](?=\D)/, { token: "keyword", switchTo: fdmMode ? "@normalGcode" : "@moveGcode" }],
58
- [/[gGmM]\d+(\.\d+)?/, { token: "keyword", switchTo: "@normalGcode" }],
62
+ [/[gG]\d+(\.\d+)?/, { token: "keyword", switchTo: "@normalGcode" }],
63
+ [/[mM]\d+(\.\d+)?/, { token: "keyword", switchTo: "@normalMcode" }],
59
64
  [/[tT](?=\{)/, { token: "keyword", switchTo: "@normalGcodeWithT" }],
60
65
  [/[tT]-?\d+/, { token: "keyword", switchTo: "@normalGcodeWithT" }]
61
66
  ],
@@ -82,11 +87,21 @@ function generateMonarchLanguage(fdmMode) {
82
87
  { include: "gcode" }
83
88
  ],
84
89
  normalGcode: [
90
+ // T inside a G-code parameter list starts a new T-code (T is not a valid G-code parameter)
91
+ [/[tT](?=\{)/, "keyword", "normalGcodeWithT"],
92
+ [/[tT]-?\d+/, "keyword", "normalGcodeWithT"],
85
93
  // include normal gcode
86
94
  { include: "gcode" },
87
95
  // EOL
88
96
  [/\n/, "", "@popall"]
89
97
  ],
98
+ normalMcode: [
99
+ // T is a parameter letter inside an M-code, not a new T-code - so this state intentionally
100
+ // omits the T-code re-entry rules that normalGcode has
101
+ { include: "gcode" },
102
+ // EOL
103
+ [/\n/, "", "@popall"]
104
+ ],
90
105
  normalGcodeWithT: [
91
106
  // already had a T parameter, starting a new T-code
92
107
  [/(?=T)/, "keyword", "@popall"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duet3d/monacotokens",
3
- "version": "3.7.0-alpha.10",
3
+ "version": "3.7.0-alpha.11",
4
4
  "description": "TypeScript library that holds syntax highlighting files for the Monaco editor",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",