devSpec: allow backslash escaped whitespace in STRING tokens

This allows us to use spaces when specifying window name selectors.
Which is very convenient and cool.
This commit is contained in:
2025-01-14 23:11:30 -04:00
parent ff56bfce04
commit 9a9f5058ed
+8 -1
View File
@@ -2,6 +2,8 @@
%option nounput
%{
#include <vector>
#include <string>
#include <algorithm>
#include <deviceManager/deviceManager.h>
#include "deviceSpecp.hh"
%}
@@ -24,7 +26,12 @@
"(" { return LPAREN; }
")" { return RPAREN; }
[ \t]*"="[ \t]* { return EQUALS; } // Allow optional whitespace around equals
[^=\|\(\) \t\r\n]+ { deviceSpecplval.str = strdup(yytext); return STRING; } // Exclude = from STRING tokens
([^=\|\(\) \t\r\n]|\\[ \t])+ {
std::string token(yytext);
token.erase(std::remove(token.begin(), token.end(), '\\'), token.end());
deviceSpecplval.str = strdup(token.c_str());
return STRING;
}
\r?\n { /* ignore newlines */ }
[ \t]+ { /* ignore whitespace */ }
. { return yytext[0]; }