Files
salmanoff/hcore/deviceManager/deviceSpecl.ll
T

61 lines
1.5 KiB
LLVM

%option prefix="deviceSpecl"
%option nounput
%option noinput
%{
#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
}