mirror of
https://github.com/processing/processing4.git
synced 2026-02-04 22:29:18 +01:00
more work on preproc with chars (issue #752)
This commit is contained in:
@@ -132,7 +132,8 @@ import antlr.collections.AST;
|
||||
* @author Jonathan Feinberg <jdf@pobox.com>
|
||||
*/
|
||||
public class PdePreprocessor {
|
||||
|
||||
protected static final String UNICODE_ESCAPES = "0123456789abcdefABCDEF";
|
||||
|
||||
// used for calling the ASTFactory to get the root node
|
||||
private static final int ROOT_ID = 0;
|
||||
|
||||
@@ -254,15 +255,26 @@ public class PdePreprocessor {
|
||||
throw new SketchException("Unterminated character constant (after initial quote)", 0,
|
||||
countNewlines(program.substring(0, i)));
|
||||
}
|
||||
boolean escaped = false;
|
||||
if (program.charAt(i) == '\\') {
|
||||
i++; // step over the backslash
|
||||
escaped = true;
|
||||
}
|
||||
if (i >= length) {
|
||||
throw new SketchException("Unterminated character constant (after backslash)", 0,
|
||||
countNewlines(program.substring(0, i)));
|
||||
}
|
||||
if (program.charAt(i) == 'u') {
|
||||
i += 5; // step over the u, and the four digit unicode constant
|
||||
if (escaped && program.charAt(i) == 'u') { // unicode escape sequence?
|
||||
i++; // step over the u
|
||||
//i += 4; // and the four digit unicode constant
|
||||
for (int j = 0; j < 4; j++) {
|
||||
if (UNICODE_ESCAPES.indexOf(program.charAt(i)) == -1) {
|
||||
throw new SketchException("Bad or unfinished \\uXXXX sequence " +
|
||||
"(malformed Unicode character constant)", 0,
|
||||
countNewlines(program.substring(0, i)));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
i++; // step over a single character
|
||||
}
|
||||
@@ -276,7 +288,6 @@ public class PdePreprocessor {
|
||||
countNewlines(program.substring(0, i)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user