From bd5255daf24b860f44f9d1654f5753017abec2f5 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 4 Feb 2013 17:23:00 +0000 Subject: Parse escaped { and } characters properly Within a {-quoted string (one surrounded by { and }), ignore any characters prefixed by backslash. --- tikzit/src/common/tikzlexer.lm | 10 ++++++++-- 1 file 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; } -- cgit v1.2.3