%option prefix="deviceSpecl" %option nounput %option noinput %{ #include #include #include #include #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; } "=" { return EQUALS; } // Match "=" on its own (\\.|[^=\|\(\) \t\r\n])+ { std::string token(yytext); std::string unescaped; unescaped.reserve(token.size()); for (size_t i = 0; i < token.size(); ++i) { if (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()); return STRING; } [ \t\r\n]+ { /* ignore all whitespace, including newlines */ } . { return yytext[0]; } %% int deviceSpeclwrap(void) { return 1; // Indicate end of input }