76e465bd1d
Now we can escape special characters without issue.
60 lines
1.5 KiB
LLVM
60 lines
1.5 KiB
LLVM
%option prefix="deviceSpecl"
|
|
%option nounput
|
|
%{
|
|
#include <vector>
|
|
#include <string>
|
|
#include <algorithm>
|
|
#include <deviceManager/deviceManager.h>
|
|
#include "deviceSpecp.hh"
|
|
%}
|
|
|
|
%%
|
|
"+adev" {
|
|
deviceSpecplval.chr = yytext[1];
|
|
return KEYWORD_SPECTYPE_ACTUATOR;
|
|
}
|
|
"+edev" {
|
|
deviceSpecplval.chr = yytext[1];
|
|
return KEYWORD_SPECTYPE_EXTROSPECTOR;
|
|
}
|
|
"+idev" {
|
|
deviceSpecplval.chr = yytext[1];
|
|
return KEYWORD_SPECTYPE_INTEROSPECTOR;
|
|
}
|
|
"||" { return DOUBLE_PIPE; }
|
|
"|" { return PIPE; }
|
|
"(" { return LPAREN; }
|
|
")" { return RPAREN; }
|
|
[ \t]*"="[ \t]* { return EQUALS; } // Allow optional whitespace around equals
|
|
(\\.|[^=\|\(\) \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
|
|
{
|
|
unescaped.push_back(token[i]);
|
|
}
|
|
}
|
|
|
|
deviceSpecplval.str = strdup(unescaped.c_str());
|
|
return STRING;
|
|
}
|
|
\r?\n { /* ignore newlines */ }
|
|
[ \t]+ { /* ignore whitespace */ }
|
|
. { return yytext[0]; }
|
|
%%
|
|
|
|
int deviceSpeclwrap(void)
|
|
{
|
|
return 1; // Indicate end of input
|
|
}
|