diff options
author | Alex Merry <alex.merry@cs.ox.ac.uk> | 2013-02-04 17:23:00 +0000 |
---|---|---|
committer | Alex Merry <alex.merry@cs.ox.ac.uk> | 2013-02-04 17:23:00 +0000 |
commit | bd5255daf24b860f44f9d1654f5753017abec2f5 (patch) | |
tree | 4dbd5ee342a495bd6f3f0619e9063f8e3ab4c426 /tikzit | |
parent | 022ac124a472ce1cf542806a01c975da938eba51 (diff) |
Parse escaped { and } characters properly
Within a {-quoted string (one surrounded by { and }), ignore any
characters prefixed by backslash.
Diffstat (limited to 'tikzit')
-rw-r--r-- | tikzit/src/common/tikzlexer.lm | 10 |
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; } |