Ruby  1.9.3p551(2014-11-13revision48407)
Data Structures | Macros | Functions | Variables
cparse.c File Reference
#include "ruby/ruby.h"

Go to the source code of this file.

Data Structures

struct  cparse_params
 

Macros

#define FALSE   0
 
#define TRUE   1
 
#define RACC_VERSION   "1.4.5"
 
#define DEFAULT_TOKEN   -1
 
#define ERROR_TOKEN   1
 
#define FINAL_TOKEN   0
 
#define vDEFAULT_TOKEN   INT2FIX(DEFAULT_TOKEN)
 
#define vERROR_TOKEN   INT2FIX(ERROR_TOKEN)
 
#define vFINAL_TOKEN   INT2FIX(FINAL_TOKEN)
 
#define ID2SYM(i)   ULONG2NUM(i)
 
#define SYM2ID(v)   ((ID)NUM2ULONG(v))
 
#define SYMBOL_P(v)   FIXNUM_P(v)
 
#define LONG2NUM(i)   INT2NUM(i)
 
#define AREF(s, idx)   ((0 <= idx && idx < RARRAY_LEN(s)) ? RARRAY_PTR(s)[idx] : Qnil)
 
#define STACK_INIT_LEN   64
 
#define NEW_STACK()   rb_ary_new2(STACK_INIT_LEN)
 
#define PUSH(s, i)   rb_ary_store(s, RARRAY_LEN(s), i)
 
#define POP(s)   rb_ary_pop(s)
 
#define LAST_I(s)   ((RARRAY_LEN(s) > 0) ? RARRAY_PTR(s)[RARRAY_LEN(s) - 1] : Qnil)
 
#define GET_TAIL(s, len)   get_stack_tail(s, len)
 
#define CUT_TAIL(s, len)   cut_stack_tail(s, len)
 
#define CP_FIN_ACCEPT   1
 
#define CP_FIN_EOT   2
 
#define CP_FIN_CANTPOP   3
 
#define D_puts(msg)
 
#define D_printf(fmt, arg)
 
#define SHIFT(v, act, tok, val)   shift(v,act,tok,val)
 
#define REDUCE(v, act)
 

Functions

static ID value_to_id _ ((VALUE v))
 
static long num_to_long _ ((VALUE n))
 
static ID value_to_id (VALUE v)
 
static long num_to_long (VALUE n)
 
static VALUE get_stack_tail _ ((VALUE stack, long len))
 
static VALUE get_stack_tail (VALUE stack, long len)
 
static void cut_stack_tail (VALUE stack, long len)
 
static VALUE racc_cparse _ ((VALUE parser, VALUE arg, VALUE sysdebug))
 
static VALUE racc_yyparse _ ((VALUE parser, VALUE lexer, VALUE lexmid, VALUE arg, VALUE sysdebug))
 
static void call_lexer _ ((struct cparse_params *v))
 
static VALUE lexer_i _ ((VALUE block_args, VALUE data, VALUE self))
 
static VALUE assert_array _ ((VALUE a))
 
static VALUE assert_hash _ ((VALUE h))
 
static VALUE initialize_params _ ((VALUE vparams, VALUE parser, VALUE arg, VALUE lexer, VALUE lexmid))
 
static void cparse_params_mark _ ((void *ptr))
 
static void parse_main _ ((struct cparse_params *v, VALUE tok, VALUE val, int resume))
 
static void extract_user_token _ ((struct cparse_params *v, VALUE block_args, VALUE *tok, VALUE *val))
 
static void shift _ ((struct cparse_params *v, long act, VALUE tok, VALUE val))
 
static int reduce _ ((struct cparse_params *v, long act))
 
static VALUE racc_cparse (VALUE parser, VALUE arg, VALUE sysdebug)
 
static VALUE racc_yyparse (VALUE parser, VALUE lexer, VALUE lexmid, VALUE arg, VALUE sysdebug)
 
static VALUE lexer_iter (VALUE data)
 
static void call_lexer (struct cparse_params *v)
 
static VALUE lexer_i (VALUE block_args, VALUE data, VALUE self)
 
static VALUE assert_array (VALUE a)
 
static VALUE assert_hash (VALUE h)
 
static long assert_integer (VALUE n)
 
static VALUE initialize_params (VALUE vparams, VALUE parser, VALUE arg, VALUE lexer, VALUE lexmid)
 
static void cparse_params_mark (void *ptr)
 
static void extract_user_token (struct cparse_params *v, VALUE block_args, VALUE *tok, VALUE *val)
 
static void parse_main (struct cparse_params *v, VALUE tok, VALUE val, int resume)
 
static void shift (struct cparse_params *v, long act, VALUE tok, VALUE val)
 
static int reduce (struct cparse_params *v, long act)
 
static VALUE reduce0 (VALUE val, VALUE data, VALUE self)
 
void Init_cparse (void)
 

Variables

static VALUE RaccBug
 
static VALUE CparseParams
 
static ID id_yydebug
 
static ID id_nexttoken
 
static ID id_onerror
 
static ID id_noreduce
 
static ID id_errstatus
 
static ID id_d_shift
 
static ID id_d_reduce
 
static ID id_d_accept
 
static ID id_d_read_token
 
static ID id_d_next_state
 
static ID id_d_e_pop
 

Macro Definition Documentation

#define AREF (   s,
  idx 
)    ((0 <= idx && idx < RARRAY_LEN(s)) ? RARRAY_PTR(s)[idx] : Qnil)

Definition at line 93 of file cparse.c.

Referenced by extract_user_token(), parse_main(), reduce0(), and vm_init_redefined_flag().

#define CP_FIN_ACCEPT   1

Definition at line 176 of file cparse.c.

Referenced by lexer_i(), and parse_main().

#define CP_FIN_CANTPOP   3

Definition at line 178 of file cparse.c.

Referenced by parse_main().

#define CP_FIN_EOT   2

Definition at line 177 of file cparse.c.

Referenced by parse_main().

#define CUT_TAIL (   s,
  len 
)    cut_stack_tail(s, len)

Definition at line 127 of file cparse.c.

Referenced by reduce0().

#define D_printf (   fmt,
  arg 
)

Definition at line 217 of file cparse.c.

Referenced by parse_main(), and reduce0().

#define D_puts (   msg)

Definition at line 216 of file cparse.c.

Referenced by parse_main(), racc_cparse(), racc_yyparse(), and reduce0().

#define DEFAULT_TOKEN   -1

Definition at line 29 of file cparse.c.

#define ERROR_TOKEN   1

Definition at line 30 of file cparse.c.

Referenced by parse_main().

#define FALSE   0

Definition at line 17 of file cparse.c.

Referenced by initialize_params(), and racc_cparse().

#define FINAL_TOKEN   0

Definition at line 31 of file cparse.c.

Referenced by initialize_params().

#define GET_TAIL (   s,
  len 
)    get_stack_tail(s, len)

Definition at line 126 of file cparse.c.

Referenced by reduce0().

#define ID2SYM (   i)    ULONG2NUM(i)

Definition at line 63 of file cparse.c.

Referenced by basic_obj_respond_to(), bug_i(), call_trace_proc(), cbsubst_get_subst_arg(), check_funcall(), chunk_ii(), collect_local_variables_in_iseq(), compile_colon2(), console_dev(), const_missing(), constant_to_sym(), count_objects(), count_objects_size(), cParser_initialize(), cState_configure(), cState_to_h(), cto_i(), cv_i(), defined_expr(), dir_initialize(), enum_zip(), exception_type2symbol(), exec_recursive(), gc_profile_record_get(), gc_profile_result(), gc_stat(), get_exception_sym2type(), gvar_i(), iconv_s_ctlmethods(), id2ref(), Init_Array(), Init_Enumerator(), Init_IO(), Init_ossl_ssl(), Init_syck(), Init_transcode(), ins_methods_push(), insn_make_insn_table(), insn_operand_intern(), int_ossl_asn1_decode0_cons(), int_ossl_asn1_decode0_prim(), iseq_compile_each(), iseq_data_to_ary(), iseq_load(), ivar_i(), list_i(), make_localjump_error(), make_struct(), method_missing(), method_name(), mnew(), ossl_asn1_class2sym(), ossl_asn1_initialize(), ossl_asn1eoc_initialize(), ossl_pkcs7_get_type(), ossl_sslctx_get_session_cache_stats(), r_object0(), rawmode_opt(), rb_catch(), rb_dlcfunc_calltype(), rb_exec_arg_prepare(), rb_f_exec(), rb_f_global_variables(), rb_f_local_variables(), rb_f_method_name(), rb_iseq_parameters(), rb_name_class(), rb_name_error(), rb_obj_respond_to(), rb_str_format(), rb_str_intern(), rb_struct_define(), rb_struct_define_without_accessor(), rb_struct_getmember(), rb_struct_s_def(), rb_throw(), realpath_rec(), recursive_list_access(), recursive_pop(), reg_named_capture_assign_iter(), register_label(), ripper_init_eventids1(), ripper_init_eventids2_table(), symbols_i(), thread_keys_i(), time_init_1(), unnamed_parameters(), vm_call0(), vm_call_method(), vm_method_missing(), when_vals(), and yyparse().

#define LAST_I (   s)    ((RARRAY_LEN(s) > 0) ? RARRAY_PTR(s)[RARRAY_LEN(s) - 1] : Qnil)

Definition at line 124 of file cparse.c.

Referenced by parse_main(), and reduce0().

#define LONG2NUM (   i)    INT2NUM(i)
#define NEW_STACK ( )    rb_ary_new2(STACK_INIT_LEN)

Definition at line 121 of file cparse.c.

Referenced by initialize_params().

#define POP (   s)    rb_ary_pop(s)

Definition at line 123 of file cparse.c.

Referenced by parse_main().

#define PUSH (   s,
  i 
)    rb_ary_store(s, RARRAY_LEN(s), i)

Definition at line 122 of file cparse.c.

Referenced by initialize_params(), reduce0(), and shift().

#define RACC_VERSION   "1.4.5"

Definition at line 27 of file cparse.c.

Referenced by Init_cparse().

#define REDUCE (   v,
  act 
)
Value:
do {\
switch (reduce(v,act)) { \
case 0: /* normal */ \
break; \
case 1: /* yyerror */ \
goto user_yyerror; \
case 2: /* yyaccept */ \
D_puts("u accept"); \
goto accept; \
default: \
break; \
} \
} while (0)

Definition at line 438 of file cparse.c.

Referenced by parse_main().

#define SHIFT (   v,
  act,
  tok,
  val 
)    shift(v,act,tok,val)

Definition at line 437 of file cparse.c.

Referenced by parse_main().

#define STACK_INIT_LEN   64

Definition at line 120 of file cparse.c.

#define SYM2ID (   v)    ((ID)NUM2ULONG(v))
#define SYMBOL_P (   v)    FIXNUM_P(v)
#define TRUE   1

Definition at line 20 of file cparse.c.

Referenced by initialize_params(), and racc_yyparse().

#define vDEFAULT_TOKEN   INT2FIX(DEFAULT_TOKEN)

Definition at line 33 of file cparse.c.

#define vERROR_TOKEN   INT2FIX(ERROR_TOKEN)

Definition at line 34 of file cparse.c.

Referenced by parse_main().

#define vFINAL_TOKEN   INT2FIX(FINAL_TOKEN)

Definition at line 35 of file cparse.c.

Referenced by parse_main().

Function Documentation

static ID value_to_id _ ( (VALUE v )
static
static long assert_integer _ ( (VALUE n)  )
inlinestatic
static void cut_stack_tail _ ( (VALUE stack, long len )
static
static VALUE racc_cparse _ ( (VALUE parser, VALUE arg, VALUE sysdebug)  )
static
static VALUE racc_yyparse _ ( (VALUE parser, VALUE lexer, VALUE lexmid, VALUE arg, VALUE sysdebug)  )
static
static void call_lexer _ ( (struct cparse_params *v )
static
static VALUE reduce0 _ ( (VALUE block_args, VALUE data, VALUE self)  )
static
static VALUE assert_array _ ( (VALUE a)  )
static
static VALUE assert_hash _ ( (VALUE h)  )
static
static VALUE initialize_params _ ( (VALUE vparams, VALUE parser, VALUE arg, VALUE lexer, VALUE lexmid)  )
static
static void cparse_params_mark _ ( (void *ptr)  )
static
static void parse_main _ ( (struct cparse_params *v, VALUE tok, VALUE val, int resume)  )
static
static void extract_user_token _ ( (struct cparse_params *v, VALUE block_args, VALUE *tok, VALUE *val)  )
static
static void shift _ ( (struct cparse_params *v, long act, VALUE tok, VALUE val)  )
static
static int reduce _ ( (struct cparse_params *v, long act)  )
static
static VALUE assert_array ( VALUE  a)
static

Definition at line 301 of file cparse.c.

References Check_Type, and T_ARRAY.

Referenced by initialize_params().

static VALUE assert_hash ( VALUE  h)
static

Definition at line 308 of file cparse.c.

References Check_Type, and T_HASH.

Referenced by initialize_params().

static long assert_integer ( VALUE  n)
static

Definition at line 315 of file cparse.c.

References NUM2LONG().

Referenced by initialize_params().

static void call_lexer ( struct cparse_params v)
static

Definition at line 278 of file cparse.c.

References lexer_i(), lexer_iter(), rb_iterate(), and cparse_params::value_v.

Referenced by racc_yyparse().

static void cparse_params_mark ( void *  ptr)
static
static void cut_stack_tail ( VALUE  stack,
long  len 
)
static

Definition at line 112 of file cparse.c.

References rb_ary_pop().

static void extract_user_token ( struct cparse_params v,
VALUE  block_args,
VALUE tok,
VALUE val 
)
static
static VALUE get_stack_tail ( VALUE  stack,
long  len 
)
static

Definition at line 104 of file cparse.c.

References Qnil, RARRAY_LEN, RARRAY_PTR, and rb_ary_new4().

void Init_cparse ( void  )
static VALUE initialize_params ( VALUE  vparams,
VALUE  parser,
VALUE  arg,
VALUE  lexer,
VALUE  lexmid 
)
static
static VALUE lexer_i ( VALUE  block_args,
VALUE  data,
VALUE  self 
)
static
static VALUE lexer_iter ( VALUE  data)
static

Definition at line 268 of file cparse.c.

References Data_Get_Struct, cparse_params::lexer, cparse_params::lexmid, Qnil, rb_funcall(), and v.

Referenced by call_lexer().

static long num_to_long ( VALUE  n)
inlinestatic

Definition at line 88 of file cparse.c.

References NUM2LONG().

Referenced by parse_main(), reduce(), and reduce0().

static void parse_main ( struct cparse_params v,
VALUE  tok,
VALUE  val,
int  resume 
)
static
static VALUE racc_cparse ( VALUE  parser,
VALUE  arg,
VALUE  sysdebug 
)
static
static VALUE racc_yyparse ( VALUE  parser,
VALUE  lexer,
VALUE  lexmid,
VALUE  arg,
VALUE  sysdebug 
)
static
static int reduce ( struct cparse_params v,
long  act 
)
static
static VALUE reduce0 ( VALUE  val,
VALUE  data,
VALUE  self 
)
static
static void shift ( struct cparse_params v,
long  act,
VALUE  tok,
VALUE  val 
)
static
static ID value_to_id ( VALUE  v)
static

Definition at line 79 of file cparse.c.

References rb_eTypeError, rb_raise(), SYM2ID, and SYMBOL_P.

Referenced by initialize_params(), and reduce0().

Variable Documentation

VALUE CparseParams
static

Definition at line 42 of file cparse.c.

Referenced by Init_cparse(), racc_cparse(), and racc_yyparse().

ID id_d_accept
static

Definition at line 52 of file cparse.c.

Referenced by Init_cparse(), and parse_main().

ID id_d_e_pop
static

Definition at line 55 of file cparse.c.

Referenced by Init_cparse(), and parse_main().

ID id_d_next_state
static

Definition at line 54 of file cparse.c.

Referenced by Init_cparse(), and parse_main().

ID id_d_read_token
static

Definition at line 53 of file cparse.c.

Referenced by Init_cparse(), and parse_main().

ID id_d_reduce
static

Definition at line 51 of file cparse.c.

Referenced by Init_cparse(), and reduce0().

ID id_d_shift
static

Definition at line 50 of file cparse.c.

Referenced by Init_cparse(), and shift().

ID id_errstatus
static

Definition at line 48 of file cparse.c.

Referenced by Init_cparse(), initialize_params(), parse_main(), and reduce().

ID id_nexttoken
static

Definition at line 45 of file cparse.c.

Referenced by Init_cparse(), and parse_main().

ID id_noreduce
static

Definition at line 47 of file cparse.c.

Referenced by Init_cparse(), and reduce0().

ID id_onerror
static

Definition at line 46 of file cparse.c.

Referenced by Init_cparse(), and parse_main().

ID id_yydebug
static

Definition at line 44 of file cparse.c.

Referenced by Init_cparse(), and initialize_params().

VALUE RaccBug
static

Definition at line 41 of file cparse.c.

Referenced by Init_cparse(), initialize_params(), parse_main(), and reduce0().