Skip to content

Commit 9f117e1

Browse files
philipc-mwkrisctl
authored andcommitted
Fixes Lezer parser to correctly handle whitespace beside multiline comment delimiters.
1 parent 4617072 commit 9f117e1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/jupyter_matlab_labextension/src/lezer-matlab/src/parse_comments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const isAlphabetical = (char) => /^[a-zA-Z]$/.test(String.fromCharCode(char));
1616

1717
const lineEndArray = [newline, carriageReturn, fileEnd, fileStart];
1818

19-
const isWhitespace = (char) => /\s/.test(char);
19+
const isWhitespace = (char) => /\s/.test(String.fromCharCode(char));
2020

2121
const precededByWhitespaceOnly = (input) => {
2222
// Scan from current position to start of line.

src/jupyter_matlab_labextension/src/lezer-matlab/test/basic_terms.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,19 @@ Script(String)
4141
# Multiline comment
4242

4343
%{
44-
Test multiline comment
44+
Test multiline comment.
45+
%}
46+
%{
47+
Test multiline comment with whitespace before ending delimiter.
48+
The whitespace could be a space or a tab, and can be before or
49+
after either delimiter without invalidating the multiline comment.
50+
%}
51+
not_a_comment % Line below is a LineComment
4552
%}
4653

4754
==>
4855

49-
Script(MultilineComment)
56+
Script(MultilineComment,MultilineComment,Identifier,LineComment,LineComment)
5057

5158
# Transpose
5259

0 commit comments

Comments
 (0)