Files
salmanoff/hcore/deviceManager/deviceSpecl.ll
T
hayodea 5c3bbdf114 Devspec: Add lexer and parser for devSpecs
This grammar looks simple but it consumed 2 days of my time
and it's giving me bugs all the same, but mostly working
nicely.

See the syntax documentation in /docs
2025-01-07 14:09:31 -04:00

35 lines
977 B
LLVM

%option prefix="deviceSpecl"
%{
#include <vector>
#include <deviceManager/deviceManager.h>
#include "deviceSpecp.hh"
%}
%%
^a {
deviceSpecplval.chr = yytext[0];
return KEYWORD_SPECTYPE_ACTUATOR;
}
^e {
deviceSpecplval.chr = yytext[0];
return KEYWORD_SPECTYPE_EXTROSPECTOR;
}
^i {
deviceSpecplval.chr = yytext[0];
return KEYWORD_SPECTYPE_INTEROSPECTOR;
}
"||" { return DOUBLE_PIPE; }
"|" { return PIPE; }
"(" { return LPAREN; }
")" { return RPAREN; }
[^\|\(\) \t\r\n]+ { deviceSpecplval.str = strdup(yytext); return STRING; }
\r?\n { /* ignore newlines */ }
[ \t]+ { /* ignore whitespace */ }
. { return yytext[0]; }
%%
int deviceSpeclwrap(void)
{
return 1; // Indicate end of input
}