Skip to content

Commit 33435eb

Browse files
committed
Fix a bug of removing comments inside the parentheses in stripComments
1 parent 1f41393 commit 33435eb

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ const parseLine = (() => {
6262
}
6363
return cs;
6464
};
65-
const stripLine = (() => {
65+
const stripComments = (() => {
6666
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
67+
const re2 = new RegExp(/\s*\([^\)]*\)/g); // Remove anything inside the parentheses
6868
const re3 = new RegExp(/\s+/g);
69-
70-
return (s => s.replace(re1, '').replace(re2, '').replace(re3, ''));
69+
return (line => line.replace(re1, '').replace(re2, '').replace(re3, ''));
7170
})();
7271
const re = /([a-zA-Z][0-9\+\-\.]*)|(\*[0-9]+)/igm;
7372

@@ -84,7 +83,7 @@ const parseLine = (() => {
8483

8584
let ln; // Line number
8685
let cs; // Checksum
87-
const words = stripLine(line).match(re) || [];
86+
const words = stripComments(line).match(re) || [];
8887
for (let i = 0; i < words.length; ++i) {
8988
const word = words[i];
9089
const letter = word[0].toUpperCase();

0 commit comments

Comments
 (0)