From 79f4b0d33cbb490f957d081bd7c8bc97bd4c689c Mon Sep 17 00:00:00 2001 From: sanine Date: Tue, 7 Feb 2023 17:52:17 -0600 Subject: fix parser using REJECT so that example works --- yy/kalmia.l | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'yy/kalmia.l') diff --git a/yy/kalmia.l b/yy/kalmia.l index 85f68e3..42ab9e1 100644 --- a/yy/kalmia.l +++ b/yy/kalmia.l @@ -1,7 +1,7 @@ -%option noinput nounput noyywrap 8bit nodefault +%option noinput nounput noyywrap noreject 8bit %option reentrant bison-bridge bison-locations %option prefix="kalmia" -%start STRING TAG +%start STRING TAG_START TAG %{ #include @@ -39,18 +39,19 @@ ATTR ([\x20\x0a\x0d\x09]*)?"=" } -"<" { BEGIN(TAG); return S_TAG_OPEN; } -""<" { BEGIN(TAG_START); return S_TAG_OPEN; } +"">" { BEGIN(INITIAL); return TAG_CLOSE; } "/>" { BEGIN(INITIAL); return EMPTY_TAG_CLOSE; } -[a-zA-Z_:][a-zA-Z0-9\.\-_:]* { +[a-zA-Z_:][a-zA-Z0-9\.\-_:]* { /* generic tag name */ + BEGIN(TAG); yylval->string = strdup(yytext); return NAME; } -[a-zA-Z_:][a-zA-Z0-9\.\-_:]*/{ATTR} { +[a-zA-Z_:][a-zA-Z0-9\.\-_:]* { /* generic attribute key */ yylval->string = strdup(yytext); return ATTR; -- cgit v1.2.1