diff options
author | June McEnroe <june@causal.agency> | 2021-01-13 16:04:52 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2021-01-13 16:04:52 -0500 |
commit | 9775ce4b5d2afe9d8ef4ca6ba8e06571d55ddba6 (patch) | |
tree | 444495dbf3e9789d0122fdfb35525c12d1bb071c /bin | |
parent | Try to return strings as single tokens (diff) | |
download | src-9775ce4b5d2afe9d8ef4ca6ba8e06571d55ddba6.tar.gz src-9775ce4b5d2afe9d8ef4ca6ba8e06571d55ddba6.zip |
Move text "lexer" to hilex.c
Diffstat (limited to '')
-rw-r--r-- | bin/Makefile | 1 | ||||
-rw-r--r-- | bin/hilex.c | 8 | ||||
-rw-r--r-- | bin/hilex.h | 1 | ||||
-rw-r--r-- | bin/text.l | 35 |
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 afcc5000..a5c682ac 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 5998e6a4..2a8d4ec0 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 e3d64814..00000000 --- a/bin/text.l +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 2020 C. 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 }; |