a45728 | 2010-06-10 | Arne Goedeke | |
|
2bae3a | 2010-06-10 | Martin Stjernholm | | #line 1 "rl/json_parser.rl"
|
a45728 | 2010-06-10 | Arne Goedeke | |
#include "mapping.h"
#include "operators.h"
#include "object.h"
#include "array.h"
#include "builtin_functions.h"
#include "gc.h"
|
2bae3a | 2010-06-10 | Martin Stjernholm | | static ptrdiff_t _parse_JSON(PCHARP str, ptrdiff_t p, ptrdiff_t pe, struct parser_state *state);
|
a45728 | 2010-06-10 | Arne Goedeke | |
|
2bae3a | 2010-06-10 | Martin Stjernholm | | #include "json_string_utf8.c"
|
a45728 | 2010-06-10 | Arne Goedeke | | #include "json_string.c"
#include "json_number.c"
#include "json_array.c"
#include "json_mapping.c"
|
b56cb9 | 2010-06-10 | Arne Goedeke | | #line 42 "rl/json_parser.rl"
|
a45728 | 2010-06-10 | Arne Goedeke | |
|
2bae3a | 2010-06-10 | Martin Stjernholm | | static ptrdiff_t _parse_JSON(PCHARP str, ptrdiff_t p, ptrdiff_t pe, struct parser_state *state) {
p_wchar2 i = p;
|
a45728 | 2010-06-10 | Arne Goedeke | | int cs;
int c = 0;
|
b56cb9 | 2010-06-10 | Arne Goedeke | | #line 31 "json_parser.c"
|
a45728 | 2010-06-10 | Arne Goedeke | | static const int JSON_start = 1;
static const int JSON_first_final = 12;
static const int JSON_error = 0;
static const int JSON_en_main = 1;
|
b56cb9 | 2010-06-10 | Arne Goedeke | | #line 49 "rl/json_parser.rl"
|
a45728 | 2010-06-10 | Arne Goedeke | |
|
b56cb9 | 2010-06-10 | Arne Goedeke | | #line 42 "json_parser.c"
|
a45728 | 2010-06-10 | Arne Goedeke | | {
cs = JSON_start;
}
|
b56cb9 | 2010-06-10 | Arne Goedeke | | #line 51 "rl/json_parser.rl"
|
a45728 | 2010-06-10 | Arne Goedeke | |
|
b56cb9 | 2010-06-10 | Arne Goedeke | | #line 49 "json_parser.c"
|
a45728 | 2010-06-10 | Arne Goedeke | | {
if ( p == pe )
goto _test_eof;
switch ( cs )
{
st1:
if ( ++p == pe )
goto _test_eof1;
case 1:
|
2bae3a | 2010-06-10 | Martin Stjernholm | | switch( ( ((int)INDEX_PCHARP(str, p))) ) {
|
a45728 | 2010-06-10 | Arne Goedeke | | case 13: goto st1;
case 32: goto st1;
case 34: goto tr2;
case 43: goto tr3;
case 91: goto tr4;
case 102: goto st2;
case 110: goto st6;
case 116: goto st9;
case 123: goto tr8;
}
|
2bae3a | 2010-06-10 | Martin Stjernholm | | if ( ( ((int)INDEX_PCHARP(str, p))) < 45 ) {
if ( 9 <= ( ((int)INDEX_PCHARP(str, p))) && ( ((int)INDEX_PCHARP(str, p))) <= 10 )
|
a45728 | 2010-06-10 | Arne Goedeke | | goto st1;
|
2bae3a | 2010-06-10 | Martin Stjernholm | | } else if ( ( ((int)INDEX_PCHARP(str, p))) > 46 ) {
if ( 48 <= ( ((int)INDEX_PCHARP(str, p))) && ( ((int)INDEX_PCHARP(str, p))) <= 57 )
|
a45728 | 2010-06-10 | Arne Goedeke | | goto tr3;
} else
goto tr3;
goto st0;
st0:
cs = 0;
goto _out;
tr2:
|
b56cb9 | 2010-06-10 | Arne Goedeke | | #line 25 "rl/json_parser.rl"
|
2bae3a | 2010-06-10 | Martin Stjernholm | | { PARSE_STRING(p); {p = (( i))-1;} }
|
a45728 | 2010-06-10 | Arne Goedeke | | goto st12;
tr3:
|
b56cb9 | 2010-06-10 | Arne Goedeke | | #line 26 "rl/json_parser.rl"
|
a45728 | 2010-06-10 | Arne Goedeke | | { PARSE(number, p); {p = (( i))-1;} }
goto st12;
tr4:
|
b56cb9 | 2010-06-10 | Arne Goedeke | | #line 28 "rl/json_parser.rl"
|
a45728 | 2010-06-10 | Arne Goedeke | | { PARSE(array, p); {p = (( i))-1;} }
goto st12;
tr8:
|
b56cb9 | 2010-06-10 | Arne Goedeke | | #line 27 "rl/json_parser.rl"
|
a45728 | 2010-06-10 | Arne Goedeke | | { PARSE(mapping, p); {p = (( i))-1;} }
goto st12;
tr12:
|
b56cb9 | 2010-06-10 | Arne Goedeke | | #line 31 "rl/json_parser.rl"
{ PUSH_SPECIAL(false); }
|
a45728 | 2010-06-10 | Arne Goedeke | | goto st12;
tr15:
|
b56cb9 | 2010-06-10 | Arne Goedeke | | #line 32 "rl/json_parser.rl"
{ PUSH_SPECIAL(null); }
|
a45728 | 2010-06-10 | Arne Goedeke | | goto st12;
tr18:
|
b56cb9 | 2010-06-10 | Arne Goedeke | | #line 30 "rl/json_parser.rl"
{ PUSH_SPECIAL(true); }
|
a45728 | 2010-06-10 | Arne Goedeke | | goto st12;
st12:
if ( ++p == pe )
goto _test_eof12;
case 12:
|
b56cb9 | 2010-06-10 | Arne Goedeke | | #line 114 "json_parser.c"
|
2bae3a | 2010-06-10 | Martin Stjernholm | | switch( ( ((int)INDEX_PCHARP(str, p))) ) {
|
a45728 | 2010-06-10 | Arne Goedeke | | case 13: goto st12;
case 32: goto st12;
}
|
2bae3a | 2010-06-10 | Martin Stjernholm | | if ( 9 <= ( ((int)INDEX_PCHARP(str, p))) && ( ((int)INDEX_PCHARP(str, p))) <= 10 )
|
a45728 | 2010-06-10 | Arne Goedeke | | goto st12;
goto st0;
st2:
if ( ++p == pe )
goto _test_eof2;
case 2:
|
2bae3a | 2010-06-10 | Martin Stjernholm | | if ( ( ((int)INDEX_PCHARP(str, p))) == 97 )
|
a45728 | 2010-06-10 | Arne Goedeke | | goto st3;
goto st0;
st3:
if ( ++p == pe )
goto _test_eof3;
case 3:
|
2bae3a | 2010-06-10 | Martin Stjernholm | | if ( ( ((int)INDEX_PCHARP(str, p))) == 108 )
|
a45728 | 2010-06-10 | Arne Goedeke | | goto st4;
goto st0;
st4:
if ( ++p == pe )
goto _test_eof4;
case 4:
|
2bae3a | 2010-06-10 | Martin Stjernholm | | if ( ( ((int)INDEX_PCHARP(str, p))) == 115 )
|
a45728 | 2010-06-10 | Arne Goedeke | | goto st5;
goto st0;
st5:
if ( ++p == pe )
goto _test_eof5;
case 5:
|
2bae3a | 2010-06-10 | Martin Stjernholm | | if ( ( ((int)INDEX_PCHARP(str, p))) == 101 )
|
a45728 | 2010-06-10 | Arne Goedeke | | goto tr12;
goto st0;
st6:
if ( ++p == pe )
goto _test_eof6;
case 6:
|
2bae3a | 2010-06-10 | Martin Stjernholm | | if ( ( ((int)INDEX_PCHARP(str, p))) == 117 )
|
a45728 | 2010-06-10 | Arne Goedeke | | goto st7;
goto st0;
st7:
if ( ++p == pe )
goto _test_eof7;
case 7:
|
2bae3a | 2010-06-10 | Martin Stjernholm | | if ( ( ((int)INDEX_PCHARP(str, p))) == 108 )
|
a45728 | 2010-06-10 | Arne Goedeke | | goto st8;
goto st0;
st8:
if ( ++p == pe )
goto _test_eof8;
case 8:
|
2bae3a | 2010-06-10 | Martin Stjernholm | | if ( ( ((int)INDEX_PCHARP(str, p))) == 108 )
|
a45728 | 2010-06-10 | Arne Goedeke | | goto tr15;
goto st0;
st9:
if ( ++p == pe )
goto _test_eof9;
case 9:
|
2bae3a | 2010-06-10 | Martin Stjernholm | | if ( ( ((int)INDEX_PCHARP(str, p))) == 114 )
|
a45728 | 2010-06-10 | Arne Goedeke | | goto st10;
goto st0;
st10:
if ( ++p == pe )
goto _test_eof10;
case 10:
|
2bae3a | 2010-06-10 | Martin Stjernholm | | if ( ( ((int)INDEX_PCHARP(str, p))) == 117 )
|
a45728 | 2010-06-10 | Arne Goedeke | | goto st11;
goto st0;
st11:
if ( ++p == pe )
goto _test_eof11;
case 11:
|
2bae3a | 2010-06-10 | Martin Stjernholm | | if ( ( ((int)INDEX_PCHARP(str, p))) == 101 )
|
a45728 | 2010-06-10 | Arne Goedeke | | goto tr18;
goto st0;
}
_test_eof1: cs = 1; goto _test_eof;
_test_eof12: cs = 12; goto _test_eof;
_test_eof2: cs = 2; goto _test_eof;
_test_eof3: cs = 3; goto _test_eof;
_test_eof4: cs = 4; goto _test_eof;
_test_eof5: cs = 5; goto _test_eof;
_test_eof6: cs = 6; goto _test_eof;
_test_eof7: cs = 7; goto _test_eof;
_test_eof8: cs = 8; goto _test_eof;
_test_eof9: cs = 9; goto _test_eof;
_test_eof10: cs = 10; goto _test_eof;
_test_eof11: cs = 11; goto _test_eof;
_test_eof: {}
_out: {}
}
|
b56cb9 | 2010-06-10 | Arne Goedeke | | #line 52 "rl/json_parser.rl"
|
a45728 | 2010-06-10 | Arne Goedeke | |
if (cs >= JSON_first_final) {
|
b56cb9 | 2010-06-10 | Arne Goedeke | | return p;
|
a45728 | 2010-06-10 | Arne Goedeke | | }
|
2bae3a | 2010-06-10 | Martin Stjernholm | | if (!(state->flags&JSON_VALIDATE) && c > 0) pop_n_elems(c);
|
a45728 | 2010-06-10 | Arne Goedeke | |
|
2bae3a | 2010-06-10 | Martin Stjernholm | | state->flags |= JSON_ERROR;
return p;
|
a45728 | 2010-06-10 | Arne Goedeke | | }
|