pike.git / src / post_modules / JSON / rl / json_parser.rl

version» Context lines:

pike.git/src/post_modules/JSON/rl/json_parser.rl:1: - /* vim: syntax=ragel */ + /* vim: syntax=ragel +  */      #include "mapping.h"   #include "operators.h"   #include "object.h"   #include "array.h"   #include "builtin_functions.h"   #include "gc.h"         static ptrdiff_t _parse_JSON(PCHARP str, ptrdiff_t p, ptrdiff_t pe, struct parser_state *state);
pike.git/src/post_modules/JSON/rl/json_parser.rl:20:    machine JSON;    alphtype int;    include JSOND "json_defaults.rl";    getkey ((int)INDEX_PCHARP(str, fpc));       action parse_string { PARSE_STRING(fpc); fexec i; }    action parse_number { PARSE(number, fpc); fexec i; }    action parse_mapping { PARSE(mapping, fpc); fexec i; }    action parse_array { PARSE(array, fpc); fexec i; }    -  action push_true { PUSH_SPECIAL(true); } -  action push_false { PUSH_SPECIAL(false); } -  action push_null { PUSH_SPECIAL(null); } +  action push_true { PUSH_SPECIAL(true, push_int(1)); } +  action push_false { PUSH_SPECIAL(false, push_int(0)); } +  action push_null { PUSH_SPECIAL(null, push_undefined()); }       main := myspace* . (number_start >parse_number |    string_start >parse_string |    mapping_start >parse_mapping |    array_start >parse_array |    json_true @push_true |    json_false @push_false |    json_null @push_null    ) . myspace*;   }%%      static ptrdiff_t _parse_JSON(PCHARP str, ptrdiff_t p, ptrdiff_t pe, struct parser_state *state) { -  p_wchar2 i = p; +  ptrdiff_t i = p;    int cs;    int c = 0;    %% write data;       %% write init;    %% write exec;       if (cs >= JSON_first_final) {    return p;    }    -  +  if ( (state->flags & JSON_FIRST_VALUE) && (c==1) ) +  { +  state->flags &= ~JSON_ERROR; +  return p-1; +  } +     if (!(state->flags&JSON_VALIDATE) && c > 0) pop_n_elems(c);       state->flags |= JSON_ERROR;    return p;   }