You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[matlab] CPD: Parse error with backslashes in character vectors/string literals #2258
Description:
I tried using cpd on Windows 10 in a medium large code base, but got a (wrong?) Lexical error immediately. I think MATLAB's weird sometimes-escape-character \ isn't handled properly:
net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file Untitled.m at line 3, column 56. Encountered: "$" (36), after : ""
at net.sourceforge.pmd.lang.matlab.ast.MatlabParserTokenManager.getNextToken(MatlabParserTokenManager.java:1996)
at net.sourceforge.pmd.lang.matlab.MatlabTokenManager.getNextToken(MatlabTokenManager.java:31)
at net.sourceforge.pmd.cpd.token.internal.BaseTokenFilter.getNextToken(BaseTokenFilter.java:30)
at net.sourceforge.pmd.cpd.internal.JavaCCTokenizer.tokenize(JavaCCTokenizer.java:40)
at net.sourceforge.pmd.cpd.CPD.addAndThrowLexicalError(CPD.java:144)
at net.sourceforge.pmd.cpd.CPD.add(CPD.java:139)
at net.sourceforge.pmd.cpd.CPD.add(CPD.java:108)
at net.sourceforge.pmd.cpd.CPD.add(CPD.java:70)
at net.sourceforge.pmd.cpd.CPD.addDirectory(CPD.java:80)
at net.sourceforge.pmd.cpd.CPD.addRecursively(CPD.java:65)
at net.sourceforge.pmd.cpd.CPDCommandLineInterface.addSourcesFilesToCPD(CPDCommandLineInterface.java:134)
at net.sourceforge.pmd.cpd.CPDCommandLineInterface.addSourceFilesToCPD(CPDCommandLineInterface.java:114)
at net.sourceforge.pmd.cpd.CPDCommandLineInterface.main(CPDCommandLineInterface.java:87)
at net.sourceforge.pmd.cpd.CPD.main(CPD.java:179)
--ignore-literals doesn't help as a work-around either...
changed the title [-][matlab] [cpd] Parse error with backslashes in string literals[/-][+][matlab] CPD: Parse error with backslashes in string literals[/+]on Oct 29, 2026
changed the title [-][matlab] CPD: Parse error with backslashes in string literals[/-][+][matlab] CPD: Parse error with backslashes in character vectors/string literals[/+]on Oct 29, 2026
Activity
[matlab] Fix pmd#2258: Handle literal backslashes in character vectors (
[-][matlab] [cpd] Parse error with backslashes in string literals[/-][+][matlab] CPD: Parse error with backslashes in string literals[/+][-][matlab] CPD: Parse error with backslashes in string literals[/-][+][matlab] CPD: Parse error with backslashes in character vectors/string literals[/+]