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
;
114 syntax_error_append(VALUE exc
, VALUE file
, int line
, int column
,
115 void *enc
, const char *fmt
, va_list args
)
117 return rb_syntax_error_append(exc
, file
, line
, column
, (rb_encoding
*)enc
, fmt
, args
);
121 local_defined(ID id
, const void *p
)
123 return rb_local_defined(id
, (const rb_iseq_t
*)p
);
127 dvar_defined(ID id
, const void *p
)
129 return rb_dvar_defined(id
, (const rb_iseq_t
*)p
);
133 hash_literal_key_p(VALUE k
)
135 switch (OBJ_BUILTIN_TYPE(k
)) {
144 literal_cmp(VALUE val
, VALUE lit
)
146 if (val
== lit
) return 0;
147 if (!hash_literal_key_p(val
) || !hash_literal_key_p(lit
)) return -1;
148 return rb_iseq_cdhash_cmp(val
, lit
);
152 literal_hash(VALUE a
)
154 if (!hash_literal_key_p(a
)) return (st_index_t
)a
;
155 return rb_iseq_cdhash_hash(a
);
159 is_usascii_enc(void *enc
)
161 return rb_is_usascii_enc((rb_encoding
*)enc
);
167 return is_local_id(id
);
171 is_attrset_id2(ID id
)
173 return is_attrset_id(id
);
179 return is_notop_id(id
);
183 enc_str_new(const char *ptr
, long len
, void *enc
)
185 return rb_enc_str_new(ptr
, len
, (rb_encoding
*)enc
);
189 enc_isalnum(OnigCodePoint c
, void *enc
)
191 return rb_enc_isalnum(c
, (rb_encoding
*)enc
);
195 enc_precise_mbclen(const char *p
, const char *e
, void *enc
)
197 return rb_enc_precise_mbclen(p
, e
, (rb_encoding
*)enc
);
201 mbclen_charfound_p(int len
)
203 return MBCLEN_CHARFOUND_P(len
);
209 return rb_enc_name((rb_encoding
*)enc
);
213 enc_prev_char(const char *s
, const char *p
, const char *e
, void *enc
)
215 return rb_enc_prev_char(s
, p
, e
, (rb_encoding
*)enc
);
221 return (void *)rb_enc_get(obj
);
225 enc_asciicompat(void *enc
)
227 return rb_enc_asciicompat((rb_encoding
*)enc
);
233 return (void *)rb_utf8_encoding();
237 enc_associate(VALUE obj
, void *enc
)
239 return rb_enc_associate(obj
, (rb_encoding
*)enc
);
243 ascii8bit_encoding(void)
245 return (void *)rb_ascii8bit_encoding();
249 enc_codelen(int c
, void *enc
)
251 return rb_enc_codelen(c
, (rb_encoding
*)enc
);
255 enc_str_buf_cat(VALUE str
, const char *ptr
, long len
, void *enc
)
257 return rb_enc_str_buf_cat(str
, ptr
, len
, (rb_encoding
*)enc
);
261 enc_mbcput(unsigned int c
, void *buf
, void *enc
)
263 return rb_enc_mbcput(c
, buf
, (rb_encoding
*)enc
);
267 enc_from_index(int idx
)
269 return (void *)rb_enc_from_index(idx
);
273 enc_isspace(OnigCodePoint c
, void *enc
)
275 return rb_enc_isspace(c
, (rb_encoding
*)enc
);
279 intern3(const char *name
, long len
, void *enc
)
281 return rb_intern3(name
, len
, (rb_encoding
*)enc
);
285 enc_compatible(VALUE str1
, VALUE str2
)
287 return (void *)rb_enc_compatible(str1
, str2
);
291 enc_from_encoding(void *enc
)
293 return rb_enc_from_encoding((rb_encoding
*)enc
);
297 encoding_get(VALUE obj
)
299 return ENCODING_GET(obj
);
303 encoding_set(VALUE obj
, int encindex
)
305 ENCODING_SET(obj
, encindex
);
309 encoding_is_ascii8bit(VALUE obj
)
311 return ENCODING_IS_ASCII8BIT(obj
);
315 usascii_encoding(void)
317 return (void *)rb_usascii_encoding();
321 enc_symname_type(const char *name
, long len
, void *enc
, unsigned int allowed_attrset
)
323 return rb_enc_symname_type(name
, len
, (rb_encoding
*)enc
, allowed_attrset
);
327 struct parser_params
*parser
;
330 const rb_code_location_t
*loc
;
331 } reg_named_capture_assign_t
;
334 reg_named_capture_assign_iter(const OnigUChar
*name
, const OnigUChar
*name_end
,
335 int back_num
, int *back_refs
, OnigRegex regex
, void *arg0
)
337 reg_named_capture_assign_t
*arg
= (reg_named_capture_assign_t
*)arg0
;
338 struct parser_params
* p
= arg
->parser
;
339 rb_encoding
*enc
= arg
->enc
;
340 const rb_code_location_t
*loc
= arg
->loc
;
341 long len
= name_end
- name
;
342 const char *s
= (const char *)name
;
344 return rb_reg_named_capture_assign_iter_impl(p
, s
, len
, (void *)enc
, &arg
->succ_block
, loc
);
348 reg_named_capture_assign(struct parser_params
* p
, VALUE regexp
, const rb_code_location_t
*loc
)
350 reg_named_capture_assign_t arg
;
353 arg
.enc
= rb_enc_get(regexp
);
356 onig_foreach_name(RREGEXP_PTR(regexp
), reg_named_capture_assign_iter
, &arg
);
358 if (!arg
.succ_block
) return 0;
359 return RNODE_BLOCK(arg
.succ_block
)->nd_next
;
371 return RB_UNDEF_P(v
);
377 return (int)RB_TEST(obj
);
383 return (int)NIL_P(obj
);
389 return (int)RB_FLONUM_P(obj
);
399 syntax_error_new(void)
401 return rb_class_new_instance(0, 0, rb_eSyntaxError
);
405 obj_frozen(VALUE obj
)
407 return (int)RB_OBJ_FROZEN(obj
);
411 obj_write(VALUE old
, VALUE
*slot
, VALUE young
)
413 return RB_OBJ_WRITE(old
, slot
, young
);
417 obj_written(VALUE old
, VALUE slot
, VALUE young
)
419 return RB_OBJ_WRITTEN(old
, slot
, young
);
425 return rb_default_rs
;
429 rational_raw1(VALUE x
)
431 return rb_rational_raw1(x
);
435 memmove2(void *dest
, const void *src
, size_t t
, size_t n
)
437 return memmove(dest
, src
, rbimpl_size_mul_or_raise(t
, n
));
441 nonempty_memcpy(void *dest
, const void *src
, size_t t
, size_t n
)
443 return ruby_nonempty_memcpy(dest
, src
, rbimpl_size_mul_or_raise(t
, n
));
453 type_p(VALUE obj
, int t
)
455 return (int)RB_TYPE_P(obj
, t
);
461 return (int)RB_FIXNUM_P(obj
);
467 return (int)RB_SYMBOL_P(obj
);
471 zalloc(size_t elemsiz
)
473 return ruby_xcalloc(1, elemsiz
);
482 static rb_imemo_tmpbuf_t
*
483 tmpbuf_parser_heap(void *buf
, rb_imemo_tmpbuf_t
*old_heap
, size_t cnt
)
485 return rb_imemo_tmpbuf_parser_heap(buf
, old_heap
, cnt
);
489 special_const_p(VALUE obj
)
491 return (int)RB_SPECIAL_CONST_P(obj
);
495 builtin_type(VALUE obj
)
497 return (int)RB_BUILTIN_TYPE(obj
);
503 rb_ast_t
*ast
= (rb_ast_t
*)rb_imemo_new(imemo_ast
, 0, 0, 0, nb
);
510 return (((VALUE
)(id
)<<RUBY_SPECIAL_SHIFT
)|SYMBOL_FLAG
);
514 str_coderange_scan_restartable(const char *s
, const char *e
, void *enc
, int *cr
)
516 return rb_str_coderange_scan_restartable(s
, e
, (rb_encoding
*)enc
, cr
);
519 VALUE
rb_io_gets_internal(VALUE io
);
520 extern VALUE rb_mRubyVMFrozenCore
;
521 VALUE
rb_node_case_when_optimizable_literal(const NODE
*const node
);
524 rb_parser_config_initialize(rb_parser_config_t
*config
)
528 config
->malloc
= ruby_xmalloc
;
529 config
->calloc
= ruby_xcalloc
;
530 config
->realloc
= ruby_xrealloc
;
531 config
->free
= ruby_xfree
;
532 config
->alloc_n
= ruby_xmalloc2
;
533 config
->alloc
= ruby_xmalloc
;
534 config
->realloc_n
= ruby_xrealloc2
;
535 config
->zalloc
= zalloc
;
536 config
->rb_memmove
= memmove2
;
537 config
->nonempty_memcpy
= nonempty_memcpy
;
538 config
->xmalloc_mul_add
= rb_xmalloc_mul_add
;
540 config
->tmpbuf_parser_heap
= tmpbuf_parser_heap
;
541 config
->ast_new
= ast_new
;
543 config
->compile_callback
= rb_suppress_tracing
;
544 config
->reg_named_capture_assign
= reg_named_capture_assign
;
546 config
->obj_freeze
= rb_obj_freeze
;
547 config
->obj_hide
= rb_obj_hide
;
548 config
->obj_frozen
= obj_frozen
;
549 config
->type_p
= type_p
;
550 config
->obj_freeze_raw
= OBJ_FREEZE_RAW
;
552 config
->fixnum_p
= fixnum_p
;
553 config
->symbol_p
= symbol_p
;
555 config
->attr_get
= rb_attr_get
;
557 config
->ary_new
= rb_ary_new
;
558 config
->ary_push
= rb_ary_push
;
559 config
->ary_new_from_args
= rb_ary_new_from_args
;
560 config
->ary_pop
= rb_ary_pop
;
561 config
->ary_last
= rb_ary_last
;
562 config
->ary_unshift
= rb_ary_unshift
;
563 config
->ary_new2
= rb_ary_new2
;
564 config
->ary_entry
= rb_ary_entry
;
565 config
->ary_join
= rb_ary_join
;
566 config
->ary_reverse
= rb_ary_reverse
;
567 config
->ary_clear
= rb_ary_clear
;
568 config
->array_len
= rb_array_len
;
569 config
->array_aref
= RARRAY_AREF
;
571 config
->sym_intern_ascii_cstr
= rb_sym_intern_ascii_cstr
;
572 config
->make_temporary_id
= rb_make_temporary_id
;
573 config
->is_local_id
= is_local_id2
;
574 config
->is_attrset_id
= is_attrset_id2
;
575 config
->is_global_name_punct
= is_global_name_punct
;
576 config
->id_type
= id_type
;
577 config
->id_attrset
= rb_id_attrset
;
578 config
->intern
= rb_intern
;
579 config
->intern2
= rb_intern2
;
580 config
->intern3
= intern3
;
581 config
->intern_str
= rb_intern_str
;
582 config
->is_notop_id
= is_notop_id2
;
583 config
->enc_symname_type
= enc_symname_type
;
584 config
->str_intern
= rb_str_intern
;
585 config
->id2name
= rb_id2name
;
586 config
->id2str
= rb_id2str
;
587 config
->id2sym
= rb_id2sym
;
588 config
->sym2id
= rb_sym2id
;
590 config
->str_catf
= rb_str_catf
;
591 config
->str_cat_cstr
= rb_str_cat_cstr
;
592 config
->str_subseq
= rb_str_subseq
;
593 config
->str_dup
= rb_str_dup
;
594 config
->str_new_frozen
= rb_str_new_frozen
;
595 config
->str_buf_new
= rb_str_buf_new
;
596 config
->str_buf_cat
= rb_str_buf_cat
;
597 config
->str_modify
= rb_str_modify
;
598 config
->str_set_len
= rb_str_set_len
;
599 config
->str_cat
= rb_str_cat
;
600 config
->str_resize
= rb_str_resize
;
601 config
->str_new
= rb_str_new
;
602 config
->str_new_cstr
= rb_str_new_cstr
;
603 config
->fstring
= rb_fstring
;
604 config
->is_ascii_string
= is_ascii_string2
;
605 config
->enc_str_new
= enc_str_new
;
606 config
->enc_str_buf_cat
= enc_str_buf_cat
;
607 config
->str_buf_append
= rb_str_buf_append
;
608 config
->str_vcatf
= rb_str_vcatf
;
609 config
->string_value_cstr
= rb_string_value_cstr
;
610 config
->rb_sprintf
= rb_sprintf
;
611 config
->rstring_ptr
= RSTRING_PTR
;
612 config
->rstring_end
= RSTRING_END
;
613 config
->rstring_len
= RSTRING_LEN
;
614 config
->filesystem_str_new_cstr
= rb_filesystem_str_new_cstr
;
615 config
->obj_as_string
= rb_obj_as_string
;
617 config
->hash_clear
= rb_hash_clear
;
618 config
->hash_new
= rb_hash_new
;
619 config
->hash_aset
= rb_hash_aset
;
620 config
->hash_lookup
= rb_hash_lookup
;
621 config
->hash_delete
= rb_hash_delete
;
622 config
->ident_hash_new
= rb_ident_hash_new
;
624 config
->int2fix
= int2fix
;
626 config
->bignum_negate
= bignum_negate
;
627 config
->big_norm
= rb_big_norm
;
628 config
->cstr_to_inum
= rb_cstr_to_inum
;
630 config
->float_new
= rb_float_new
;
631 config
->float_value
= rb_float_value
;
633 config
->num2int
= rb_num2int_inline
;
634 config
->int_positive_pow
= rb_int_positive_pow
;
635 config
->int2num
= rb_int2num_inline
;
636 config
->fix2long
= rb_fix2long
;
638 config
->rational_new
= rb_rational_new
;
639 config
->rational_raw1
= rational_raw1
;
640 config
->rational_set_num
= rational_set_num
;
641 config
->rational_get_num
= rational_get_num
;
643 config
->complex_raw
= rb_complex_raw
;
644 config
->rcomplex_set_real
= rcomplex_set_real
;
645 config
->rcomplex_set_imag
= rcomplex_set_imag
;
646 config
->rcomplex_get_real
= rcomplex_get_real
;
647 config
->rcomplex_get_imag
= rcomplex_get_imag
;
649 config
->stderr_tty_p
= rb_stderr_tty_p
;
650 config
->write_error_str
= rb_write_error_str
;
651 config
->default_rs
= default_rs
;
652 config
->io_write
= rb_io_write
;
653 config
->io_flush
= rb_io_flush
;
654 config
->io_puts
= rb_io_puts
;
655 config
->io_gets_internal
= rb_io_gets_internal
;
657 config
->debug_output_stdout
= rb_ractor_stdout
;
658 config
->debug_output_stderr
= rb_ractor_stderr
;
660 config
->is_usascii_enc
= is_usascii_enc
;
661 config
->enc_isalnum
= enc_isalnum
;
662 config
->enc_precise_mbclen
= enc_precise_mbclen
;
663 config
->mbclen_charfound_p
= mbclen_charfound_p
;
664 config
->enc_name
= enc_name
;
665 config
->enc_prev_char
= enc_prev_char
;
666 config
->enc_get
= enc_get
;
667 config
->enc_asciicompat
= enc_asciicompat
;
668 config
->utf8_encoding
= utf8_encoding
;
669 config
->enc_associate
= enc_associate
;
670 config
->ascii8bit_encoding
= ascii8bit_encoding
;
671 config
->enc_codelen
= enc_codelen
;
672 config
->enc_mbcput
= enc_mbcput
;
673 config
->char_to_option_kcode
= rb_char_to_option_kcode
;
674 config
->ascii8bit_encindex
= rb_ascii8bit_encindex
;
675 config
->enc_find_index
= rb_enc_find_index
;
676 config
->enc_from_index
= enc_from_index
;
677 config
->enc_associate_index
= rb_enc_associate_index
;
678 config
->enc_isspace
= enc_isspace
;
679 config
->enc_coderange_7bit
= ENC_CODERANGE_7BIT
;
680 config
->enc_coderange_unknown
= ENC_CODERANGE_UNKNOWN
;
681 config
->enc_compatible
= enc_compatible
;
682 config
->enc_from_encoding
= enc_from_encoding
;
683 config
->encoding_get
= encoding_get
;
684 config
->encoding_set
= encoding_set
;
685 config
->encoding_is_ascii8bit
= encoding_is_ascii8bit
;
686 config
->usascii_encoding
= usascii_encoding
;
688 config
->ractor_make_shareable
= rb_ractor_make_shareable
;
690 config
->local_defined
= local_defined
;
691 config
->dvar_defined
= dvar_defined
;
693 config
->literal_cmp
= literal_cmp
;
694 config
->literal_hash
= literal_hash
;
696 config
->builtin_class_name
= rb_builtin_class_name
;
697 config
->syntax_error_append
= syntax_error_append
;
698 config
->raise
= rb_raise
;
699 config
->syntax_error_new
= syntax_error_new
;
701 config
->errinfo
= rb_errinfo
;
702 config
->set_errinfo
= rb_set_errinfo
;
703 config
->exc_raise
= rb_exc_raise
;
704 config
->make_exception
= rb_make_exception
;
706 config
->sized_xfree
= ruby_sized_xfree
;
707 config
->sized_realloc_n
= ruby_sized_realloc_n
;
708 config
->obj_write
= obj_write
;
709 config
->obj_written
= obj_written
;
710 config
->gc_register_mark_object
= rb_gc_register_mark_object
;
711 config
->gc_guard
= gc_guard
;
712 config
->gc_mark
= rb_gc_mark
;
713 config
->gc_mark_movable
= rb_gc_mark_movable
;
714 config
->gc_location
= rb_gc_location
;
716 config
->reg_compile
= rb_reg_compile
;
717 config
->reg_check_preprocess
= rb_reg_check_preprocess
;
718 config
->memcicmp
= rb_memcicmp
;
720 config
->compile_warn
= rb_compile_warn
;
721 config
->compile_warning
= rb_compile_warning
;
722 config
->bug
= rb_bug
;
723 config
->fatal
= rb_fatal
;
724 config
->verbose
= ruby_verbose2
;
726 config
->make_backtrace
= rb_make_backtrace
;
728 config
->scan_hex
= ruby_scan_hex
;
729 config
->scan_oct
= ruby_scan_oct
;
730 config
->scan_digits
= ruby_scan_digits
;
731 config
->strtod
= ruby_strtod
;
733 config
->rbool
= rbool
;
734 config
->undef_p
= undef_p
;
735 config
->rtest
= rtest
;
736 config
->nil_p
= nil_p
;
737 config
->flonum_p
= flonum_p
;
739 config
->qtrue
= Qtrue
;
740 config
->qfalse
= Qfalse
;
741 config
->qundef
= Qundef
;
742 config
->eArgError
= rb_eArgError
;
743 config
->mRubyVMFrozenCore
= rb_mRubyVMFrozenCore
;
744 config
->long2int
= rb_long2int
;
745 config
->special_const_p
= special_const_p
;
746 config
->builtin_type
= builtin_type
;
748 config
->node_case_when_optimizable_literal
= rb_node_case_when_optimizable_literal
;
751 config
->static_id2sym
= static_id2sym
;
752 config
->str_coderange_scan_restartable
= str_coderange_scan_restartable
;
758 struct ruby_parser
*parser
;
759 rb_parser_config_t
*config
;
760 rb_parser_t
*parser_params
;
762 config
= rb_ruby_parser_config_new(ruby_xmalloc
);
763 rb_parser_config_initialize(config
);
766 * Create parser_params ahead of vparser because
767 * rb_ruby_parser_new can run GC so if create vparser
768 * first, parser_mark tries to mark not initialized parser_params.
770 parser_params
= rb_ruby_parser_new(config
);
771 VALUE vparser
= TypedData_Make_Struct(0, struct ruby_parser
,
772 &ruby_parser_data_type
, parser
);
773 parser
->parser_params
= parser_params
;
779 rb_parser_set_options(VALUE vparser
, int print
, int loop
, int chomp
, int split
)
781 struct ruby_parser
*parser
;
783 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
784 rb_ruby_parser_set_options(parser
->parser_params
, print
, loop
, chomp
, split
);
788 rb_parser_set_context(VALUE vparser
, const struct rb_iseq_struct
*base
, int main
)
790 struct ruby_parser
*parser
;
792 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
793 rb_ruby_parser_set_context(parser
->parser_params
, base
, main
);
798 rb_parser_set_script_lines(VALUE vparser
, VALUE lines
)
800 struct ruby_parser
*parser
;
802 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
803 rb_ruby_parser_set_script_lines(parser
->parser_params
, lines
);
807 rb_parser_error_tolerant(VALUE vparser
)
809 struct ruby_parser
*parser
;
811 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
812 rb_ruby_parser_error_tolerant(parser
->parser_params
);
816 rb_parser_compile_file_path(VALUE vparser
, VALUE fname
, VALUE file
, int start
)
818 struct ruby_parser
*parser
;
821 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
822 ast
= rb_ruby_parser_compile_file_path(parser
->parser_params
, fname
, file
, start
);
823 RB_GC_GUARD(vparser
);
829 rb_parser_keep_tokens(VALUE vparser
)
831 struct ruby_parser
*parser
;
833 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
834 rb_ruby_parser_keep_tokens(parser
->parser_params
);
838 rb_parser_compile_generic(VALUE vparser
, VALUE (*lex_gets
)(VALUE
, int), VALUE fname
, VALUE input
, int start
)
840 struct ruby_parser
*parser
;
843 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
844 ast
= rb_ruby_parser_compile_generic(parser
->parser_params
, lex_gets
, fname
, input
, start
);
845 RB_GC_GUARD(vparser
);
851 rb_parser_compile_string(VALUE vparser
, const char *f
, VALUE s
, int line
)
853 struct ruby_parser
*parser
;
856 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
857 ast
= rb_ruby_parser_compile_string(parser
->parser_params
, f
, s
, line
);
858 RB_GC_GUARD(vparser
);
864 rb_parser_compile_string_path(VALUE vparser
, VALUE f
, VALUE s
, int line
)
866 struct ruby_parser
*parser
;
869 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
870 ast
= rb_ruby_parser_compile_string_path(parser
->parser_params
, f
, s
, line
);
871 RB_GC_GUARD(vparser
);
877 rb_parser_encoding(VALUE vparser
)
879 struct ruby_parser
*parser
;
881 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
882 return rb_ruby_parser_encoding(parser
->parser_params
);
886 rb_parser_end_seen_p(VALUE vparser
)
888 struct ruby_parser
*parser
;
890 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
891 return RBOOL(rb_ruby_parser_end_seen_p(parser
->parser_params
));
895 rb_parser_set_yydebug(VALUE vparser
, VALUE flag
)
897 struct ruby_parser
*parser
;
899 TypedData_Get_Struct(vparser
, struct ruby_parser
, &ruby_parser_data_type
, parser
);
900 rb_ruby_parser_set_yydebug(parser
->parser_params
, RTEST(flag
));
906 /* For "ISO C requires a translation unit to contain at least one declaration" */
908 rb_parser_dummy(void)