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

File Contents

Contents of /Public_Parser_JSON2-0.8/json_mapping.c:

#line 1 "src/json_mapping.rl"
// vim:syntax=ragel


#line 53 "src/json_mapping.rl"


p_wchar2 *_parse_JSON_mapping(p_wchar2 *p, p_wchar2 *pe, struct parser_state *state) {
    p_wchar2 *i = p;
    struct mapping *m;
    int cs;
    int c = 0;

    
#line 16 "work/json_mapping.c"
static const int JSON_mapping_start = 1;
static const int JSON_mapping_first_final = 6;
static const int JSON_mapping_error = 0;

static const int JSON_mapping_en_main = 1;

#line 62 "src/json_mapping.rl"

    if (!state->validate) {
	m = debug_allocate_mapping(5);
    }

    
#line 30 "work/json_mapping.c"
	{
	cs = JSON_mapping_start;
	}
#line 68 "src/json_mapping.rl"
    
#line 36 "work/json_mapping.c"
	{
	if ( p == pe )
		goto _out;
	switch ( cs )
	{
case 1:
	if ( (*p) == 123 )
		goto st2;
	goto st0;
st0:
	goto _out0;
st2:
	if ( ++p == pe )
		goto _out2;
case 2:
	switch( (*p) ) {
		case 13: goto st2;
		case 32: goto st2;
		case 34: goto tr2;
		case 125: goto st6;
	}
	if ( 9 <= (*p) && (*p) <= 10 )
		goto st2;
	goto st0;
tr2:
#line 24 "src/json_mapping.rl"
	{
	state->level++;
	i = _parse_JSON_string(p, pe, state);
	state->level--;

	if (i == NULL) {
	    goto failure;
	}

	c++;
	{p = (( i))-1;}
    }
	goto st3;
st3:
	if ( ++p == pe )
		goto _out3;
case 3:
#line 80 "work/json_mapping.c"
	switch( (*p) ) {
		case 13: goto st3;
		case 32: goto st3;
		case 58: goto st4;
	}
	if ( 9 <= (*p) && (*p) <= 10 )
		goto st3;
	goto st0;
st4:
	if ( ++p == pe )
		goto _out4;
case 4:
	switch( (*p) ) {
		case 13: goto st4;
		case 32: goto st4;
		case 34: goto tr6;
		case 43: goto tr6;
		case 91: goto tr6;
		case 102: goto tr6;
		case 116: goto tr6;
		case 123: goto tr6;
	}
	if ( (*p) < 45 ) {
		if ( 9 <= (*p) && (*p) <= 10 )
			goto st4;
	} else if ( (*p) > 46 ) {
		if ( 48 <= (*p) && (*p) <= 57 )
			goto tr6;
	} else
		goto tr6;
	goto st0;
tr6:
#line 8 "src/json_mapping.rl"
	{
	state->level++;
	i = _parse_JSON(p, pe, state);
	state->level--;

	if (i == NULL) {
	    goto failure;
	} else if (!state->validate) {
	    mapping_insert(m, &(Pike_sp[-2]), &(Pike_sp[-1]));
	    pop_2_elems();
	}

	c++;
	{p = (( i))-1;}
    }
	goto st5;
st5:
	if ( ++p == pe )
		goto _out5;
case 5:
#line 134 "work/json_mapping.c"
	switch( (*p) ) {
		case 13: goto st5;
		case 32: goto st5;
		case 44: goto st2;
		case 125: goto st6;
	}
	if ( 9 <= (*p) && (*p) <= 10 )
		goto st5;
	goto st0;
st6:
	if ( ++p == pe )
		goto _out6;
case 6:
#line 52 "src/json_mapping.rl"
	{ goto _out6; }
#line 150 "work/json_mapping.c"
	goto st0;
	}
	_out0: cs = 0; goto _out; 
	_out2: cs = 2; goto _out; 
	_out3: cs = 3; goto _out; 
	_out4: cs = 4; goto _out; 
	_out5: cs = 5; goto _out; 
	_out6: cs = 6; goto _out; 

	_out: {}
	}
#line 69 "src/json_mapping.rl"

    if (cs >= JSON_mapping_first_final) {
	if (!state->validate) {
	    push_mapping(m);
	}
	return p;
    }

    push_int((int)p);

failure:
    if (!state->validate) {
	if (c & 1) stack_pop_keep_top(); // remove key
	free_mapping(m);
    }

    return NULL;
}

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