1 /* This is a wrapper for parse.y */
2 #ifdef UNIVERSAL_PARSER
5 #include "internal/array.h"
6 #include "internal/bignum.h"
7 #include "internal/compile.h"
8 #include "internal/complex.h"
9 #include "internal/encoding.h"
10 #include "internal/error.h"
11 #include "internal/gc.h"
12 #include "internal/hash.h"
13 #include "internal/io.h"
14 #include "internal/parse.h"
15 #include "internal/rational.h"
16 #include "internal/re.h"
17 #include "internal/ruby_parser.h"
18 #include "internal/string.h"
19 #include "internal/symbol.h"
20 #include "internal/thread.h"
22 #include "ruby/ractor.h"
23 #include "ruby/ruby.h"
24 #include "ruby/util.h"
31 rb_parser_t
*parser_params
;
35 parser_mark(void *ptr
)
37 struct ruby_parser
*parser
= (struct ruby_parser
*)ptr
;
38 rb_ruby_parser_mark(parser
->parser_params
);
42 parser_free(void *ptr
)
44 struct ruby_parser
*parser
= (struct ruby_parser
*)ptr
;
45 rb_ruby_parser_free(parser
->parser_params
);
49 parser_memsize(const void *ptr
)
51 struct ruby_parser
*parser
= (struct ruby_parser
*)ptr
;
52 return rb_ruby_parser_memsize(parser
->parser_params
);
55 static const rb_data_type_t ruby_parser_data_type
= {
62 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
66 bignum_negate(VALUE b
)
72 is_ascii_string2(VALUE str
)
74 return is_ascii_string(str
);
78 rational_set_num(VALUE r
, VALUE n
)
80 RATIONAL_SET_NUM(r
, n
);
84 rational_get_num(VALUE obj
)
86 return RRATIONAL(obj
)->num
;
90 rcomplex_set_real(VALUE cmp
, VALUE r
)
92 RCOMPLEX_SET_REAL(cmp
, r
);
96 rcomplex_set_imag(VALUE cmp
, VALUE i
)
98 RCOMPLEX_SET_IMAG(cmp
, i
);
102 rcomplex_get_real(VALUE obj
)
104 return RCOMPLEX(obj
)->real
;
108 rcomplex_get_imag(VALUE obj
)
110 return RCOMPLEX(obj
)->imag
;
113 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT
, 6, 0)
115 syntax_error_append(VALUE exc
, VALUE file
, int line
, int column
,
116 void *enc
, const char *fmt
, va_list args
)
118 return rb_syntax_error_append(exc
, file
, line
, column
, (rb_encoding
*)enc
, fmt
, args
);
122 local_defined(ID id
, const void *p
)
124 return rb_local_defined(id
, (const rb_iseq_t
*)p
);
128 dvar_defined(ID id
, const void *p
)
130 return rb_dvar_defined(id
, (const rb_iseq_t
*)p
);
134 hash_literal_key_p(VALUE k
)
136 switch (OBJ_BUILTIN_TYPE(k
)) {
145 literal_cmp(VALUE val
, VALUE lit
)
147 if (val
== lit
) return 0;
148 if (!hash_literal_key_p(val
) || !hash_literal_key_p(lit
)) return -1;
149 return rb_iseq_cdhash_cmp(val
, lit
);
153 literal_hash(VALUE a
)
155 if (!hash_literal_key_p(a
)) return (st_index_t
)a
;
156 return rb_iseq_cdhash_hash(a
);
160 is_usascii_enc(void *enc
)
162 return rb_is_usascii_enc((rb_encoding
*)enc
);
168 return is_local_id(id
);
172 is_attrset_id2(ID id
)
174 return is_attrset_id(id
);
180 return is_notop_id(id
);
184 enc_str_new(const char *ptr
, long len
, void *enc
)
186 return rb_enc_str_new(ptr
, len
, (rb_encoding
*)enc
);
190 enc_isalnum(OnigCodePoint c
, void *enc
)
192 return rb_enc_isalnum(c
, (rb_encoding
*)enc
);
196 enc_precise_mbclen(const char *p
, const char *e
, void *enc
)
198 return rb_enc_precise_mbclen(p
, e
, (rb_encoding
*)enc
);
202 mbclen_charfound_p(int len
)
204 return MBCLEN_CHARFOUND_P(len
);
210 return rb_enc_name((rb_encoding
*)enc
);
214 enc_prev_char(const char *s
, const char *p
, const char *e
, void *enc
)
216 return rb_enc_prev_char(s
, p
, e
, (rb_encoding
*)enc
);
222 return (void *)rb_enc_get(obj
);
226 enc_asciicompat(void *enc
)
228 return rb_enc_asciicompat((rb_encoding
*)enc
);
234 return (void *)rb_utf8_encoding();
238 enc_associate(VALUE obj
, void *enc
)
240 return rb_enc_associate(obj
, (rb_encoding
*)enc
);
244 ascii8bit_encoding(void)
246 return (void *)rb_ascii8bit_encoding();
250 enc_codelen(int c
, void *enc
)
252 return rb_enc_codelen(c
, (rb_encoding
*)enc
);
256 enc_str_buf_cat(VALUE str
, const char *ptr
, long len
, void *enc
)
258 return rb_enc_str_buf_cat(str
, ptr
, len
, (rb_encoding
*)enc
);
262 enc_mbcput(unsigned int c
, void *buf
, void *enc
)
264 return rb_enc_mbcput(c
, buf
, (rb_encoding
*)enc
);
268 enc_from_index(int idx
)
270 return (void *)rb_enc_from_index(idx
);
274 enc_isspace(OnigCodePoint c
, void *enc
)
276 return rb_enc_isspace(c
, (rb_encoding
*)enc
);
280 intern3(const char *name
, long len
, void *enc
)
282 return rb_intern3(name
, len
, (rb_encoding
*)enc
);
286 enc_compatible(VALUE str1
, VALUE str2
)
288 return (void *)rb_enc_compatible(str1
, str2
);
292 enc_from_encoding(void *enc
)
294 return rb_enc_from_encoding((rb_encoding
*)enc
);
298 encoding_get(VALUE obj
)
300 return ENCODING_GET(obj
);
304 encoding_set(VALUE obj
, int encindex
)
306 ENCODING_SET(obj
, encindex
);
310 encoding_is_ascii8bit(VALUE obj
)
312 return ENCODING_IS_ASCII8BIT(obj
);
316 usascii_encoding(void)
318 return (void *)rb_usascii_encoding();
322 enc_symname_type(const char *name
, long len
, void *enc
, unsigned int allowed_attrset
)
324 return rb_enc_symname_type(name
, len
, (rb_encoding
*)enc
, allowed_attrset
);
328 struct parser_params
*parser
;
331 const rb_code_location_t
*loc
;
332 } reg_named_capture_assign_t
;
335 reg_named_capture_assign_iter(const OnigUChar
*name
, const OnigUChar
*name_end
,
336 int back_num
, int *back_refs
, OnigRegex regex
, void *arg0
)
338 reg_named_capture_assign_t
*arg
= (reg_named_capture_assign_t
*)arg0
;
339 struct parser_params
* p
= arg
->parser
;
340 rb_encoding
*enc
= arg
->enc
;
341 const rb_code_location_t
*loc
= arg
->loc
;
342 long len
= name_end
- name
;
343 const char *s
= (const char *)name
;
345 return rb_reg_named_capture_assign_iter_impl(p
, s
, len
, (void *)enc
, &arg
->succ_block
, loc
);
349 reg_named_capture_assign(struct parser_params
* p
, VALUE regexp
, const rb_code_location_t
*loc
)
351 reg_named_capture_assign_t arg
;
354 arg
.enc
= rb_enc_get(regexp
);
357 onig_foreach_name(RREGEXP_PTR(regexp
), reg_named_capture_assign_iter
, &arg
);
359 if (!arg
.succ_block
) return 0;
360 return RNODE_BLOCK(arg
.succ_block
)->nd_next
;
372 return RB_UNDEF_P(v
);
378 return (int)RB_TEST(obj
);
384 return (int)NIL_P(obj
);
390 return (int)RB_FLONUM_P(obj
);
400 syntax_error_new(void)
402 return rb_class_new_instance(0, 0, rb_eSyntaxError
);
406 obj_frozen(VALUE obj
)
408 return (int)RB_OBJ_FROZEN(obj
);
412 obj_write(VALUE old
, VALUE
*slot
, VALUE young
)
414 return RB_OBJ_WRITE(old
, slot
, young
);
418 obj_written(VALUE old
, VALUE slot
, VALUE young
)
420 return RB_OBJ_WRITTEN(old
, slot
, young
);
426 return rb_default_rs
;
430 rational_raw1(VALUE x
)
432 return rb_rational_raw1(x
);
436 memmove2(void *dest
, const void *src
, size_t t
, size_t n
)
438 return memmove(dest
, src
, rbimpl_size_mul_or_raise(t
, n
));
442 nonempty_memcpy(void *dest
, const void *src
, size_t t
, size_t n
)
444 return ruby_nonempty_memcpy(dest
, src
, rbimpl_size_mul_or_raise(t
, n
));
454 type_p(VALUE obj
, int t
)
456 return (int)RB_TYPE_P(obj
, t
);
462 return (int)RB_FIXNUM_P(obj
);
468 return (int)RB_SYMBOL_P(obj
);
472 zalloc(size_t elemsiz
)
474 return ruby_xcalloc(1, elemsiz
);
483 static rb_imemo_tmpbuf_t
*
484 tmpbuf_parser_heap(void *buf
, rb_imemo_tmpbuf_t
*old_heap
, size_t cnt
)
486 return rb_imemo_tmpbuf_parser_heap(buf
, old_heap
, cnt
);
490 special_const_p(VALUE obj
)
492 return (int)RB_SPECIAL_CONST_P(obj
);
496 builtin_type(VALUE obj
)
498 return (int)RB_BUILTIN_TYPE(obj
);
504 rb_ast_t
*ast
= (rb_ast_t
*)rb_imemo_new(imemo_ast
, 0, 0, 0, nb
);
511 return (((VALUE
)(id
)<<RUBY_SPECIAL_SHIFT
)|SYMBOL_FLAG
);
515 str_coderange_scan_restartable(const char *s
, const char *e
, void *enc
, int *cr
)
517 return rb_str_coderange_scan_restartable(s
, e
, (rb_encoding
*)enc
, cr
);
520 VALUE
rb_io_gets_internal(VALUE io
);
521 extern VALUE rb_mRubyVMFrozenCore
;
522 VALUE
rb_node_case_when_optimizable_literal(const NODE
*const node
);
525 rb_parser_config_initialize(rb_parser_config_t
*config
)
529 config
->malloc
= ruby_xmalloc
;
530 config
->calloc
= ruby_xcalloc
;
531 config
->realloc
= ruby_xrealloc
;
532 config
->free
= ruby_xfree
;
533 config
->alloc_n
= ruby_xmalloc2
;
534 config
->alloc
= ruby_xmalloc
;
535 config
->realloc_n
= ruby_xrealloc2
;
536 config
->zalloc
= zalloc
;
537 config
->rb_memmove
= memmove2
;
538 config
->nonempty_memcpy
= nonempty_memcpy
;
539 config
->xmalloc_mul_add
= rb_xmalloc_mul_add
;
541 config
->tmpbuf_parser_heap
= tmpbuf_parser_heap
;
542 config
->ast_new
= ast_new
;
544 config
->compile_callback
= rb_suppress_tracing
;
545 config
->reg_named_capture_assign
= reg_named_capture_assign
;
547 config
->obj_freeze
= rb_obj_freeze
;
548 config
->obj_hide
= rb_obj_hide
;
549 config
->obj_frozen
= obj_frozen
;
550 config
->type_p
= type_p
;
551 config
->obj_freeze_raw
= OBJ_FREEZE_RAW
;
553 config
->fixnum_p
= fixnum_p
;
554 config
->symbol_p
= symbol_p
;
556 config
->attr_get
= rb_attr_get
;
558 config
->ary_new
= rb_ary_new
;
559 config
->ary_push
= rb_ary_push
;
560 config
->ary_new_from_args
= rb_ary_new_from_args
;
561 config
->ary_pop
= rb_ary_pop
;
562 config
->ary_last
= rb_ary_last
;
563 config
->ary_unshift
= rb_ary_unshift
;
564 config
->ary_new2
= rb_ary_new2
;
565 config
->ary_entry
= rb_ary_entry
;
566 config
->ary_join
= rb_ary_join
;
567 config
->ary_reverse
= rb_ary_reverse
;
568 config
->ary_clear
= rb_ary_clear
;
569 config
->array_len
= rb_array_len
;
570 config
->array_aref
= RARRAY_AREF
;
572 config
->sym_intern_ascii_cstr
= rb_sym_intern_ascii_cstr
;
573 config
->make_temporary_id
= rb_make_temporary_id
;
574 config
->is_local_id
= is_local_id2
;
575 config
->is_attrset_id
= is_attrset_id2
;
576 config
->is_global_name_punct
= is_global_name_punct
;
577 config
->id_type
= id_type
;
578 config
->id_attrset
= rb_id_attrset
;
579 config
->intern
= rb_intern
;
580 config
->intern2
= rb_intern2
;
581 config
->intern3
= intern3
;
582 config
->intern_str
= rb_intern_str
;
583 config
->is_notop_id
= is_notop_id2
;
584 config
->enc_symname_type
= enc_symname_type
;
585 config
->str_intern
= rb_str_intern
;
586 config
->id2name
= rb_id2name
;
587 config
->id2str
= rb_id2str
;
588 config
->id2sym
= rb_id2sym
;
589 config
->sym2id
= rb_sym2id
;
591 config
->str_catf
= rb_str_catf
;
592 config
->str_cat_cstr
= rb_str_cat_cstr
;
593 config
->str_subseq
= rb_str_subseq
;
594 config
->str_dup
= rb_str_dup
;
595 config
->str_new_frozen
= rb_str_new_frozen
;
596 config
->str_buf_new
= rb_str_buf_new
;
597 config
->str_buf_cat
= rb_str_buf_cat
;
598 config
->str_modify
= rb_str_modify
;
599 config
->str_set_len
= rb_str_set_len
;
600 config
->str_cat
= rb_str_cat
;
601 config
->str_resize
= rb_str_resize
;
602 config
->str_new
= rb_str_new
;
603 config
->str_new_cstr
= rb_str_new_cstr
;
604 config
->fstring
= rb_fstring
;
605 config
->is_ascii_string
= is_ascii_string2
;
606 config
->enc_str_new
= enc_str_new
;
607 config
->enc_str_buf_cat
= enc_str_buf_cat
;
608 config
->str_buf_append
= rb_str_buf_append
;
609 config
->str_vcatf
= rb_str_vcatf
;
610 config
->string_value_cstr
= rb_string_value_cstr
;
611 config
->rb_sprintf
= rb_sprintf
;
612 config
->rstring_ptr
= RSTRING_PTR
;
613 config
->rstring_end
= RSTRING_END
;
614 config
->rstring_len
= RSTRING_LEN
;
615 config
->filesystem_str_new_cstr
= rb_filesystem_str_new_cstr
;
616 config
->obj_as_string
= rb_obj_as_string
;
618 config
->hash_clear
= rb_hash_clear
;
619 config
->hash_new
= rb_hash_new
;
620 config
->hash_aset
= rb_hash_aset
;
621 config
->hash_lookup
= rb_hash_lookup
;
622 config
->hash_delete
= rb_hash_delete
;
623 config
->ident_hash_new
= rb_ident_hash_new
;
625 config
->int2fix
= int2fix
;
627 config
->bignum_negate
= bignum_negate
;
628 config
->big_norm
= rb_big_norm
;
629 config
->cstr_to_inum
= rb_cstr_to_inum
;
631 config
->float_new
= rb_float_new
;
632 config
->float_value
= rb_float_value
;
634 config
->num2int
= rb_num2int_inline
;
635 config
->int_positive_pow
= rb_int_positive_pow
;
636 config
->int2num
= rb_int2num_inline
;
637 config
->fix2long
= rb_fix2long
;
639 config
->rational_new
= rb_rational_new
;
640 config
->rational_raw1
= rational_raw1
;
641 config
->rational_set_num
= rational_set_num
;
642 config
->rational_get_num
= rational_get_num
;
644 config
->complex_raw
= rb_complex_raw
;
645 config
->rcomplex_set_real
= rcomplex_set_real
;
646 config
->rcomplex_set_imag
= rcomplex_set_imag
;
647 config
->rcomplex_get_real
= rcomplex_get_real
;
648 config
->rcomplex_get_imag
= rcomplex_get_imag
;
650 config
->stderr_tty_p
= rb_stderr_tty_p
;
651 config
->write_error_str
= rb_write_error_str
;
652 config
->default_rs
= default_rs
;
653 config
->io_write
= rb_io_write
;
654 config
->io_flush
= rb_io_flush
;
655 config
->io_puts
= rb_io_puts
;
656 config
->io_gets_internal
= rb_io_gets_internal
;
658 config
->debug_output_stdout
= rb_ractor_stdout
;
659 config
->debug_output_stderr
= rb_ractor_stderr
;
661 config
->is_usascii_enc
= is_usascii_enc
;
662 config
->enc_isalnum
= enc_isalnum
;
663 config
->enc_precise_mbclen
= enc_precise_mbclen
;
664 config
->mbclen_charfound_p
= mbclen_charfound_p
;
665 config
->enc_name
= enc_name
;
666 config
->enc_prev_char
= enc_prev_char
;
667 config
->enc_get
= enc_get
;
668 config
->enc_asciicompat
= enc_asciicompat
;
669 config
->utf8_encoding
= utf8_encoding
;
670 config
->enc_associate
= enc_associate
;
671 config
->ascii8bit_encoding
= ascii8bit_encoding
;
672 config
->enc_codelen
= enc_codelen
;
673 config
->enc_mbcput
= enc_mbcput
;
674 config
->char_to_option_kcode
= rb_char_to_option_kcode
;
675 config
->ascii8bit_encindex
= rb_ascii8bit_encindex
;
676 config
->enc_find_index
= rb_enc_find_index
;
677 config
->enc_from_index
= enc_from_index
;
678 config
->enc_associate_index
= rb_enc_associate_index
;
679 config
->enc_isspace
= enc_isspace
;
680 config
->enc_coderange_7bit
= ENC_CODERANGE_7BIT
;
681 config
->enc_coderange_unknown
= ENC_CODERANGE_UNKNOWN
;
682 config
->enc_compatible
= enc_compatible
;
683 config
->enc_from_encoding
= enc_from_encoding
;
684 config
->encoding_get
= encoding_get
;
685 config
->encoding_set
= encoding_set
;
686 config
->encoding_is_ascii8bit
= encoding_is_ascii8bit
;
687 config
->usascii_encoding
= usascii_encoding
;
689 config
->ractor_make_shareable
= rb_ractor_make_shareable
;
691 config
->local_defined
= local_defined
;
692 config
->dvar_defined
= dvar_defined
;
694 config
->literal_cmp
= literal_cmp
;
695 config
->literal_hash
= literal_hash
;
697 config
->builtin_class_name
= rb_builtin_class_name
;
698 config
->syntax_error_append
= syntax_error_append
;
699 config
->raise
= rb_raise
;
700 config
->syntax_error_new
= syntax_error_new
;
702 config
->errinfo
= rb_errinfo
;
703 config
->set_errinfo
= rb_set_errinfo
;
704 config
->exc_raise
= rb_exc_raise
;
705 config
->make_exception
= rb_make_exception
;
707 config
->sized_xfree
= ruby_sized_xfree
;
708 config
->sized_realloc_n
= ruby_sized_realloc_n
;
709 config
->obj_write
= obj_write
;
710 config
->obj_written
= obj_written
;
711 config
->gc_register_mark_object
= rb_gc_register_mark_object
;
712 config
->gc_guard
= gc_guard
;
713 config
->gc_mark
= rb_gc_mark
;
714 config
->gc_mark_movable
= rb_gc_mark_movable
;
715 config
->gc_location
= rb_gc_location
;
717 config
->reg_compile
= rb_reg_compile
;
718 config
->reg_check_preprocess
= rb_reg_check_preprocess
;
719 config
->memcicmp
= rb_memcicmp
;
721 config
->compile_warn
= rb_compile_warn
;
722 config
->compile_warning
= rb_compile_warning
;
723 config
->bug
= rb_bug
;
724 config
->fatal
= rb_fatal
;
725 config
->verbose
= ruby_verbose2
;
727 config
->make_backtrace
= rb_make_backtrace
;
729 config
->scan_hex
= ruby_scan_hex
;
730 config
->scan_oct
= ruby_scan_oct
;
731 config
->scan_digits
= ruby_scan_digits
;
732 config
->strtod
= ruby_strtod
;
734 config
->rbool
= rbool
;
735 config
->undef_p
= undef_p
;
736 config
->rtest
= rtest
;
737 config
->nil_p
= nil_p
;
738 config
->flonum_p
= flonum_p
;
740 config
->qtrue
= Qtrue
;
741 config
->qfalse
= Qfalse
;
742 config
->qundef
= Qundef
;
743 config
->eArgError
= rb_eArgError
;
744 config
->mRubyVMFrozenCore
= rb_mRubyVMFrozenCore
;
745 config
->long2int
= rb_long2int
;
746 config
->special_const_p
= special_const_p
;
747 config
->builtin_type
= builtin_type
;
749 config
->node_case_when_optimizable_literal
= rb_node_case_when_optimizable_literal
;
752 config
->static_id2sym
= static_id2sym
;
753 config
->str_coderange_scan_restartable
= str_coderange_scan_restartable
;
759 struct ruby_parser
*parser
;
760 rb_parser_config_t
*config
;
761 rb_parser_t
*parser_params
;
763 config
= rb_ruby_parser_config_new(ruby_xmalloc
);
764 rb_parser_config_initialize(config
);
767 * Create parser_params ahead of vparser because
768 * rb_ruby_parser_new can run GC so if create vparser
769 * first, parser_mark tries to mark not initialized parser_params.
771 parser_params
= rb_ruby_parser_new(config
);
772 VALUE vparser
= TypedData_Make_Struct(0, struct ruby_parser
,
773 &ruby_parser_data_type
, parser
);
774 parser
->parser_params
= parser_params
;
780 rb_parser_set_options(VALUE vparser
, int print
, int loop
, int chomp
, int split
)
782 struct ruby_parser
*parser
;
784 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
785 rb_ruby_parser_set_options(parser
->parser_params
, print
, loop
, chomp
, split
);
789 rb_parser_set_context(VALUE vparser
, const struct rb_iseq_struct
*base
, int main
)
791 struct ruby_parser
*parser
;
793 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
794 rb_ruby_parser_set_context(parser
->parser_params
, base
, main
);
799 rb_parser_set_script_lines(VALUE vparser
, VALUE lines
)
801 struct ruby_parser
*parser
;
803 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
804 rb_ruby_parser_set_script_lines(parser
->parser_params
, lines
);
808 rb_parser_error_tolerant(VALUE vparser
)
810 struct ruby_parser
*parser
;
812 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
813 rb_ruby_parser_error_tolerant(parser
->parser_params
);
817 rb_parser_compile_file_path(VALUE vparser
, VALUE fname
, VALUE file
, int start
)
819 struct ruby_parser
*parser
;
822 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
823 ast
= rb_ruby_parser_compile_file_path(parser
->parser_params
, fname
, file
, start
);
824 RB_GC_GUARD(vparser
);
830 rb_parser_keep_tokens(VALUE vparser
)
832 struct ruby_parser
*parser
;
834 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
835 rb_ruby_parser_keep_tokens(parser
->parser_params
);
839 rb_parser_compile_generic(VALUE vparser
, VALUE (*lex_gets
)(VALUE
, int), VALUE fname
, VALUE input
, int start
)
841 struct ruby_parser
*parser
;
844 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
845 ast
= rb_ruby_parser_compile_generic(parser
->parser_params
, lex_gets
, fname
, input
, start
);
846 RB_GC_GUARD(vparser
);
852 rb_parser_compile_string(VALUE vparser
, const char *f
, VALUE s
, int line
)
854 struct ruby_parser
*parser
;
857 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
858 ast
= rb_ruby_parser_compile_string(parser
->parser_params
, f
, s
, line
);
859 RB_GC_GUARD(vparser
);
865 rb_parser_compile_string_path(VALUE vparser
, VALUE f
, VALUE s
, int line
)
867 struct ruby_parser
*parser
;
870 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
871 ast
= rb_ruby_parser_compile_string_path(parser
->parser_params
, f
, s
, line
);
872 RB_GC_GUARD(vparser
);
878 rb_parser_encoding(VALUE vparser
)
880 struct ruby_parser
*parser
;
882 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
883 return rb_ruby_parser_encoding(parser
->parser_params
);
887 rb_parser_end_seen_p(VALUE vparser
)
889 struct ruby_parser
*parser
;
891 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
892 return RBOOL(rb_ruby_parser_end_seen_p(parser
->parser_params
));
896 rb_parser_set_yydebug(VALUE vparser
, VALUE flag
)
898 struct ruby_parser
*parser
;
900 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
901 rb_ruby_parser_set_yydebug(parser
->parser_params
, RTEST(flag
));
907 /* For "ISO C requires a translation unit to contain at least one declaration" */
909 rb_parser_dummy(void)