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.1/json_string.c

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


#line 7 "json.cmod/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;

#line 64 "json_string.rl"


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

    init_string_builder(&s, 1);

#ifdef DEBUG
    printf(">> STRING\nstarting to parse string at %c\n", (char)*p);
#endif

    
#line 30 "json.cmod/json_string.c"
	{
	cs = JSON_string_start;
	}
#line 79 "json_string.rl"
    
#line 36 "json.cmod/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;
	}
	goto tr2;
tr2:
#line 34 "json_string.rl"
	{
	mark = p;
    }
	goto st3;
tr8:
#line 22 "json_string.rl"
	{
	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 38 "json_string.rl"
	{ mark = p + 1; }
	goto st3;
tr13:
#line 13 "json_string.rl"
	{
	temp *= 16;
	temp += HEX2DEC((*p));
    }
#line 18 "json_string.rl"
	{
	string_builder_putchar(&s, temp);
    }
#line 38 "json_string.rl"
	{ mark = p + 1; }
	goto st3;
st3:
	if ( ++p == pe )
		goto _out3;
case 3:
#line 96 "json.cmod/json_string.c"
	switch( (*p) ) {
		case 34: goto tr6;
		case 92: goto tr7;
	}
	goto st3;
tr3:
#line 34 "json_string.rl"
	{
	mark = p;
    }
#line 40 "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.
	    string_builder_append(&s, MKPCHARP(mark, 2), (ptrdiff_t)(p - mark));
#ifdef DEBUG
	    //printf("parsed string: '%.*s'\n", (int)(fpc - mark), mark);
#endif
        }
    }
	goto st9;
tr6:
#line 40 "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.
	    string_builder_append(&s, MKPCHARP(mark, 2), (ptrdiff_t)(p - mark));
#ifdef DEBUG
	    //printf("parsed string: '%.*s'\n", (int)(fpc - mark), mark);
#endif
        }
    }
	goto st9;
st9:
	if ( ++p == pe )
		goto _out9;
case 9:
#line 63 "json_string.rl"
	{ goto _out9; }
#line 142 "json.cmod/json_string.c"
	goto st0;
tr4:
#line 34 "json_string.rl"
	{
	mark = p;
    }
#line 40 "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.
	    string_builder_append(&s, MKPCHARP(mark, 2), (ptrdiff_t)(p - mark));
#ifdef DEBUG
	    //printf("parsed string: '%.*s'\n", (int)(fpc - mark), mark);
#endif
        }
    }
	goto st4;
tr7:
#line 40 "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.
	    string_builder_append(&s, MKPCHARP(mark, 2), (ptrdiff_t)(p - mark));
#ifdef DEBUG
	    //printf("parsed string: '%.*s'\n", (int)(fpc - mark), mark);
#endif
        }
    }
	goto st4;
st4:
	if ( ++p == pe )
		goto _out4;
case 4:
#line 182 "json.cmod/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 9 "json_string.rl"
	{
	temp = HEX2DEC((*p));
    }
	goto st6;
st6:
	if ( ++p == pe )
		goto _out6;
case 6:
#line 218 "json.cmod/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 13 "json_string.rl"
	{
	temp *= 16;
	temp += HEX2DEC((*p));
    }
	goto st7;
st7:
	if ( ++p == pe )
		goto _out7;
case 7:
#line 239 "json.cmod/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 13 "json_string.rl"
	{
	temp *= 16;
	temp += HEX2DEC((*p));
    }
	goto st8;
st8:
	if ( ++p == pe )
		goto _out8;
case 8:
#line 260 "json.cmod/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 80 "json_string.rl"

    if (cs < JSON_string_first_final) {
#ifdef DEBUG
	printf("failed parsing string at %.*s in state %d.\n", MINIMUM(pe - p, 10),p, cs);
#endif
	free_string_builder(&s);

	Pike_error("Failed to parse string at '%c'.\n", (char)*p);
    }

    push_string(finish_string_builder(&s));

#ifdef DEBUG
    printf("stopping parsing string at %c in state %d.\n<< STRING\n", (char)*p, cs);
#endif
    return p;
}

#undef HEX2DEC


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