From 4469b08d3ef3fd8c9189c6fee90c0e943b840a86 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 12 Nov 2010 18:32:56 -0800 Subject: [PATCH] Handle escaped characters in a SDF identifier. This patch adds the ability to parse a SDF identifier that contains escaped characters. --- vpi/sdf_lexor.lex | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/vpi/sdf_lexor.lex b/vpi/sdf_lexor.lex index 47932b7c2..9c4fe6ca4 100644 --- a/vpi/sdf_lexor.lex +++ b/vpi/sdf_lexor.lex @@ -85,7 +85,7 @@ static int yywrap(void) return REAL_NUMBER; } -[a-zA-Z_][a-zA-Z0-9$_]* { +([a-zA-Z_]|(\\[^ \t\b\f\r\n]))([a-zA-Z0-9$_]|(\\[^ \t\b\f\r\n]))* { return lookup_keyword(yytext); } @@ -154,12 +154,24 @@ void stop_edge_id(void) static int lookup_keyword(const char*text) { - int idx; + unsigned idx, len, skip; for (idx = 0 ; keywords[idx].name ; idx += 1) { if (strcasecmp(text, keywords[idx].name) == 0) return keywords[idx].code; } + /* Process any escaped characters. */ + skip = 0; + len = strlen(yytext); + for (idx = 0; idx < len; idx += 1) { + if (yytext[idx] == '\\') { + skip += 1; + idx += 1; + } + yytext[idx-skip] = yytext[idx]; + } + yytext[idx-skip] = 0; + yylval.string_val = strdup(yytext); return IDENTIFIER; }