diff --git a/hcore/deviceManager/deviceSpecl.ll b/hcore/deviceManager/deviceSpecl.ll index daa03ef..f22599a 100644 --- a/hcore/deviceManager/deviceSpecl.ll +++ b/hcore/deviceManager/deviceSpecl.ll @@ -26,31 +26,33 @@ "|" { return PIPE; } "(" { return LPAREN; } ")" { return RPAREN; } -[ \t]*"="[ \t]* { return EQUALS; } // Allow optional whitespace around equals +"=" { return EQUALS; } // Match "=" on its own (\\.|[^=\|\(\) \t\r\n])+ { std::string token(yytext); - - // Unescape logic for backslash, pipe std::string unescaped; unescaped.reserve(token.size()); for (size_t i = 0; i < token.size(); ++i) { - if (token[i] == '\\' && i + 1 < token.size()) - { - unescaped.push_back(token[++i]); - } - else + if (token[i] != '\\') { unescaped.push_back(token[i]); + continue; } + + /* If a backslash is the final char before EOF, just continue so it gets + * dropped as a side effect. + */ + if (i + 1 >= token.size()) { continue; } + + // Else push the char following the backslash. + unescaped.push_back(token[++i]); } deviceSpecplval.str = strdup(unescaped.c_str()); return STRING; } -\r?\n { /* ignore newlines */ } -[ \t]+ { /* ignore whitespace */ } +[ \t\r\n]+ { /* ignore all whitespace, including newlines */ } . { return yytext[0]; } %%