summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-01-13 16:04:52 -0500
committerJune McEnroe <june@causal.agency>2021-01-13 16:04:52 -0500
commit29b578e6cdede6d9777b8dcf20d09b4aec10ba6c (patch)
treec602b18e2af839d5acc4af227ad424f0192cfcc8
parentTry to return strings as single tokens (diff)
downloadsrc-29b578e6cdede6d9777b8dcf20d09b4aec10ba6c.tar.gz
src-29b578e6cdede6d9777b8dcf20d09b4aec10ba6c.zip
Move text "lexer" to hilex.c
Diffstat (limited to '')
-rw-r--r--bin/Makefile1
-rw-r--r--bin/hilex.c8
-rw-r--r--bin/hilex.h1
-rw-r--r--bin/text.l35
4 files changed, 8 insertions, 37 deletions
diff --git a/bin/Makefile b/bin/Makefile
index 6220ec06..9cdf9848 100644
--- a/bin/Makefile
+++ b/bin/Makefile
@@ -88,7 +88,6 @@ OBJS.hilex += c11.o
 OBJS.hilex += hilex.o
 OBJS.hilex += make.o
 OBJS.hilex += mdoc.o
-OBJS.hilex += text.o
 
 hilex: ${OBJS.hilex}
 	${CC} ${LDFLAGS} ${OBJS.$@} ${LDLIBS.$@} -o $@
diff --git a/bin/hilex.c b/bin/hilex.c
index e91442f6..39025961 100644
--- a/bin/hilex.c
+++ b/bin/hilex.c
@@ -35,6 +35,14 @@ static const char *Class[] = {
 #undef X
 };
 
+static FILE *yyin;
+static char *yytext;
+static int yylex(void) {
+	static size_t cap = 0;
+	return (getline(&yytext, &cap, yyin) < 0 ? None : Normal);
+}
+static const struct Lexer LexText = { yylex, &yyin, &yytext };
+
 static const struct {
 	const struct Lexer *lexer;
 	const char *name;
diff --git a/bin/hilex.h b/bin/hilex.h
index 2e463be7..fc969e5f 100644
--- a/bin/hilex.h
+++ b/bin/hilex.h
@@ -47,4 +47,3 @@ struct Lexer {
 extern const struct Lexer LexC;
 extern const struct Lexer LexMake;
 extern const struct Lexer LexMdoc;
-extern const struct Lexer LexText;
diff --git a/bin/text.l b/bin/text.l
deleted file mode 100644
index 78ebb7a2..00000000
--- a/bin/text.l
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (C) 2020  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 prefix="text"
-%option noyywrap
-
-%{
-#include "hilex.h"
-%}
-
-%%
-
-.*"\n"? { return Normal; }
-
-%{
-	(void)yyunput;
-	(void)input;
-%}
-
-%%
-
-const struct Lexer LexText = { yylex, &yyin, &yytext };