summary refs log tree commit diff
path: root/bin/bitlex.l
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-05-30 22:23:48 -0400
committerJune McEnroe <june@causal.agency>2019-05-30 22:23:48 -0400
commitfb34d727d81485248be40d5282ae0295636018f4 (patch)
tree6400113a06457ed973b98ac3091b07e60003a231 /bin/bitlex.l
parentAdd xx -p option (diff)
downloadsrc-fb34d727d81485248be40d5282ae0295636018f4.tar.gz
src-fb34d727d81485248be40d5282ae0295636018f4.zip
Simplify and build bit
lex is a waste of time.
Diffstat (limited to 'bin/bitlex.l')
-rw-r--r--bin/bitlex.l67
1 files changed, 0 insertions, 67 deletions
diff --git a/bin/bitlex.l b/bin/bitlex.l
deleted file mode 100644
index c6519b39..00000000
--- a/bin/bitlex.l
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Copyright (C) 2019  June McEnroe <june@causal.agency>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-%option noinput
-%option nounput
-
-%{
-
-#include <stdint.h>
-
-static uint64_t parseInt(uint64_t base, const char *str) {
-	uint64_t num = 0;
-	for (const char *ch = str; *ch; ++ch) {
-		if (*ch == '_') continue;
-		num *= base;
-		if (*ch >= '0' && *ch <= '9') num += *ch - '0';
-		if (*ch >= 'A' && *ch <= 'F') num += 0xA + *ch - 'A';
-		if (*ch >= 'a' && *ch <= 'f') num += 0xA + *ch - 'a';
-	}
-	return num;
-}
-
-%}
-
-%%
-
-[ \t\n]	;
-
-0b[01_]+ {
-	yylval = parseInt(2, &yytext[2]);
-	return Int;
-}
-0[0-7_]+ {
-	yylval = parseInt(8, &yytext[1]);
-	return Int;
-}
-[0-9][0-9_]* {
-	yylval = parseInt(10, yytext);
-	return Int;
-}
-0x[0-9A-Fa-f_]+ {
-	yylval = parseInt(16, &yytext[2]);
-	return Int;
-}
-'.' {
-	yylval = yytext[1];
-	return Int;
-}
-
-"<<"	return Shl;
-">>"	return Shr;
-"->>"	return Sar;
-
-.	return yytext[0];