/* Generated by re2c 4.1 on Sun Aug 31 06:57:11 2025 */
#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 yy65;
	}
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') goto yy38;
	if (yych == 't') goto yy38;
	goto yy16;
yy22:
	YYSKIP();
	yych = YYPEEK();
	if (yych <= 'V') {
		if (yych == 'F') goto yy39;
		if (yych <= 'U') goto yy16;
		goto yy40;
	} else {
		if (yych <= 'f') {
			if (yych <= 'e') goto yy16;
			goto yy39;
		} else {
			if (yych == 'v') goto yy40;
			goto yy16;
		}
	}
yy23:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'G') goto yy41;
	if (yych == 'g') goto yy41;
	goto yy16;
yy24:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'T') goto yy42;
	if (yych == 't') goto yy42;
	goto yy16;
yy25:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'V') goto yy43;
	if (yych == 'v') goto yy43;
	goto yy16;
yy26:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'A') goto yy44;
	if (yych == 'a') goto yy44;
	goto yy16;
yy27:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'S') goto yy45;
	if (yych == 's') goto yy45;
	goto yy16;
yy28:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'A') goto yy46;
	if (yych == 'a') goto yy46;
	goto yy16;
yy29:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'R') goto yy47;
	if (yych == 'r') goto yy47;
	goto yy16;
yy30:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'R') goto yy48;
	if (yych == 'r') goto yy48;
	goto yy16;
yy31:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'R') goto yy49;
	if (yych == 'r') goto yy49;
	goto yy16;
yy32:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'T') goto yy50;
	if (yych == 't') goto yy50;
	goto yy16;
yy33:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'U') goto yy51;
	if (yych == 'u') goto yy51;
	goto yy16;
yy34:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'R') goto yy52;
	if (yych == 'r') goto yy52;
	goto yy16;
yy35:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'R') goto yy53;
	if (yych == 'r') goto yy53;
	goto yy16;
yy36:
	yyaccept = 1;
	YYSKIP();
	YYBACKUP();
	yych = YYPEEK();
	if (yych == 'O') goto yy54;
	if (yych == 'o') goto yy54;
yy37:
#line 97 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_ERROR); }
#line 450 "../../lnav/src/log_level_re.cc"
yy38:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'A') goto yy55;
	if (yych == 'a') goto yy55;
	goto yy16;
yy39:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'O') goto yy56;
	if (yych == 'o') goto yy56;
	goto yy16;
yy40:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'A') goto yy57;
	if (yych == 'a') goto yy57;
	goto yy16;
yy41:
	YYSKIP();
#line 94 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_NOTICE); }
#line 473 "../../lnav/src/log_level_re.cc"
yy42:
	YYSKIP();
	yych = YYPEEK();
	if (yych <= 'I') {
		if (yych == 'E') goto yy41;
		if (yych <= 'H') goto yy16;
		goto yy58;
	} else {
		if (yych <= 'e') {
			if (yych <= 'd') goto yy16;
			goto yy41;
		} else {
			if (yych == 'i') goto yy58;
			goto yy16;
		}
	}
yy43:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'E') goto yy59;
	if (yych == 'e') goto yy59;
	goto yy16;
yy44:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'T') goto yy60;
	if (yych == 't') goto yy60;
	goto yy16;
yy45:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'T') goto yy61;
	if (yych == 't') goto yy61;
	goto yy16;
yy46:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'C') goto yy62;
	if (yych == 'c') goto yy62;
	goto yy16;
yy47:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'B') goto yy63;
	if (yych == 'b') goto yy63;
	goto yy16;
yy48:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'N') goto yy64;
	if (yych == 'n') goto yy64;
	goto yy16;
yy49:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'T') goto yy66;
	if (yych == 't') goto yy66;
	goto yy16;
yy50:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'I') goto yy67;
	if (yych == 'i') goto yy67;
	goto yy16;
yy51:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'G') goto yy68;
	if (yych == 'g') goto yy68;
	goto yy16;
yy52:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'E') goto yy70;
	if (yych == 'e') goto yy70;
	goto yy16;
yy53:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'G') goto yy71;
	if (yych == 'g') goto yy71;
	goto yy16;
yy54:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'R') goto yy72;
	if (yych == 'r') goto yy72;
	goto yy16;
yy55:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'L') goto yy73;
	if (yych == 'l') goto yy73;
	goto yy16;
yy56:
	YYSKIP();
#line 93 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_INFO); }
#line 572 "../../lnav/src/log_level_re.cc"
yy57:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'L') goto yy74;
	if (yych == 'l') goto yy74;
	goto yy16;
yy58:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'C') goto yy75;
	if (yych == 'c') goto yy75;
	goto yy16;
yy59:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'R') goto yy76;
	if (yych == 'r') goto yy76;
	goto yy16;
yy60:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'S') goto yy77;
	if (yych == 's') goto yy77;
	goto yy16;
yy61:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'E') goto yy78;
	if (yych == 'e') goto yy78;
	goto yy16;
yy62:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'E') goto yy79;
	if (yych == 'e') goto yy79;
	goto yy16;
yy63:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'O') goto yy80;
	if (yych == 'o') goto yy80;
	goto yy16;
yy64:
	yyaccept = 2;
	YYSKIP();
	YYBACKUP();
	yych = YYPEEK();
	if (yych == 'I') goto yy81;
	if (yych == 'i') goto yy81;
yy65:
#line 96 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_WARNING); }
#line 625 "../../lnav/src/log_level_re.cc"
yy66:
	YYSKIP();
#line 98 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_CRITICAL); }
#line 630 "../../lnav/src/log_level_re.cc"
yy67:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'C') goto yy82;
	if (yych == 'c') goto yy82;
	goto yy16;
yy68:
	YYSKIP();
	yych = YYPEEK();
	if (yych <= '1') goto yy69;
	if (yych <= '5') goto yy83;
yy69:
	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 662 "../../lnav/src/log_level_re.cc"
yy70:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'C') goto yy84;
	if (yych == 'c') goto yy84;
	goto yy16;
yy71:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'E') goto yy85;
	if (yych == 'e') goto yy85;
	goto yy16;
yy72:
	YYSKIP();
	goto yy37;
yy73:
	YYSKIP();
#line 99 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_FATAL); }
#line 682 "../../lnav/src/log_level_re.cc"
yy74:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'I') goto yy86;
	if (yych == 'i') goto yy86;
	goto yy16;
yy75:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'E') goto yy41;
	if (yych == 'e') goto yy41;
	goto yy16;
yy76:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'E') goto yy66;
	if (yych == 'e') goto yy66;
	goto yy16;
yy77:
	YYSKIP();
#line 95 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_STATS); }
#line 705 "../../lnav/src/log_level_re.cc"
yy78:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'M') goto yy56;
	if (yych == 'm') goto yy56;
	goto yy16;
yy79:
	YYSKIP();
#line 75 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_TRACE); }
#line 716 "../../lnav/src/log_level_re.cc"
yy80:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'S') goto yy62;
	if (yych == 's') goto yy62;
	goto yy16;
yy81:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'N') goto yy87;
	if (yych == 'n') goto yy87;
	goto yy16;
yy82:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'A') goto yy88;
	if (yych == 'a') goto yy88;
	goto yy16;
yy83:
	YYSKIP();
	goto yy69;
yy84:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'A') goto yy89;
	if (yych == 'a') goto yy89;
	goto yy16;
yy85:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'N') goto yy90;
	if (yych == 'n') goto yy90;
	goto yy16;
yy86:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'D') goto yy91;
	if (yych == 'd') goto yy91;
	goto yy16;
yy87:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'G') goto yy92;
	if (yych == 'g') goto yy92;
	goto yy16;
yy88:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'L') goto yy66;
	if (yych == 'l') goto yy66;
	goto yy16;
yy89:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'T') goto yy93;
	if (yych == 't') goto yy93;
	goto yy16;
yy90:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'C') goto yy94;
	if (yych == 'c') goto yy94;
	goto yy16;
yy91:
	YYSKIP();
#line 100 "../../lnav/src/log_level_re.re"
	{ RET(LEVEL_INVALID); }
#line 784 "../../lnav/src/log_level_re.cc"
yy92:
	YYSKIP();
	goto yy65;
yy93:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'I') goto yy95;
	if (yych == 'i') goto yy95;
	goto yy16;
yy94:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'Y') goto yy73;
	if (yych == 'y') goto yy73;
	goto yy16;
yy95:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'O') goto yy96;
	if (yych != 'o') goto yy16;
yy96:
	YYSKIP();
	yych = YYPEEK();
	if (yych == 'N') goto yy92;
	if (yych == 'n') goto yy92;
	goto yy16;
}
#line 103 "../../lnav/src/log_level_re.re"

}
