libxcb #1
@@ -26,31 +26,33 @@
|
|||||||
"|" { return PIPE; }
|
"|" { return PIPE; }
|
||||||
"(" { return LPAREN; }
|
"(" { return LPAREN; }
|
||||||
")" { return RPAREN; }
|
")" { return RPAREN; }
|
||||||
[ \t]*"="[ \t]* { return EQUALS; } // Allow optional whitespace around equals
|
"=" { return EQUALS; } // Match "=" on its own
|
||||||
(\\.|[^=\|\(\) \t\r\n])+ {
|
(\\.|[^=\|\(\) \t\r\n])+ {
|
||||||
std::string token(yytext);
|
std::string token(yytext);
|
||||||
|
|
||||||
// Unescape logic for backslash, pipe
|
|
||||||
std::string unescaped;
|
std::string unescaped;
|
||||||
unescaped.reserve(token.size());
|
unescaped.reserve(token.size());
|
||||||
|
|
||||||
for (size_t i = 0; i < token.size(); ++i)
|
for (size_t i = 0; i < token.size(); ++i)
|
||||||
{
|
{
|
||||||
if (token[i] == '\\' && i + 1 < token.size())
|
if (token[i] != '\\')
|
||||||
{
|
|
||||||
unescaped.push_back(token[++i]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
unescaped.push_back(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());
|
deviceSpecplval.str = strdup(unescaped.c_str());
|
||||||
return STRING;
|
return STRING;
|
||||||
}
|
}
|
||||||
\r?\n { /* ignore newlines */ }
|
[ \t\r\n]+ { /* ignore all whitespace, including newlines */ }
|
||||||
[ \t]+ { /* ignore whitespace */ }
|
|
||||||
. { return yytext[0]; }
|
. { return yytext[0]; }
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user