From 9a9f5058ed3459ad79e7d5b9c31725f08662a814 Mon Sep 17 00:00:00 2001 From: Hayodea Hakol Date: Tue, 14 Jan 2025 23:11:30 -0400 Subject: [PATCH] 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. --- hcore/deviceManager/deviceSpecl.ll | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hcore/deviceManager/deviceSpecl.ll b/hcore/deviceManager/deviceSpecl.ll index 376b7cc..2a20642 100644 --- a/hcore/deviceManager/deviceSpecl.ll +++ b/hcore/deviceManager/deviceSpecl.ll @@ -2,6 +2,8 @@ %option nounput %{ #include +#include +#include #include #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]; }