/* Generated by re2c 4.5 on Fri Mar 27 22:42:11 2026 */
#line 1 "../../lnav/src/log_level_re.re"
/**
 * Copyright (c) 2018, Timothy Stack
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 * * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 * * Neither the name of Timothy Stack nor the names of its contributors
 * may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "config.h"

#include <string.h>

#include "log_level.hh"

log_level_t string2level(const char *levelstr, ssize_t len, bool exact)
{
    log_level_t retval = LEVEL_UNKNOWN;

    if (len == (ssize_t)-1) {
        len = strlen(levelstr);
    }

    if (((len == 1) || ((len > 1) && (levelstr[1] == ' '))) &&
        (retval = abbrev2level(levelstr, 1)) != LEVEL_UNKNOWN) {
        return retval;
    }

#   define YYCTYPE unsigned char
#   define RET(tok) { \
        return tok; \
    }

    const YYCTYPE *YYCURSOR = (const unsigned char *) levelstr;
    const YYCTYPE *YYLIMIT = (const unsigned char *) levelstr + len;
    const YYCTYPE *YYMARKER = YYCURSOR;
    const YYCTYPE *debug_level = nullptr;

#   define YYPEEK()    (YYCURSOR < YYLIMIT ? *YYCURSOR : 0)
#   define YYSKIP()    ++YYCURSOR
#   define YYBACKUP()  YYMARKER = YYCURSOR
#   define YYRESTORE() YYCURSOR = YYMARKER
#   define YYSTAGP(x)  x = YYCURSOR - 1

    
#line 69 "../../lnav/src/log_level_re.cc"
#line 65 "../../lnav/src/log_level_re.re"

    loop:
    
#line 74 "../../lnav/src/log_level_re.cc"
{
	YYCTYPE yych;
	unsigned int yyaccept = 0;
	yych = YYPEEK();
	if (yych <= 'W') {
		if (yych <= 'I') {
			if (yych <= 'C') {
				if (yych <= '@') {
					if (yych >= 0x01) goto yy1;
				} else {
					if (yych <= 'A') goto yy3;
					if (yych <= 'B') goto yy1;
					goto yy4;
				}
			} else {
				if (yych <= 'E') {
					if (yych <= 'D') goto yy5;
					goto yy6;
				} else {
					if (yych <= 'F') goto yy7;
					if (yych <= 'H') goto yy1;
					goto yy8;
				}
			}
		} else {
			if (yych <= 'R') {
				if (yych <= 'L') {
					if (yych <= 'K') goto yy1;
					goto yy9;
				} else {
					if (yych == 'N') goto yy10;
					goto yy1;
				}
			} else {
				if (yych <= 'T') {
					if (yych <= 'S') goto yy11;
					goto yy12;
				} else {
					if (yych <= 'U') goto yy1;
					if (yych <= 'V') goto yy13;
					goto yy14;
				}
			}
		}
	} else {
		if (yych <= 'k') {
			if (yych <= 'd') {
				if (yych <= 'a') {
					if (yych <= '`') goto yy1;
					goto yy3;
				} else {
					if (yych <= 'b') goto yy1;
					if (yych <= 'c') goto yy4;
					goto yy5;
				}
			} else {
				if (yych <= 'f') {
					if (yych <= 'e') goto yy6;
					goto yy7;
				} else {
					if (yych == 'i') goto yy8;
					goto yy1;
				}
			}
		} else {
			if (yych <= 's') {
				if (yych <= 'm') {
					if (yych <= 'l') goto yy9;
					goto yy1;
				} else {
					if (yych <= 'n') goto yy10;
					if (yych <= 'r') goto yy1;
					goto yy11;
				}
			} else {
				if (yych <= 'u') {
					if (yych <= 't') goto yy12;
					goto yy1;
				} else {
					if (yych <= 'v') goto yy13;
					if (yych <= 'w') goto yy14;
					goto yy1;
				}
			}
		}
	}
	YYSKIP();
#line 74 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_UNKNOWN); }
#line 164 "../../lnav/src/log_level_re.cc"
yy1:
	YYSKIP();
yy2:
#line 101 "../../lnav/src/log_level_re.re"
	{ goto loop; }
#line 170 "../../lnav/src/log_level_re.cc"
yy3:
	yyaccept = 0;
	YYSKIP();
	YYBACKUP();
	yych = YYPEEK();
	if (yych == 'L') goto yy15;
	if (yych == 'l') goto yy15;
	goto yy2;
yy4:
	yyaccept = 0;
	YYSKIP();
	YYBACKUP();
	yych = YYPEEK();
	if (yych == 'R') goto yy17;
	if (yych == 'r') goto yy17;
	goto yy2;
yy5:
	yyaccept = 0;
	YYSKIP();
	YYBACKUP();
	yych = YYPEEK();
	if (yych == 'E') goto yy18;
	if (yych == 'e') goto yy18;
	goto yy2;
yy6:
	yyaccept = 0;
	YYSKIP();
	YYBACKUP();
	yych = YYPEEK();
	if (yych <= 'R') {
		if (yych == 'M') goto yy19;
		if (yych <= 'Q') goto yy2;
		goto yy20;
	} else {
		if (yych <= 'm') {
			if (yych <= 'l') goto yy2;
			goto yy19;
		} else {
			if (yych == 'r') goto yy20;
			goto yy2;
		}
	}
yy7:
	yyaccept = 0;
	YYSKIP();
	YYBACKUP();
	yych = YYPEEK();
	if (yych == 'A') goto yy21;
	if (yych == 'a') goto yy21;
	goto yy2;
yy8:
	yyaccept = 0;
	YYSKIP();
	YYBACKUP();
	yych = YYPEEK();
	if (yych == 'N') goto yy22;
	if (yych == 'n') goto yy22;
	goto yy2;
yy9:
	yyaccept = 0;
	YYSKIP();
	YYBACKUP();
	yych = YYPEEK();
	if (yych == 'O') goto yy23;
	if (yych == 'o') goto yy23;
	goto yy2;
yy10:
	yyaccept = 0;
	YYSKIP();
	YYBACKUP();
	yych = YYPEEK();
	if (yych == 'O') goto yy24;
	if (yych == 'o') goto yy24;
	goto yy2;
yy11:
	yyaccept = 0;
	YYSKIP();
	YYBACKUP();
	yych = YYPEEK();
	if (yych <= 'Y') {
		if (yych <= 'S') {
			if (yych == 'E') goto yy25;
			goto yy2;
		} else {
			if (yych <= 'T') goto yy26;
			if (yych <= 'X') goto yy2;
			goto yy27;
		}
	} else {
		if (yych <= 's') {
			if (yych == 'e') goto yy25;
			goto yy2;
		} else {
			if (yych <= 't') goto yy26;
			if (yych == 'y') goto yy27;
			goto yy2;
		}
	}
yy12:
	yyaccept = 0;
	YYSKIP();
	YYBACKUP();
	yych = YYPEEK();
	if (yych == 'R') goto yy28;
	if (yych == 'r') goto yy28;
	goto yy2;
yy13:
	yyaccept = 0;
	YYSKIP();
	YYBACKUP();
	yych = YYPEEK();
	if (yych == 'E') goto yy29;
	if (yych == 'e') goto yy29;
	goto yy2;
yy14:
	yyaccept = 0;
	YYSKIP();
	YYBACKUP();
	yych = YYPEEK();
	if (yych == 'A') goto yy30;
	if (yych == 'a') goto yy30;
	goto yy2;
yy15:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'E') goto yy31;
	if (yych == 'e') goto yy31;
yy16:
	YYRESTORE();
	if (yyaccept <= 1) {
		if (yyaccept == 0) goto yy2;
		else goto yy37;
	} else {
		goto yy67;
	}
yy17:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'I') goto yy32;
	if (yych == 'i') goto yy32;
	goto yy16;
yy18:
	YYSKIP();
	yych = YYPEEK();
	if (yych <= 'P') {
		if (yych == 'B') goto yy33;
		if (yych <= 'O') goto yy16;
		goto yy34;
	} else {
		if (yych <= 'b') {
			if (yych <= 'a') goto yy16;
			goto yy33;
		} else {
			if (yych == 'p') goto yy34;
			goto yy16;
		}
	}
yy19:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'E') goto yy35;
	if (yych == 'e') goto yy35;
	goto yy16;
yy20:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'R') goto yy36;
	if (yych == 'r') goto yy36;
	goto yy16;
yy21:
	YYSKIP();
	yych = YYPEEK();
	if (yych <= 'T') {
		if (yych == 'I') goto yy38;
		if (yych <= 'S') goto yy16;
		goto yy39;
	} else {
		if (yych <= 'i') {
			if (yych <= 'h') goto yy16;
			goto yy38;
		} else {
			if (yych == 't') goto yy39;
			goto yy16;
		}
	}
yy22:
	YYSKIP();
	yych = YYPEEK();
	if (yych <= 'V') {
		if (yych == 'F') goto yy40;
		if (yych <= 'U') goto yy16;
		goto yy41;
	} else {
		if (yych <= 'f') {
			if (yych <= 'e') goto yy16;
			goto yy40;
		} else {
			if (yych == 'v') goto yy41;
			goto yy16;
		}
	}
yy23:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'G') goto yy42;
	if (yych == 'g') goto yy42;
	goto yy16;
yy24:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'T') goto yy43;
	if (yych == 't') goto yy43;
	goto yy16;
yy25:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'V') goto yy44;
	if (yych == 'v') goto yy44;
	goto yy16;
yy26:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'A') goto yy45;
	if (yych == 'a') goto yy45;
	goto yy16;
yy27:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'S') goto yy46;
	if (yych == 's') goto yy46;
	goto yy16;
yy28:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'A') goto yy47;
	if (yych == 'a') goto yy47;
	goto yy16;
yy29:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'R') goto yy48;
	if (yych == 'r') goto yy48;
	goto yy16;
yy30:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'R') goto yy49;
	if (yych == 'r') goto yy49;
	goto yy16;
yy31:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'R') goto yy50;
	if (yych == 'r') goto yy50;
	goto yy16;
yy32:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'T') goto yy51;
	if (yych == 't') goto yy51;
	goto yy16;
yy33:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'U') goto yy52;
	if (yych == 'u') goto yy52;
	goto yy16;
yy34:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'R') goto yy53;
	if (yych == 'r') goto yy53;
	goto yy16;
yy35:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'R') goto yy54;
	if (yych == 'r') goto yy54;
	goto yy16;
yy36:
	yyaccept = 1;
	YYSKIP();
	YYBACKUP();
	yych = YYPEEK();
	if (yych == 'O') goto yy55;
	if (yych == 'o') goto yy55;
yy37:
#line 97 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_ERROR); }
#line 460 "../../lnav/src/log_level_re.cc"
yy38:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'L') goto yy56;
	if (yych == 'l') goto yy56;
	goto yy16;
yy39:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'A') goto yy57;
	if (yych == 'a') goto yy57;
	goto yy16;
yy40:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'O') goto yy58;
	if (yych == 'o') goto yy58;
	goto yy16;
yy41:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'A') goto yy59;
	if (yych == 'a') goto yy59;
	goto yy16;
yy42:
	YYSKIP();
#line 94 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_NOTICE); }
#line 489 "../../lnav/src/log_level_re.cc"
yy43:
	YYSKIP();
	yych = YYPEEK();
	if (yych <= 'I') {
		if (yych == 'E') goto yy42;
		if (yych <= 'H') goto yy16;
		goto yy60;
	} else {
		if (yych <= 'e') {
			if (yych <= 'd') goto yy16;
			goto yy42;
		} else {
			if (yych == 'i') goto yy60;
			goto yy16;
		}
	}
yy44:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'E') goto yy61;
	if (yych == 'e') goto yy61;
	goto yy16;
yy45:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'T') goto yy62;
	if (yych == 't') goto yy62;
	goto yy16;
yy46:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'T') goto yy63;
	if (yych == 't') goto yy63;
	goto yy16;
yy47:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'C') goto yy64;
	if (yych == 'c') goto yy64;
	goto yy16;
yy48:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'B') goto yy65;
	if (yych == 'b') goto yy65;
	goto yy16;
yy49:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'N') goto yy66;
	if (yych == 'n') goto yy66;
	goto yy16;
yy50:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'T') goto yy68;
	if (yych == 't') goto yy68;
	goto yy16;
yy51:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'I') goto yy69;
	if (yych == 'i') goto yy69;
	goto yy16;
yy52:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'G') goto yy70;
	if (yych == 'g') goto yy70;
	goto yy16;
yy53:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'E') goto yy72;
	if (yych == 'e') goto yy72;
	goto yy16;
yy54:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'G') goto yy73;
	if (yych == 'g') goto yy73;
	goto yy16;
yy55:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'R') goto yy56;
	if (yych != 'r') goto yy16;
yy56:
	YYSKIP();
	goto yy37;
yy57:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'L') goto yy74;
	if (yych == 'l') goto yy74;
	goto yy16;
yy58:
	YYSKIP();
#line 93 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_INFO); }
#line 590 "../../lnav/src/log_level_re.cc"
yy59:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'L') goto yy75;
	if (yych == 'l') goto yy75;
	goto yy16;
yy60:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'C') goto yy76;
	if (yych == 'c') goto yy76;
	goto yy16;
yy61:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'R') goto yy77;
	if (yych == 'r') goto yy77;
	goto yy16;
yy62:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'S') goto yy78;
	if (yych == 's') goto yy78;
	goto yy16;
yy63:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'E') goto yy79;
	if (yych == 'e') goto yy79;
	goto yy16;
yy64:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'E') goto yy80;
	if (yych == 'e') goto yy80;
	goto yy16;
yy65:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'O') goto yy81;
	if (yych == 'o') goto yy81;
	goto yy16;
yy66:
	yyaccept = 2;
	YYSKIP();
	YYBACKUP();
	yych = YYPEEK();
	if (yych == 'I') goto yy82;
	if (yych == 'i') goto yy82;
yy67:
#line 96 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_WARNING); }
#line 643 "../../lnav/src/log_level_re.cc"
yy68:
	YYSKIP();
#line 98 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_CRITICAL); }
#line 648 "../../lnav/src/log_level_re.cc"
yy69:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'C') goto yy83;
	if (yych == 'c') goto yy83;
	goto yy16;
yy70:
	YYSKIP();
	yych = YYPEEK();
	if (yych <= '1') goto yy71;
	if (yych <= '5') goto yy84;
yy71:
	YYSTAGP(debug_level);
#line 76 "../../lnav/src/log_level_re.re"
	{
         if (debug_level == nullptr) {
             RET(LEVEL_DEBUG);
         }
         switch (*debug_level) {
         case '2':
             RET(LEVEL_DEBUG2);
         case '3':
             RET(LEVEL_DEBUG3);
         case '4':
             RET(LEVEL_DEBUG4);
         case '5':
             RET(LEVEL_DEBUG5);
         default:
             RET(LEVEL_DEBUG);
         }
     }
#line 680 "../../lnav/src/log_level_re.cc"
yy72:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'C') goto yy85;
	if (yych == 'c') goto yy85;
	goto yy16;
yy73:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'E') goto yy86;
	if (yych == 'e') goto yy86;
	goto yy16;
yy74:
	YYSKIP();
#line 99 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_FATAL); }
#line 697 "../../lnav/src/log_level_re.cc"
yy75:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'I') goto yy87;
	if (yych == 'i') goto yy87;
	goto yy16;
yy76:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'E') goto yy42;
	if (yych == 'e') goto yy42;
	goto yy16;
yy77:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'E') goto yy68;
	if (yych == 'e') goto yy68;
	goto yy16;
yy78:
	YYSKIP();
#line 95 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_STATS); }
#line 720 "../../lnav/src/log_level_re.cc"
yy79:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'M') goto yy58;
	if (yych == 'm') goto yy58;
	goto yy16;
yy80:
	YYSKIP();
#line 75 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_TRACE); }
#line 731 "../../lnav/src/log_level_re.cc"
yy81:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'S') goto yy64;
	if (yych == 's') goto yy64;
	goto yy16;
yy82:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'N') goto yy88;
	if (yych == 'n') goto yy88;
	goto yy16;
yy83:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'A') goto yy89;
	if (yych == 'a') goto yy89;
	goto yy16;
yy84:
	YYSKIP();
	goto yy71;
yy85:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'A') goto yy90;
	if (yych == 'a') goto yy90;
	goto yy16;
yy86:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'N') goto yy91;
	if (yych == 'n') goto yy91;
	goto yy16;
yy87:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'D') goto yy92;
	if (yych == 'd') goto yy92;
	goto yy16;
yy88:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'G') goto yy93;
	if (yych == 'g') goto yy93;
	goto yy16;
yy89:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'L') goto yy68;
	if (yych == 'l') goto yy68;
	goto yy16;
yy90:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'T') goto yy94;
	if (yych == 't') goto yy94;
	goto yy16;
yy91:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'C') goto yy95;
	if (yych == 'c') goto yy95;
	goto yy16;
yy92:
	YYSKIP();
#line 100 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_INVALID); }
#line 799 "../../lnav/src/log_level_re.cc"
yy93:
	YYSKIP();
	goto yy67;
yy94:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'I') goto yy96;
	if (yych == 'i') goto yy96;
	goto yy16;
yy95:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'Y') goto yy74;
	if (yych == 'y') goto yy74;
	goto yy16;
yy96:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'O') goto yy97;
	if (yych != 'o') goto yy16;
yy97:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'N') goto yy93;
	if (yych == 'n') goto yy93;
	goto yy16;
}
#line 103 "../../lnav/src/log_level_re.re"

}
