static int json_lexer_feed_char(JSONLexer *lexer, char ch, bool flush)

{

    int char_consumed, new_state;



    lexer->x++;

    if (ch == '\n') {

        lexer->x = 0;

        lexer->y++;

    }



    do {

        new_state = json_lexer[lexer->state][(uint8_t)ch];

        char_consumed = !TERMINAL_NEEDED_LOOKAHEAD(lexer->state, new_state);

        if (char_consumed) {

            qstring_append_chr(lexer->token, ch);

        }



        switch (new_state) {

        case JSON_OPERATOR:

        case JSON_ESCAPE:

        case JSON_INTEGER:

        case JSON_FLOAT:

        case JSON_KEYWORD:

        case JSON_STRING:

            lexer->emit(lexer, lexer->token, new_state, lexer->x, lexer->y);

        case JSON_SKIP:

            QDECREF(lexer->token);

            lexer->token = qstring_new();

            new_state = IN_START;

            break;

        case IN_ERROR:

            QDECREF(lexer->token);

            lexer->token = qstring_new();

            new_state = IN_START;

            return -EINVAL;

        default:

            break;

        }

        lexer->state = new_state;

    } while (!char_consumed && !flush);



    /* Do not let a single token grow to an arbitrarily large size,

     * this is a security consideration.

     */

    if (lexer->token->length > MAX_TOKEN_SIZE) {

        lexer->emit(lexer, lexer->token, lexer->state, lexer->x, lexer->y);

        QDECREF(lexer->token);

        lexer->token = qstring_new();

        lexer->state = IN_START;

    }



    return 0;

}

static int json_lexer_feed_char(JSONLexer *lexer, char ch, bool flush)

{

    int char_consumed, new_state;



    lexer->x++;

    if (ch == '\n') {

        lexer->x = 0;

        lexer->y++;

    }



    do {

        new_state = json_lexer[lexer->state][(uint8_t)ch];

        char_consumed = !TERMINAL_NEEDED_LOOKAHEAD(lexer->state, new_state);

        if (char_consumed) {

            qstring_append_chr(lexer->token, ch);

        }



        switch (new_state) {

        case JSON_OPERATOR:

        case JSON_ESCAPE:

        case JSON_INTEGER:

        case JSON_FLOAT:

        case JSON_KEYWORD:

        case JSON_STRING:

            lexer->emit(lexer, lexer->token, new_state, lexer->x, lexer->y);

        case JSON_SKIP:

            QDECREF(lexer->token);

            lexer->token = qstring_new();

            new_state = IN_START;

            break;

        case IN_ERROR:

            QDECREF(lexer->token);

            lexer->token = qstring_new();

            new_state = IN_START;

            return -EINVAL;

        default:

            break;

        }

        lexer->state = new_state;

    } while (!char_consumed && !flush);



    





    if (lexer->token->length > MAX_TOKEN_SIZE) {

        lexer->emit(lexer, lexer->token, lexer->state, lexer->x, lexer->y);

        QDECREF(lexer->token);

        lexer->token = qstring_new();

        lexer->state = IN_START;

    }



    return 0;

}

static int FUNC_0(JSONLexer *VAR_0, char VAR_1, bool VAR_2)

{

    int VAR_3, VAR_4;



    VAR_0->x++;

    if (VAR_1 == '\n') {

        VAR_0->x = 0;

        VAR_0->y++;

    }



    do {

        VAR_4 = json_lexer[VAR_0->state][(uint8_t)VAR_1];

        VAR_3 = !TERMINAL_NEEDED_LOOKAHEAD(VAR_0->state, VAR_4);

        if (VAR_3) {

            qstring_append_chr(VAR_0->token, VAR_1);

        }



        switch (VAR_4) {

        case JSON_OPERATOR:

        case JSON_ESCAPE:

        case JSON_INTEGER:

        case JSON_FLOAT:

        case JSON_KEYWORD:

        case JSON_STRING:

            VAR_0->emit(VAR_0, VAR_0->token, VAR_4, VAR_0->x, VAR_0->y);

        case JSON_SKIP:

            QDECREF(VAR_0->token);

            VAR_0->token = qstring_new();

            VAR_4 = IN_START;

            break;

        case IN_ERROR:

            QDECREF(VAR_0->token);

            VAR_0->token = qstring_new();

            VAR_4 = IN_START;

            return -EINVAL;

        default:

            break;

        }

        VAR_0->state = VAR_4;

    } while (!VAR_3 && !VAR_2);



    





    if (VAR_0->token->length > MAX_TOKEN_SIZE) {

        VAR_0->emit(VAR_0, VAR_0->token, VAR_0->state, VAR_0->x, VAR_0->y);

        QDECREF(VAR_0->token);

        VAR_0->token = qstring_new();

        VAR_0->state = IN_START;

    }



    return 0;

}

static int FUNC_0(JSONLexer *VAR_0, char VAR_1, bool VAR_2)
{ int VAR_3, VAR_4; VAR_0->x++; if (VAR_1 == '\n') { VAR_0->x = 0; VAR_0->y++; } do { VAR_4 = json_lexer[VAR_0->state][(uint8_t)VAR_1]; VAR_3 = !TERMINAL_NEEDED_LOOKAHEAD(VAR_0->state, VAR_4); if (VAR_3) { qstring_append_chr(VAR_0->token, VAR_1); } switch (VAR_4) { case JSON_OPERATOR:
case JSON_ESCAPE:
case JSON_INTEGER:
case JSON_FLOAT:
case JSON_KEYWORD:
case JSON_STRING:
VAR_0->emit(VAR_0, VAR_0->token, VAR_4, VAR_0->x, VAR_0->y); case JSON_SKIP:
QDECREF(VAR_0->token); VAR_0->token = qstring_new(); VAR_4 = IN_START; break; case IN_ERROR:
QDECREF(VAR_0->token); VAR_0->token = qstring_new(); VAR_4 = IN_START; return -EINVAL; default:
break; } VAR_0->state = VAR_4; } while (!VAR_3 && !VAR_2); if (VAR_0->token->length > MAX_TOKEN_SIZE) { VAR_0->emit(VAR_0, VAR_0->token, VAR_0->state, VAR_0->x, VAR_0->y); QDECREF(VAR_0->token); VAR_0->token = qstring_new(); VAR_0->state = IN_START; } return 0; }