summaryrefslogtreecommitdiff
path: root/2003/i/buspctl/src/lexer.l
diff options
context:
space:
mode:
Diffstat (limited to '2003/i/buspctl/src/lexer.l')
-rw-r--r--2003/i/buspctl/src/lexer.l47
1 files changed, 47 insertions, 0 deletions
diff --git a/2003/i/buspctl/src/lexer.l b/2003/i/buspctl/src/lexer.l
new file mode 100644
index 0000000..b4498ad
--- /dev/null
+++ b/2003/i/buspctl/src/lexer.l
@@ -0,0 +1,47 @@
+%{
+#include <grammar.h>
+
+int yyparse (void);
+
+%}
+
+WRITE w|write
+READ r|read
+
+DEC [0-9]+
+HEX 0x[0-9a-fA-F]+
+BIN 0b[01]+
+
+%option noyywrap nounput
+
+%%
+
+{WRITE} {
+ return WRITE;
+}
+
+{READ} {
+ return READ;
+}
+
+{DEC}|{HEX} {
+ yylval = strtol (yytext, 0, 0);
+ return NUM;
+}
+
+{BIN} {
+ yylval = strtol (yytext + 2, 0, 2);
+ return NUM;
+}
+
+[ \t\n]+ /* Rien à battre. */
+
+. return ERR;
+
+%%
+
+int parse_string (const char *s)
+{
+ yy_scan_string (s);
+ return yyparse ();
+}