summaryrefslogtreecommitdiff
path: root/2003/i/buzz/src/config/config_lex.ll
diff options
context:
space:
mode:
Diffstat (limited to '2003/i/buzz/src/config/config_lex.ll')
-rw-r--r--2003/i/buzz/src/config/config_lex.ll76
1 files changed, 76 insertions, 0 deletions
diff --git a/2003/i/buzz/src/config/config_lex.ll b/2003/i/buzz/src/config/config_lex.ll
new file mode 100644
index 0000000..31f980e
--- /dev/null
+++ b/2003/i/buzz/src/config/config_lex.ll
@@ -0,0 +1,76 @@
+%{
+
+#include "config_lex.h"
+
+config_yytype config_yylval;
+
+%}
+
+ID [_a-zA-Z][-_a-zA-Z0-9]*
+
+NUM [-+]?[0-9]+
+
+HNUM "0x"[0-9a-fzA-F]+
+
+BNUM "0b"[01]+
+
+FLOAT [-+]?[0-9]*"."[0-9]*
+
+STRING \"[^\n"]\"
+
+%option noyywrap nounput
+%option prefix="config_yy"
+
+%%
+
+{FLOAT} {
+ config_yylval.fl = strtod (config_yytext, 0);
+ return FLOAT;
+}
+
+{BNUM} {
+ config_yylval.num = strtol (config_yytext + 2, 0, 2);
+ return NUM;
+}
+
+{HNUM} {
+ config_yylval.num = strtol (config_yytext + 2, 0, 16);
+ return NUM;
+}
+
+{NUM} {
+ config_yylval.num = strtol (config_yytext, 0, 10);
+ return NUM;
+}
+
+"true" { config_yylval.boolean = true; return BOOL; }
+"false" { config_yylval.boolean = false; return BOOL; }
+
+{ID} {
+ config_yylval.id = config_yytext;
+ return ID;
+}
+
+"#".* /* Commentaires. */
+
+[ \t\n]+ /* Rien à battre. */
+
+. return ERR;
+
+%%
+
+int
+config_yyopen (const char *filename)
+{
+ config_yyin = fopen (filename, "r");
+ if (!config_yyin) return -1;
+ return 0;
+}
+
+void
+config_yyclose (void)
+{
+ fclose (config_yyin);
+}
+
+// vim: ft=lex