diff --git a/build/shared/lib/languages/PDE.properties b/build/shared/lib/languages/PDE.properties index 1a335b83d..d68177d7d 100644 --- a/build/shared/lib/languages/PDE.properties +++ b/build/shared/lib/languages/PDE.properties @@ -360,6 +360,7 @@ editor.status.missing.right_paren = Missing right parenthesis ")" editor.status.missing.left_curly_bracket = Missing left curly bracket "{" editor.status.missing.right_curly_bracket = Missing right curly bracket "}" editor.status.missing.add = Consider adding "%s" +editor.status.bad_curly_quote = Curly quotes like %s don't work. Use straight quotes. Ctrl-T to autocorrect. editor.status.reserved_words = "color" and "int" are reserved words & cannot be used as variable names editor.status.undefined_method = The function "%s(%s)" does not exist editor.status.undefined_constructor = The constructor "%s(%s)" does not exist diff --git a/java/src/processing/mode/java/JavaBuild.java b/java/src/processing/mode/java/JavaBuild.java index 88f6fc3be..e9f84170d 100644 --- a/java/src/processing/mode/java/JavaBuild.java +++ b/java/src/processing/mode/java/JavaBuild.java @@ -38,6 +38,7 @@ import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectHelper; import processing.app.Base; +import processing.app.Language; import processing.app.Library; import processing.app.Messages; import processing.app.Mode; @@ -341,9 +342,30 @@ public class JavaBuild { // System.err.println("and then she tells me " + tsre.toString()); // TODO not tested since removing ORO matcher.. ^ could be a problem - String mess = "^line (\\d+):(\\d+):\\s"; + String locationRegex = "^line (\\d+):(\\d+):\\s"; + String message = tsre.getMessage(); + String[] m; - String[] matches = PApplet.match(tsre.toString(), mess); + if (null != (m = PApplet.match(tsre.toString(), + "unexpected char: (.*)"))) { + char c = 0; + if (m[1].startsWith("0x")) { // Hex + c = (char) PApplet.unhex(m[1].substring(2)); + } else if (m[1].length() == 3) { // Quoted + c = m[1].charAt(1); + } else if (m[1].length() == 1) { // Alone + c = m[1].charAt(0); + } + if (c == '\u201C' || c == '\u201D' || // “” + c == '\u2018' || c == '\u2019') { // ‘’ + message = Language.interpolate("editor.status.bad_curly_quote", c); + } else if (c != 0) { + message = "Not expecting symbol " + m[1] + + ", which is " + Character.getName(c) + "."; + } + } + + String[] matches = PApplet.match(tsre.toString(), locationRegex); if (matches != null) { int errorLine = Integer.parseInt(matches[1]) - 1; int errorColumn = Integer.parseInt(matches[2]); @@ -358,7 +380,7 @@ public class JavaBuild { } errorLine -= sketch.getCode(errorFile).getPreprocOffset(); - throw new SketchException(tsre.getMessage(), + throw new SketchException(message, errorFile, errorLine, errorColumn); } else { diff --git a/java/src/processing/mode/java/preproc/PdePreprocessor.java b/java/src/processing/mode/java/preproc/PdePreprocessor.java index 5a68752d1..ea8723520 100644 --- a/java/src/processing/mode/java/preproc/PdePreprocessor.java +++ b/java/src/processing/mode/java/preproc/PdePreprocessor.java @@ -924,9 +924,11 @@ public class PdePreprocessor { checkForUnterminatedMultilineComment(program); - if (Preferences.getBoolean("preproc.substitute_unicode")) { - program = substituteUnicode(program); - } + // Removing all the Unicode characters makes detecting and reporting their + // preprocessor errors quite hard. +// if (Preferences.getBoolean("preproc.substitute_unicode")) { +// program = substituteUnicode(program); +// } // For 0215, adding } as a legitimate prefix to the import (along with // newline and semicolon) for cases where a tab ends with } and an import @@ -1478,4 +1480,4 @@ public class PdePreprocessor { } return sb.toString(); } -} \ No newline at end of file +}