Ruby  2.4.2p198(2017-09-14revision59899)
Macros | Enumerations | Functions | Variables
parser.c File Reference
#include "../fbuffer/fbuffer.h"
#include "parser.h"
Include dependency graph for parser.c:

Go to the source code of this file.

Macros

#define EXC_ENCODING   rb_utf8_encoding(),
 
#define rb_enc_raise   enc_raise
 

Enumerations

enum  { JSON_object_start = 1 }
 
enum  { JSON_object_first_final = 27 }
 
enum  { JSON_object_error = 0 }
 
enum  { JSON_object_en_main = 1 }
 
enum  { JSON_value_start = 1 }
 
enum  { JSON_value_first_final = 29 }
 
enum  { JSON_value_error = 0 }
 
enum  { JSON_value_en_main = 1 }
 
enum  { JSON_integer_start = 1 }
 
enum  { JSON_integer_first_final = 3 }
 
enum  { JSON_integer_error = 0 }
 
enum  { JSON_integer_en_main = 1 }
 
enum  { JSON_float_start = 1 }
 
enum  { JSON_float_first_final = 8 }
 
enum  { JSON_float_error = 0 }
 
enum  { JSON_float_en_main = 1 }
 
enum  { JSON_array_start = 1 }
 
enum  { JSON_array_first_final = 17 }
 
enum  { JSON_array_error = 0 }
 
enum  { JSON_array_en_main = 1 }
 
enum  { JSON_string_start = 1 }
 
enum  { JSON_string_first_final = 8 }
 
enum  { JSON_string_error = 0 }
 
enum  { JSON_string_en_main = 1 }
 
enum  { JSON_start = 1 }
 
enum  { JSON_first_final = 10 }
 
enum  { JSON_error = 0 }
 
enum  { JSON_en_main = 1 }
 

Functions

static void enc_raise (rb_encoding *enc, VALUE exc, const char *fmt,...)
 
static UTF32 unescape_unicode (const unsigned char *p)
 
static int convert_UTF32_to_UTF8 (char *buf, UTF32 ch)
 
static char * JSON_parse_object (JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
 
static char * JSON_parse_value (JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
 
static char * JSON_parse_integer (JSON_Parser *json, char *p, char *pe, VALUE *result)
 
static char * JSON_parse_float (JSON_Parser *json, char *p, char *pe, VALUE *result)
 
static char * JSON_parse_array (JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
 
static VALUE json_string_unescape (VALUE result, char *string, char *stringEnd)
 
static int match_i (VALUE regexp, VALUE klass, VALUE memo)
 
static char * JSON_parse_string (JSON_Parser *json, char *p, char *pe, VALUE *result)
 
static VALUE convert_encoding (VALUE source)
 
static VALUE cParser_initialize (int argc, VALUE *argv, VALUE self)
 
static VALUE cParser_parse (VALUE self)
 
static void JSON_mark (void *ptr)
 
static void JSON_free (void *ptr)
 
static size_t JSON_memsize (const void *ptr)
 
static VALUE cJSON_parser_s_allocate (VALUE klass)
 
static VALUE cParser_source (VALUE self)
 
void Init_parser (void)
 

Variables

static const char digit_values [256]
 
static VALUE mJSON
 
static VALUE mExt
 
static VALUE cParser
 
static VALUE eParserError
 
static VALUE eNestingError
 
static VALUE CNaN
 
static VALUE CInfinity
 
static VALUE CMinusInfinity
 
static ID i_json_creatable_p
 
static ID i_json_create
 
static ID i_create_id
 
static ID i_create_additions
 
static ID i_chr
 
static ID i_max_nesting
 
static ID i_allow_nan
 
static ID i_symbolize_names
 
static ID i_object_class
 
static ID i_array_class
 
static ID i_key_p
 
static ID i_deep_const_get
 
static ID i_match
 
static ID i_match_string
 
static ID i_aset
 
static ID i_aref
 
static ID i_leftshift
 
static const rb_data_type_t JSON_Parser_type
 

Macro Definition Documentation

◆ EXC_ENCODING

#define EXC_ENCODING   rb_utf8_encoding(),

Definition at line 7 of file parser.c.

Referenced by cParser_parse(), JSON_parse_array(), JSON_parse_value(), and json_string_unescape().

◆ rb_enc_raise

#define rb_enc_raise   enc_raise

Definition at line 21 of file parser.c.

Referenced by cParser_parse(), JSON_parse_array(), JSON_parse_value(), and json_string_unescape().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
JSON_object_start 

Definition at line 106 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_object_first_final 

Definition at line 107 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_object_error 

Definition at line 108 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_object_en_main 

Definition at line 110 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_value_start 

Definition at line 484 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_value_first_final 

Definition at line 485 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_value_error 

Definition at line 486 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_value_en_main 

Definition at line 488 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_integer_start 

Definition at line 878 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_integer_first_final 

Definition at line 879 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_integer_error 

Definition at line 880 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_integer_en_main 

Definition at line 882 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_float_start 

Definition at line 977 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_float_first_final 

Definition at line 978 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_float_error 

Definition at line 979 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_float_en_main 

Definition at line 981 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_array_start 

Definition at line 1143 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_array_first_final 

Definition at line 1144 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_array_error 

Definition at line 1145 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_array_en_main 

Definition at line 1147 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_string_start 

Definition at line 1483 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_string_first_final 

Definition at line 1484 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_string_error 

Definition at line 1485 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_string_en_main 

Definition at line 1487 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_start 

Definition at line 1820 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_first_final 

Definition at line 1821 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_error 

Definition at line 1822 of file parser.c.

◆ anonymous enum

anonymous enum
Enumerator
JSON_en_main 

Definition at line 1824 of file parser.c.

Function Documentation

◆ cJSON_parser_s_allocate()

static VALUE cJSON_parser_s_allocate ( VALUE  klass)
static

Definition at line 2030 of file parser.c.

References JSON_ParserStruct::fbuffer, fbuffer_alloc(), and TypedData_Make_Struct.

Referenced by Init_parser().

◆ convert_encoding()

static VALUE convert_encoding ( VALUE  source)
static

◆ convert_UTF32_to_UTF8()

static int convert_UTF32_to_UTF8 ( char *  buf,
UTF32  ch 
)
static

Definition at line 66 of file parser.c.

References len.

Referenced by json_string_unescape().

◆ cParser_initialize()

static VALUE cParser_initialize ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ cParser_parse()

static VALUE cParser_parse ( VALUE  self)
static

◆ cParser_source()

static VALUE cParser_source ( VALUE  self)
static

Definition at line 2044 of file parser.c.

References GET_PARSER, and rb_str_dup().

Referenced by Init_parser().

◆ enc_raise()

static void enc_raise ( rb_encoding enc,
VALUE  exc,
const char *  fmt,
  ... 
)
static

Definition at line 10 of file parser.c.

References rb_enc_vsprintf(), rb_exc_new3, and rb_exc_raise().

◆ Init_parser()

void Init_parser ( void  )

◆ JSON_free()

static void JSON_free ( void *  ptr)
static

Definition at line 2006 of file parser.c.

References JSON_ParserStruct::fbuffer, fbuffer_free(), and ruby_xfree().

◆ JSON_mark()

static void JSON_mark ( void *  ptr)
static

◆ JSON_memsize()

static size_t JSON_memsize ( const void *  ptr)
static

Definition at line 2013 of file parser.c.

References JSON_ParserStruct::fbuffer, and FBUFFER_CAPA.

◆ JSON_parse_array()

static char* JSON_parse_array ( JSON_Parser json,
char *  p,
char *  pe,
VALUE result,
int  current_nesting 
)
static

◆ JSON_parse_float()

static char* JSON_parse_float ( JSON_Parser json,
char *  p,
char *  pe,
VALUE result 
)
static

◆ JSON_parse_integer()

static char* JSON_parse_integer ( JSON_Parser json,
char *  p,
char *  pe,
VALUE result 
)
static

◆ JSON_parse_object()

static char* JSON_parse_object ( JSON_Parser json,
char *  p,
char *  pe,
VALUE result,
int  current_nesting 
)
static

◆ JSON_parse_string()

static char* JSON_parse_string ( JSON_Parser json,
char *  p,
char *  pe,
VALUE result 
)
static

◆ JSON_parse_value()

static char* JSON_parse_value ( JSON_Parser json,
char *  p,
char *  pe,
VALUE result,
int  current_nesting 
)
static

◆ json_string_unescape()

static VALUE json_string_unescape ( VALUE  result,
char *  string,
char *  stringEnd 
)
static

◆ match_i()

static int match_i ( VALUE  regexp,
VALUE  klass,
VALUE  memo 
)
static

◆ unescape_unicode()

static UTF32 unescape_unicode ( const unsigned char *  p)
static

Definition at line 47 of file parser.c.

References digit_values, result, and UNI_REPLACEMENT_CHAR.

Referenced by json_string_unescape().

Variable Documentation

◆ CInfinity

VALUE CInfinity
static

Definition at line 93 of file parser.c.

Referenced by Init_parser(), and JSON_parse_value().

◆ CMinusInfinity

VALUE CMinusInfinity
static

Definition at line 93 of file parser.c.

Referenced by Init_parser(), and JSON_parse_value().

◆ CNaN

VALUE CNaN
static

Definition at line 93 of file parser.c.

Referenced by Init_parser(), and JSON_parse_value().

◆ cParser

VALUE cParser
static

Definition at line 92 of file parser.c.

Referenced by Init_parser().

◆ digit_values

const char digit_values[256]
static
Initial value:
= {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
-1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1
}

Definition at line 30 of file parser.c.

Referenced by unescape_unicode().

◆ eNestingError

VALUE eNestingError
static

Definition at line 92 of file parser.c.

Referenced by Init_parser(), JSON_parse_array(), and JSON_parse_object().

◆ eParserError

VALUE eParserError
static

◆ i_allow_nan

ID i_allow_nan
static

Definition at line 95 of file parser.c.

Referenced by cParser_initialize(), and Init_parser().

◆ i_aref

ID i_aref
static

Definition at line 95 of file parser.c.

Referenced by Init_parser(), and JSON_parse_object().

◆ i_array_class

ID i_array_class
static

Definition at line 95 of file parser.c.

Referenced by cParser_initialize(), and Init_parser().

◆ i_aset

ID i_aset
static

Definition at line 95 of file parser.c.

Referenced by Init_parser(), and JSON_parse_object().

◆ i_chr

ID i_chr
static

Definition at line 95 of file parser.c.

Referenced by Init_parser().

◆ i_create_additions

ID i_create_additions
static

Definition at line 95 of file parser.c.

Referenced by cParser_initialize(), and Init_parser().

◆ i_create_id

ID i_create_id
static

Definition at line 95 of file parser.c.

Referenced by cParser_initialize(), and Init_parser().

◆ i_deep_const_get

ID i_deep_const_get
static

Definition at line 95 of file parser.c.

Referenced by Init_parser(), and JSON_parse_object().

◆ i_json_creatable_p

ID i_json_creatable_p
static

Definition at line 95 of file parser.c.

Referenced by Init_parser(), JSON_parse_object(), and match_i().

◆ i_json_create

ID i_json_create
static

Definition at line 95 of file parser.c.

Referenced by Init_parser(), JSON_parse_object(), and JSON_parse_string().

◆ i_key_p

ID i_key_p
static

Definition at line 95 of file parser.c.

Referenced by Init_parser().

◆ i_leftshift

ID i_leftshift
static

Definition at line 95 of file parser.c.

Referenced by Init_parser(), and JSON_parse_array().

◆ i_match

ID i_match
static

Definition at line 95 of file parser.c.

Referenced by Init_parser(), and match_i().

◆ i_match_string

ID i_match_string
static

Definition at line 95 of file parser.c.

Referenced by cParser_initialize(), and Init_parser().

◆ i_max_nesting

ID i_max_nesting
static

Definition at line 95 of file parser.c.

Referenced by cParser_initialize(), and Init_parser().

◆ i_object_class

ID i_object_class
static

Definition at line 95 of file parser.c.

Referenced by cParser_initialize(), and Init_parser().

◆ i_symbolize_names

ID i_symbolize_names
static

Definition at line 95 of file parser.c.

Referenced by cParser_initialize(), and Init_parser().

◆ JSON_Parser_type

const rb_data_type_t JSON_Parser_type
static
Initial value:
= {
"JSON/Parser",
0, 0,
}
static size_t JSON_memsize(const void *ptr)
Definition: parser.c:2013
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1145
static void JSON_mark(void *ptr)
Definition: parser.c:1996
static void JSON_free(void *ptr)
Definition: parser.c:2006

Definition at line 2020 of file parser.c.

◆ mExt

VALUE mExt
static

Definition at line 92 of file parser.c.

Referenced by Init_parser().

◆ mJSON

VALUE mJSON
static

Definition at line 92 of file parser.c.

Referenced by cParser_initialize(), Init_parser(), and JSON_parse_object().