Home modules.gotpike.org
Username: Password: [Create Account]
[Forgot Password?]

Modules

ADT
Database
GTK2
GUI
IP
PiJAX
Public
Sql
Stdio
Subversion
System
Tools
Xosd
lua
v4l2
wx

Recent Changes

Public.Parser.XML2 1.50
Public.ZeroMQ 1.1
Public.Template.Mustache 1.0
Public.Protocols.XMPP 1.4
Sql.Provider.jdbc 1.0

Popular Downloads

Public.Parser.JSON2 1.0
Public.Parser.JSON 0.2
GTK2 2.23
Public.Web.FCGI 1.8
Public.Parser.XML2 1.48


Module Information
Public.Parser.JSON2
Viewing contents of Public_Parser_JSON2-0.8/json_string.c

#line 1 "src/json_string.rl"
// vim:syntax=ragel
#define HEX2DEC(x) ((x) <= '9' ? (x) - '0' : ((x) < 'G') ? (x) - 'A' + 10 : (x) - 'a' + 10)

#line 69 "src/json_string.rl"


p_wchar2 *_parse_JSON_string(p_wchar2 *p, p_wchar2 *pe, struct parser_state *state) {
    p_wchar2 temp = 0;
    p_wchar2 *mark = 0;
    struct string_builder s;
    int cs;

    
#line 16 "work/json_string.c"
static const int JSON_string_start = 1;
static const int JSON_string_first_final = 9;
static const int JSON_string_error = 0;

static const int JSON_string_en_main = 1;

#line 78 "src/json_string.rl"

    if (!state->validate)
	init_string_builder(&s, 0);

    
#line 29 "work/json_string.c"
	{
	cs = JSON_string_start;
	}
#line 83 "src/json_string.rl"
    
#line 35 "work/json_string.c"
	{
	if ( p == pe )
		goto _out;
	switch ( cs )
	{
case 1:
	if ( (*p) == 34 )
		goto st2;
	goto st0;
st0:
	goto _out0;
st2:
	if ( ++p == pe )
		goto _out2;
case 2:
	switch( (*p) ) {
		case 34: goto tr3;
		case 92: goto tr4;
	}
	if ( (*p) > 55159 ) {
		if ( 57344 <= (*p) && (*p) <= 1114111 )
			goto tr2;
	} else if ( (*p) >= 0 )
		goto tr2;
	goto st0;
tr2:
#line 39 "src/json_string.rl"
	{
	mark = p;
    }
	goto st3;
tr8:
#line 27 "src/json_string.rl"
	{
	if (!state->validate) switch((*p)) {
        case '"':
        case '\\':      string_builder_putchar(&s, (*p)); break;
        case 'b':       string_builder_putchar(&s, '\b'); break;
        case 'f':       string_builder_putchar(&s, '\f'); break;
	case 'n':       string_builder_putchar(&s, '\n'); break;
        case 'r':       string_builder_putchar(&s, '\r'); break;
        case 't':       string_builder_putchar(&s, '\t'); break;
	}
    }
#line 43 "src/json_string.rl"
	{ mark = p + 1; }
	goto st3;
tr13:
#line 12 "src/json_string.rl"
	{
	if (!state->validate) {
	    temp *= 16;
	    temp += HEX2DEC((*p));

	    if (IS_NUNICODE(temp)) {
		goto _out3;
	    }
	}
    }
#line 23 "src/json_string.rl"
	{
	if (!state->validate) string_builder_putchar(&s, temp);
    }
#line 43 "src/json_string.rl"
	{ mark = p + 1; }
	goto st3;
st3:
	if ( ++p == pe )
		goto _out3;
case 3:
#line 106 "work/json_string.c"
	switch( (*p) ) {
		case 34: goto tr6;
		case 92: goto tr7;
	}
	if ( (*p) > 55159 ) {
		if ( 57344 <= (*p) && (*p) <= 1114111 )
			goto st3;
	} else if ( (*p) >= 0 )
		goto st3;
	goto st0;
tr3:
#line 39 "src/json_string.rl"
	{
	mark = p;
    }
#line 45 "src/json_string.rl"
	{
	if (p - mark > 0) {
            //string_builder_binary_strcat(s, mark, (ptrdiff_t)(fpc - mark));

	    // looking for the lowest possible magnitude here may be worth it. i am not entirely
	    // sure if i want to do the copying here.
	    // use string_builder_binary_strcat here
	    if (!state->validate)
		string_builder_append(&s, MKPCHARP(mark, 2), (ptrdiff_t)(p - mark));
        }
    }
	goto st9;
tr6:
#line 45 "src/json_string.rl"
	{
	if (p - mark > 0) {
            //string_builder_binary_strcat(s, mark, (ptrdiff_t)(fpc - mark));

	    // looking for the lowest possible magnitude here may be worth it. i am not entirely
	    // sure if i want to do the copying here.
	    // use string_builder_binary_strcat here
	    if (!state->validate)
		string_builder_append(&s, MKPCHARP(mark, 2), (ptrdiff_t)(p - mark));
        }
    }
	goto st9;
st9:
	if ( ++p == pe )
		goto _out9;
case 9:
#line 68 "src/json_string.rl"
	{ goto _out9; }
#line 155 "work/json_string.c"
	goto st0;
tr4:
#line 39 "src/json_string.rl"
	{
	mark = p;
    }
#line 45 "src/json_string.rl"
	{
	if (p - mark > 0) {
            //string_builder_binary_strcat(s, mark, (ptrdiff_t)(fpc - mark));

	    // looking for the lowest possible magnitude here may be worth it. i am not entirely
	    // sure if i want to do the copying here.
	    // use string_builder_binary_strcat here
	    if (!state->validate)
		string_builder_append(&s, MKPCHARP(mark, 2), (ptrdiff_t)(p - mark));
        }
    }
	goto st4;
tr7:
#line 45 "src/json_string.rl"
	{
	if (p - mark > 0) {
            //string_builder_binary_strcat(s, mark, (ptrdiff_t)(fpc - mark));

	    // looking for the lowest possible magnitude here may be worth it. i am not entirely
	    // sure if i want to do the copying here.
	    // use string_builder_binary_strcat here
	    if (!state->validate)
		string_builder_append(&s, MKPCHARP(mark, 2), (ptrdiff_t)(p - mark));
        }
    }
	goto st4;
st4:
	if ( ++p == pe )
		goto _out4;
case 4:
#line 193 "work/json_string.c"
	switch( (*p) ) {
		case 34: goto tr8;
		case 47: goto tr8;
		case 92: goto tr8;
		case 98: goto tr8;
		case 102: goto tr8;
		case 110: goto tr8;
		case 114: goto tr8;
		case 116: goto tr8;
		case 117: goto st5;
	}
	goto st0;
st5:
	if ( ++p == pe )
		goto _out5;
case 5:
	if ( (*p) < 65 ) {
		if ( 48 <= (*p) && (*p) <= 57 )
			goto tr10;
	} else if ( (*p) > 70 ) {
		if ( 97 <= (*p) && (*p) <= 102 )
			goto tr10;
	} else
		goto tr10;
	goto st0;
tr10:
#line 8 "src/json_string.rl"
	{
	if (!state->validate) temp = HEX2DEC((*p));
    }
	goto st6;
st6:
	if ( ++p == pe )
		goto _out6;
case 6:
#line 229 "work/json_string.c"
	if ( (*p) < 65 ) {
		if ( 48 <= (*p) && (*p) <= 57 )
			goto tr11;
	} else if ( (*p) > 70 ) {
		if ( 97 <= (*p) && (*p) <= 102 )
			goto tr11;
	} else
		goto tr11;
	goto st0;
tr11:
#line 12 "src/json_string.rl"
	{
	if (!state->validate) {
	    temp *= 16;
	    temp += HEX2DEC((*p));

	    if (IS_NUNICODE(temp)) {
		goto _out7;
	    }
	}
    }
	goto st7;
st7:
	if ( ++p == pe )
		goto _out7;
case 7:
#line 256 "work/json_string.c"
	if ( (*p) < 65 ) {
		if ( 48 <= (*p) && (*p) <= 57 )
			goto tr12;
	} else if ( (*p) > 70 ) {
		if ( 97 <= (*p) && (*p) <= 102 )
			goto tr12;
	} else
		goto tr12;
	goto st0;
tr12:
#line 12 "src/json_string.rl"
	{
	if (!state->validate) {
	    temp *= 16;
	    temp += HEX2DEC((*p));

	    if (IS_NUNICODE(temp)) {
		goto _out8;
	    }
	}
    }
	goto st8;
st8:
	if ( ++p == pe )
		goto _out8;
case 8:
#line 283 "work/json_string.c"
	if ( (*p) < 65 ) {
		if ( 48 <= (*p) && (*p) <= 57 )
			goto tr13;
	} else if ( (*p) > 70 ) {
		if ( 97 <= (*p) && (*p) <= 102 )
			goto tr13;
	} else
		goto tr13;
	goto st0;
	}
	_out0: cs = 0; goto _out; 
	_out2: cs = 2; goto _out; 
	_out3: cs = 3; goto _out; 
	_out9: cs = 9; goto _out; 
	_out4: cs = 4; goto _out; 
	_out5: cs = 5; goto _out; 
	_out6: cs = 6; goto _out; 
	_out7: cs = 7; goto _out; 
	_out8: cs = 8; goto _out; 

	_out: {}
	}
#line 84 "src/json_string.rl"

    if (cs < JSON_string_first_final) {
	if (!state->validate) {
	    free_string_builder(&s);
	}

	push_int((int)p);
	return NULL;
    }

    if (!state->validate)
	push_string(finish_string_builder(&s));

    return p;
}

#undef HEX2DEC


gotpike.org | Copyright © 2004 - 2019 | Pike is a trademark of Department of Computer and Information Science, Linköping University