From 29b578e6cdede6d9777b8dcf20d09b4aec10ba6c Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Wed, 13 Jan 2021 16:04:52 -0500 Subject: Move text "lexer" to hilex.c --- bin/Makefile | 1 - bin/hilex.c | 8 ++++++++ bin/hilex.h | 1 - bin/text.l | 35 ----------------------------------- 4 files changed, 8 insertions(+), 37 deletions(-) delete mode 100644 bin/text.l 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 - * - * 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 . - */ - -%option prefix="text" -%option noyywrap - -%{ -#include "hilex.h" -%} - -%% - -.*"\n"? { return Normal; } - -%{ - (void)yyunput; - (void)input; -%} - -%% - -const struct Lexer LexText = { yylex, &yyin, &yytext }; -- cgit 1.4.1