Skip to content

Commit

Permalink
Merge pull request #1 from tiobe/35201-matlab-backslash
Browse files Browse the repository at this point in the history
  • Loading branch information
brouwers-tiobe authored Oct 24, 2024
1 parent d8d4d3d commit dce71f6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
15 changes: 1 addition & 14 deletions pmd-matlab/etc/grammar/Matlab.jj
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,8 @@ PARSER_END(MatlabParserImpl)

<DEFAULT> TOKEN :
{
< STRING: "'" ( <ESC_SEQ> | "'" "'" | ~["\\","'","\n"] )* "'" >
< STRING: "'" ( "\\" | "'" "'" | ~["\\","'","\n"] )* "'" >
| < DSTRING: "\"" ( "\\" | "\"" "\"" | ~["\\","\"","\n"] )* "\"" >
| < #ESC_SEQ:
"\\" ( "b" | "t" | "n" | "f" | "r" | "\"" | "'" | "\\" )
| <UNICODE_ESC>
| <OCTAL_ESC>
>
| < #UNICODE_ESC: "\\" "u" <HEX_DIGIT> <HEX_DIGIT> <HEX_DIGIT> <HEX_DIGIT> >
| < #OCTAL_ESC:
"\\" ["0" - "3"] <OCTAL_DIGIT> <OCTAL_DIGIT>
| "\\" <OCTAL_DIGIT> <OCTAL_DIGIT>
| "\\" <OCTAL_DIGIT>
>
| < #HEX_DIGIT: ["0"-"9", "a"-"f", "A"-"F"] >
| < #OCTAL_DIGIT: ["0"-"7"] >
}

<DEFAULT, TRANSPOSE> TOKEN :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ void testDoubleQuotedStrings() {
void testTabWidth() {
doTest("tabWidth");
}

@Test
void testBackslash() {
doTest("stringsWithBackslash");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
error('$\phi$');
error('\\192.168.1.1\Disk');
error('\');
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Image] or [Truncated image[ Bcol Ecol
L1
[error] 1 6
[(] 6 7
['$\\phi$'] 7 15
[)] 15 16
[;] 16 17
L2
[error] 1 6
[(] 6 7
['\\\\192.168.1.1\\Disk'] 7 27
[)] 27 28
[;] 28 29
L3
[error] 1 6
[(] 6 7
['\\'] 7 10
[)] 10 11
[;] 11 12
EOF

0 comments on commit dce71f6

Please sign in to comment.