Skip to content

Commit 1bdab1b

Browse files
committed
The semi-colon is not treated as the start of a comment when enclosed in parentheses.
1 parent 2571627 commit 1bdab1b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ const parseLine = (() => {
6262
}
6363
return cs;
6464
};
65+
// http://linuxcnc.org/docs/html/gcode/overview.html#gcode:comments
66+
// Comments can be embedded in a line using parentheses () or for the remainder of a lineusing a semi-colon. The semi-colon is not treated as the start of a comment when enclosed in parentheses.
6567
const stripComments = (() => {
66-
const re1 = new RegExp(/\s*[%#;].*/g); // Strip everything after %, #, or ; to the end of the line, including preceding spaces
67-
const re2 = new RegExp(/\s*\([^\)]*\)/g); // Remove anything inside the parentheses
68+
const re1 = new RegExp(/\s*\([^\)]*\)/g); // Remove anything inside the parentheses
69+
const re2 = new RegExp(/\s*;.*/g); // Remove anything after a semi-colon to the end of the line, including preceding spaces
6870
const re3 = new RegExp(/\s+/g);
6971
return (line => line.replace(re1, '').replace(re2, '').replace(re3, ''));
7072
})();

0 commit comments

Comments
 (0)