summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Merry <alex.merry@cs.ox.ac.uk>2013-02-04 17:23:00 +0000
committerAlex Merry <alex.merry@cs.ox.ac.uk>2013-02-04 17:23:00 +0000
commitbd5255daf24b860f44f9d1654f5753017abec2f5 (patch)
tree4dbd5ee342a495bd6f3f0619e9063f8e3ab4c426
parent022ac124a472ce1cf542806a01c975da938eba51 (diff)
Parse escaped { and } characters properly
Within a {-quoted string (one surrounded by { and }), ignore any characters prefixed by backslash.
-rw-r--r--tikzit/src/common/tikzlexer.lm10
1 files changed, 8 insertions, 2 deletions
diff --git a/tikzit/src/common/tikzlexer.lm b/tikzit/src/common/tikzlexer.lm
index 816d91c..26cddd9 100644
--- a/tikzit/src/common/tikzlexer.lm
+++ b/tikzit/src/common/tikzlexer.lm
@@ -94,13 +94,19 @@ at { tokenpos += yyleng; return AT; }
\{ {
NSMutableString *buf = [NSMutableString string];
unsigned int brace_depth = 1;
+ unsigned int escape = 0;
while (1) {
char c = input();
// eof reached before closing brace
if (c == '\0' || c == EOF) yyterminate();
- if (c == '{') brace_depth++;
- else if (c == '}') {
+ if (escape) {
+ escape = 0;
+ } else if (c == '\\') {
+ escape = 1;
+ } else if (c == '{') {
+ brace_depth++;
+ } else if (c == '}') {
brace_depth--;
if (brace_depth == 0) break;
}