deal with character constant error with unicode (issue #714)

This commit is contained in:
benfry
2011-06-20 23:36:05 +00:00
parent c0543fc12e
commit 47ae658028
3 changed files with 23 additions and 7 deletions

View File

@@ -249,21 +249,30 @@ public class PdePreprocessor {
stringStart)));
}
} else if (program.charAt(i) == '\'') {
i++;
i++; // step over the initial quote
if (i >= length) {
throw new SketchException("Unterminated character constant", 0,
throw new SketchException("Unterminated character constant (after initial quote)", 0,
countNewlines(program.substring(0, i)));
}
if (program.charAt(i) == '\\') {
i++;
i++; // step over the backslash
}
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
} else {
i++; // step over a single character
}
i++;
if (i >= length) {
throw new SketchException("Unterminated character constant", 0,
countNewlines(program.substring(0, i)));
}
if (program.charAt(i) != '\'') {
throw new SketchException("Badly formed character constant", 0,
throw new SketchException("Badly formed character constant " +
"(expecting quote, got " + program.charAt(i) + ")", 0,
countNewlines(program.substring(0, i)));
}
}