kanayago 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +261 -0
  3. data/README.md +1 -1
  4. data/Rakefile +5 -48
  5. data/ext/kanayago/extconf.rb +8 -0
  6. data/ext/kanayago/kanayago.c +30 -185
  7. data/ext/kanayago/scope_node.c +2 -16
  8. data/ext/kanayago/variable_node.c +2 -1
  9. data/lib/kanayago/call_node.rb +19 -0
  10. data/lib/kanayago/constant_node.rb +15 -0
  11. data/lib/kanayago/literal_node.rb +4 -0
  12. data/lib/kanayago/scope_node.rb +14 -0
  13. data/lib/kanayago/statement_node.rb +16 -0
  14. data/lib/kanayago/variable_node.rb +4 -0
  15. data/lib/kanayago/version.rb +1 -1
  16. data/lib/kanayago.rb +3 -16
  17. data/script/setup_parser.rb +136 -0
  18. metadata +6 -64
  19. data/ext/kanayago/ccan/check_type/check_type.h +0 -63
  20. data/ext/kanayago/ccan/container_of/container_of.h +0 -142
  21. data/ext/kanayago/ccan/list/list.h +0 -791
  22. data/ext/kanayago/ccan/str/str.h +0 -17
  23. data/ext/kanayago/constant.h +0 -53
  24. data/ext/kanayago/id.h +0 -354
  25. data/ext/kanayago/id_table.h +0 -54
  26. data/ext/kanayago/include/ruby/st.h +0 -199
  27. data/ext/kanayago/internal/array.h +0 -154
  28. data/ext/kanayago/internal/basic_operators.h +0 -65
  29. data/ext/kanayago/internal/bignum.h +0 -245
  30. data/ext/kanayago/internal/bits.h +0 -650
  31. data/ext/kanayago/internal/compile.h +0 -34
  32. data/ext/kanayago/internal/compilers.h +0 -107
  33. data/ext/kanayago/internal/complex.h +0 -29
  34. data/ext/kanayago/internal/encoding.h +0 -39
  35. data/ext/kanayago/internal/error.h +0 -251
  36. data/ext/kanayago/internal/fixnum.h +0 -185
  37. data/ext/kanayago/internal/gc.h +0 -358
  38. data/ext/kanayago/internal/hash.h +0 -194
  39. data/ext/kanayago/internal/imemo.h +0 -322
  40. data/ext/kanayago/internal/io.h +0 -163
  41. data/ext/kanayago/internal/namespace.h +0 -81
  42. data/ext/kanayago/internal/numeric.h +0 -275
  43. data/ext/kanayago/internal/parse.h +0 -131
  44. data/ext/kanayago/internal/rational.h +0 -71
  45. data/ext/kanayago/internal/re.h +0 -33
  46. data/ext/kanayago/internal/ruby_parser.h +0 -125
  47. data/ext/kanayago/internal/sanitizers.h +0 -346
  48. data/ext/kanayago/internal/serial.h +0 -23
  49. data/ext/kanayago/internal/set_table.h +0 -70
  50. data/ext/kanayago/internal/static_assert.h +0 -16
  51. data/ext/kanayago/internal/string.h +0 -203
  52. data/ext/kanayago/internal/symbol.h +0 -46
  53. data/ext/kanayago/internal/thread.h +0 -112
  54. data/ext/kanayago/internal/variable.h +0 -74
  55. data/ext/kanayago/internal/vm.h +0 -136
  56. data/ext/kanayago/internal/warnings.h +0 -16
  57. data/ext/kanayago/internal.h +0 -105
  58. data/ext/kanayago/lex.c +0 -302
  59. data/ext/kanayago/method.h +0 -271
  60. data/ext/kanayago/node.c +0 -446
  61. data/ext/kanayago/node.h +0 -122
  62. data/ext/kanayago/node_name.inc +0 -224
  63. data/ext/kanayago/parse.c +0 -27377
  64. data/ext/kanayago/parse.h +0 -244
  65. data/ext/kanayago/parser_bits.h +0 -564
  66. data/ext/kanayago/parser_node.h +0 -32
  67. data/ext/kanayago/parser_st.c +0 -165
  68. data/ext/kanayago/parser_st.h +0 -162
  69. data/ext/kanayago/parser_value.h +0 -106
  70. data/ext/kanayago/probes.h +0 -4
  71. data/ext/kanayago/ruby_assert.h +0 -14
  72. data/ext/kanayago/ruby_atomic.h +0 -66
  73. data/ext/kanayago/ruby_parser.c +0 -1137
  74. data/ext/kanayago/rubyparser.h +0 -1394
  75. data/ext/kanayago/shape.h +0 -444
  76. data/ext/kanayago/st.c +0 -3223
  77. data/ext/kanayago/symbol.h +0 -116
  78. data/ext/kanayago/thread_pthread.h +0 -175
  79. data/ext/kanayago/universal_parser.c +0 -211
  80. data/ext/kanayago/vm_core.h +0 -2349
  81. data/ext/kanayago/vm_opts.h +0 -67
@@ -1,275 +0,0 @@
1
- #ifndef INTERNAL_NUMERIC_H /*-*-C-*-vi:se ft=c:*/
2
- #define INTERNAL_NUMERIC_H
3
- /**
4
- * @author Ruby developers <ruby-core@ruby-lang.org>
5
- * @copyright This file is a part of the programming language Ruby.
6
- * Permission is hereby granted, to either redistribute and/or
7
- * modify this file, provided that the conditions mentioned in the
8
- * file COPYING are met. Consult the file for details.
9
- * @brief Internal header for Numeric.
10
- */
11
- #include "internal/bignum.h" /* for BIGNUM_POSITIVE_P */
12
- #include "internal/bits.h" /* for RUBY_BIT_ROTL */
13
- #include "internal/fixnum.h" /* for FIXNUM_POSITIVE_P */
14
- #include "internal/vm.h" /* for rb_method_basic_definition_p */
15
- #include "ruby/intern.h" /* for rb_cmperr */
16
- #include "ruby/ruby.h" /* for USE_FLONUM */
17
-
18
- #define ROUND_TO(mode, even, up, down) \
19
- ((mode) == RUBY_NUM_ROUND_HALF_EVEN ? even : \
20
- (mode) == RUBY_NUM_ROUND_HALF_UP ? up : down)
21
- #define ROUND_FUNC(mode, name) \
22
- ROUND_TO(mode, name##_half_even, name##_half_up, name##_half_down)
23
- #define ROUND_CALL(mode, name, args) \
24
- ROUND_TO(mode, name##_half_even args, \
25
- name##_half_up args, name##_half_down args)
26
-
27
- #ifndef ROUND_DEFAULT
28
- # define ROUND_DEFAULT RUBY_NUM_ROUND_HALF_UP
29
- #endif
30
-
31
- enum ruby_num_rounding_mode {
32
- RUBY_NUM_ROUND_HALF_UP,
33
- RUBY_NUM_ROUND_HALF_EVEN,
34
- RUBY_NUM_ROUND_HALF_DOWN,
35
- RUBY_NUM_ROUND_DEFAULT = ROUND_DEFAULT,
36
- };
37
-
38
- /* same as internal.h */
39
- #define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
40
- #define roomof(x, y) (((x) + (y) - 1) / (y))
41
- #define type_roomof(x, y) roomof(sizeof(x), sizeof(y))
42
-
43
- #if SIZEOF_DOUBLE <= SIZEOF_VALUE
44
- typedef double rb_float_value_type;
45
- #else
46
- typedef struct {
47
- VALUE values[roomof(SIZEOF_DOUBLE, SIZEOF_VALUE)];
48
- } rb_float_value_type;
49
- #endif
50
-
51
- struct RFloat {
52
- struct RBasic basic;
53
- rb_float_value_type float_value;
54
- };
55
-
56
- #define RFLOAT(obj) ((struct RFloat *)(obj))
57
-
58
- /* numeric.c */
59
- int rb_num_to_uint(VALUE val, unsigned int *ret);
60
- VALUE ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl);
61
- double ruby_float_step_size(double beg, double end, double unit, int excl);
62
- int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl, int allow_endless);
63
- int rb_num_negative_p(VALUE);
64
- VALUE rb_int_succ(VALUE num);
65
- VALUE rb_float_uminus(VALUE num);
66
- VALUE rb_int_plus(VALUE x, VALUE y);
67
- VALUE rb_float_plus(VALUE x, VALUE y);
68
- VALUE rb_int_minus(VALUE x, VALUE y);
69
- VALUE rb_float_minus(VALUE x, VALUE y);
70
- VALUE rb_int_mul(VALUE x, VALUE y);
71
- VALUE rb_float_mul(VALUE x, VALUE y);
72
- VALUE rb_float_div(VALUE x, VALUE y);
73
- VALUE rb_int_idiv(VALUE x, VALUE y);
74
- VALUE rb_int_modulo(VALUE x, VALUE y);
75
- VALUE rb_int2str(VALUE num, int base);
76
- VALUE rb_fix_plus(VALUE x, VALUE y);
77
- VALUE rb_int_gt(VALUE x, VALUE y);
78
- VALUE rb_float_gt(VALUE x, VALUE y);
79
- VALUE rb_int_ge(VALUE x, VALUE y);
80
- enum ruby_num_rounding_mode rb_num_get_rounding_option(VALUE opts);
81
- double rb_int_fdiv_double(VALUE x, VALUE y);
82
- VALUE rb_int_pow(VALUE x, VALUE y);
83
- VALUE rb_float_pow(VALUE x, VALUE y);
84
- VALUE rb_int_cmp(VALUE x, VALUE y);
85
- VALUE rb_int_equal(VALUE x, VALUE y);
86
- VALUE rb_int_divmod(VALUE x, VALUE y);
87
- VALUE rb_int_and(VALUE x, VALUE y);
88
- VALUE rb_int_xor(VALUE x, VALUE y);
89
- VALUE rb_int_lshift(VALUE x, VALUE y);
90
- VALUE rb_int_rshift(VALUE x, VALUE y);
91
- VALUE rb_int_div(VALUE x, VALUE y);
92
- int rb_int_positive_p(VALUE num);
93
- int rb_int_negative_p(VALUE num);
94
- VALUE rb_check_integer_type(VALUE);
95
- VALUE rb_num_pow(VALUE x, VALUE y);
96
- VALUE rb_float_ceil(VALUE num, int ndigits);
97
- VALUE rb_float_floor(VALUE x, int ndigits);
98
- VALUE rb_float_abs(VALUE flt);
99
- static inline VALUE rb_num_compare_with_zero(VALUE num, ID mid);
100
- static inline int rb_num_positive_int_p(VALUE num);
101
- static inline int rb_num_negative_int_p(VALUE num);
102
- static inline double rb_float_flonum_value(VALUE v);
103
- static inline double rb_float_noflonum_value(VALUE v);
104
- static inline double rb_float_value_inline(VALUE v);
105
- static inline VALUE rb_float_new_inline(double d);
106
- static inline bool INT_POSITIVE_P(VALUE num);
107
- static inline bool INT_NEGATIVE_P(VALUE num);
108
- static inline bool FLOAT_ZERO_P(VALUE num);
109
- #define rb_float_value rb_float_value_inline
110
- #define rb_float_new rb_float_new_inline
111
-
112
- RUBY_SYMBOL_EXPORT_BEGIN
113
- /* numeric.c (export) */
114
- RUBY_SYMBOL_EXPORT_END
115
-
116
- VALUE rb_flo_div_flo(VALUE x, VALUE y);
117
- double ruby_float_mod(double x, double y);
118
- VALUE rb_float_equal(VALUE x, VALUE y);
119
- int rb_float_cmp(VALUE x, VALUE y);
120
- VALUE rb_float_eql(VALUE x, VALUE y);
121
- VALUE rb_fix_aref(VALUE fix, VALUE idx);
122
- VALUE rb_int_zero_p(VALUE num);
123
- VALUE rb_int_even_p(VALUE num);
124
- VALUE rb_int_odd_p(VALUE num);
125
- VALUE rb_int_abs(VALUE num);
126
- VALUE rb_int_bit_length(VALUE num);
127
- VALUE rb_int_uminus(VALUE num);
128
- VALUE rb_int_comp(VALUE num);
129
-
130
- static inline bool
131
- INT_POSITIVE_P(VALUE num)
132
- {
133
- if (FIXNUM_P(num)) {
134
- return FIXNUM_POSITIVE_P(num);
135
- }
136
- else {
137
- return BIGNUM_POSITIVE_P(num);
138
- }
139
- }
140
-
141
- static inline bool
142
- INT_NEGATIVE_P(VALUE num)
143
- {
144
- if (FIXNUM_P(num)) {
145
- return FIXNUM_NEGATIVE_P(num);
146
- }
147
- else {
148
- return BIGNUM_NEGATIVE_P(num);
149
- }
150
- }
151
-
152
- static inline bool
153
- FLOAT_ZERO_P(VALUE num)
154
- {
155
- return RFLOAT_VALUE(num) == 0.0;
156
- }
157
-
158
- static inline VALUE
159
- rb_num_compare_with_zero(VALUE num, ID mid)
160
- {
161
- VALUE zero = INT2FIX(0);
162
- VALUE r = rb_check_funcall(num, mid, 1, &zero);
163
- if (RB_UNDEF_P(r)) {
164
- rb_cmperr(num, zero);
165
- }
166
- return r;
167
- }
168
-
169
- static inline int
170
- rb_num_positive_int_p(VALUE num)
171
- {
172
- const ID mid = '>';
173
-
174
- if (FIXNUM_P(num)) {
175
- if (rb_method_basic_definition_p(rb_cInteger, mid))
176
- return FIXNUM_POSITIVE_P(num);
177
- }
178
- else if (RB_TYPE_P(num, T_BIGNUM)) {
179
- if (rb_method_basic_definition_p(rb_cInteger, mid))
180
- return BIGNUM_POSITIVE_P(num);
181
- }
182
- return RTEST(rb_num_compare_with_zero(num, mid));
183
- }
184
-
185
- static inline int
186
- rb_num_negative_int_p(VALUE num)
187
- {
188
- const ID mid = '<';
189
-
190
- if (FIXNUM_P(num)) {
191
- if (rb_method_basic_definition_p(rb_cInteger, mid))
192
- return FIXNUM_NEGATIVE_P(num);
193
- }
194
- else if (RB_TYPE_P(num, T_BIGNUM)) {
195
- if (rb_method_basic_definition_p(rb_cInteger, mid))
196
- return BIGNUM_NEGATIVE_P(num);
197
- }
198
- return RTEST(rb_num_compare_with_zero(num, mid));
199
- }
200
-
201
- static inline double
202
- rb_float_flonum_value(VALUE v)
203
- {
204
- #if USE_FLONUM
205
- if (v != (VALUE)0x8000000000000002) { /* LIKELY */
206
- union {
207
- double d;
208
- VALUE v;
209
- } t;
210
-
211
- VALUE b63 = (v >> 63);
212
- /* e: xx1... -> 011... */
213
- /* xx0... -> 100... */
214
- /* ^b63 */
215
- t.v = RUBY_BIT_ROTR((2 - b63) | (v & ~(VALUE)0x03), 3);
216
- return t.d;
217
- }
218
- #endif
219
- return 0.0;
220
- }
221
-
222
- static inline double
223
- rb_float_noflonum_value(VALUE v)
224
- {
225
- #if SIZEOF_DOUBLE <= SIZEOF_VALUE
226
- return RFLOAT(v)->float_value;
227
- #else
228
- union {
229
- rb_float_value_type v;
230
- double d;
231
- } u = {RFLOAT(v)->float_value};
232
- return u.d;
233
- #endif
234
- }
235
-
236
- static inline double
237
- rb_float_value_inline(VALUE v)
238
- {
239
- if (FLONUM_P(v)) {
240
- return rb_float_flonum_value(v);
241
- }
242
- return rb_float_noflonum_value(v);
243
- }
244
-
245
- static inline VALUE
246
- rb_float_new_inline(double d)
247
- {
248
- #if USE_FLONUM
249
- union {
250
- double d;
251
- VALUE v;
252
- } t;
253
- int bits;
254
-
255
- t.d = d;
256
- bits = (int)((VALUE)(t.v >> 60) & 0x7);
257
- /* bits contains 3 bits of b62..b60. */
258
- /* bits - 3 = */
259
- /* b011 -> b000 */
260
- /* b100 -> b001 */
261
-
262
- if (t.v != 0x3000000000000000 /* 1.72723e-77 */ &&
263
- !((bits-3) & ~0x01)) {
264
- return (RUBY_BIT_ROTL(t.v, 3) & ~(VALUE)0x01) | 0x02;
265
- }
266
- else if (t.v == (VALUE)0) {
267
- /* +0.0 */
268
- return 0x8000000000000002;
269
- }
270
- /* out of range */
271
- #endif
272
- return rb_float_new_in_heap(d);
273
- }
274
-
275
- #endif /* INTERNAL_NUMERIC_H */
@@ -1,131 +0,0 @@
1
- #ifndef INTERNAL_PARSE_H /*-*-C-*-vi:se ft=c:*/
2
- #define INTERNAL_PARSE_H
3
- /**
4
- * @author Ruby developers <ruby-core@ruby-lang.org>
5
- * @copyright This file is a part of the programming language Ruby.
6
- * Permission is hereby granted, to either redistribute and/or
7
- * modify this file, provided that the conditions mentioned in the
8
- * file COPYING are met. Consult the file for details.
9
- * @brief Internal header for the parser.
10
- */
11
- #include <limits.h>
12
- #include "rubyparser.h"
13
- #include "internal/static_assert.h"
14
-
15
- // The default parser to use for Ruby code.
16
- typedef enum {
17
- RB_DEFAULT_PARSER_PARSE_Y,
18
- RB_DEFAULT_PARSER_PRISM,
19
- } ruby_default_parser_enum;
20
-
21
- ruby_default_parser_enum rb_ruby_default_parser(void);
22
- void rb_ruby_default_parser_set(ruby_default_parser_enum parser);
23
-
24
- #define rb_ruby_prism_p() (rb_ruby_default_parser() == RB_DEFAULT_PARSER_PRISM)
25
-
26
- #ifdef UNIVERSAL_PARSER
27
- #define rb_encoding const void
28
- #endif
29
-
30
- struct rb_iseq_struct; /* in vm_core.h */
31
-
32
- /* structs for managing terminator of string literal and heredocment */
33
- typedef struct rb_strterm_literal_struct {
34
- long nest;
35
- int func; /* STR_FUNC_* (e.g., STR_FUNC_ESCAPE and STR_FUNC_EXPAND) */
36
- int paren; /* '(' of `%q(...)` */
37
- int term; /* ')' of `%q(...)` */
38
- } rb_strterm_literal_t;
39
-
40
- typedef struct rb_strterm_heredoc_struct {
41
- rb_parser_string_t *lastline; /* the string of line that contains `<<"END"` */
42
- long offset; /* the column of END in `<<"END"` */
43
- int sourceline; /* lineno of the line that contains `<<"END"` */
44
- unsigned length; /* the length of END in `<<"END"` */
45
- uint8_t quote;
46
- uint8_t func;
47
- } rb_strterm_heredoc_t;
48
-
49
- #define HERETERM_LENGTH_MAX UINT_MAX
50
-
51
- typedef struct rb_strterm_struct {
52
- bool heredoc;
53
- union {
54
- rb_strterm_literal_t literal;
55
- rb_strterm_heredoc_t heredoc;
56
- } u;
57
- } rb_strterm_t;
58
-
59
- /* parse.y */
60
- void rb_ruby_parser_mark(void *ptr);
61
- size_t rb_ruby_parser_memsize(const void *ptr);
62
-
63
- void rb_ruby_parser_set_options(rb_parser_t *p, int print, int loop, int chomp, int split);
64
- rb_parser_t *rb_ruby_parser_set_context(rb_parser_t *p, const struct rb_iseq_struct *base, int main);
65
- void rb_ruby_parser_set_script_lines(rb_parser_t *p);
66
- void rb_ruby_parser_error_tolerant(rb_parser_t *p);
67
- void rb_ruby_parser_keep_tokens(rb_parser_t *p);
68
- typedef rb_parser_string_t*(rb_parser_lex_gets_func)(struct parser_params*, rb_parser_input_data, int);
69
- rb_ast_t *rb_parser_compile(rb_parser_t *p, rb_parser_lex_gets_func *gets, VALUE fname, rb_parser_input_data input, int line);
70
-
71
- RUBY_SYMBOL_EXPORT_BEGIN
72
-
73
- rb_encoding *rb_ruby_parser_encoding(rb_parser_t *p);
74
- int rb_ruby_parser_end_seen_p(rb_parser_t *p);
75
- int rb_ruby_parser_set_yydebug(rb_parser_t *p, int flag);
76
- rb_parser_string_t *rb_str_to_parser_string(rb_parser_t *p, VALUE str);
77
- void rb_parser_string_free(rb_parser_t *p, rb_parser_string_t *str);
78
-
79
- int rb_parser_dvar_defined_ref(struct parser_params*, ID, ID**);
80
- ID rb_parser_internal_id(struct parser_params*);
81
- typedef void (*rb_parser_reg_fragment_error_func)(struct parser_params *, VALUE);
82
- int rb_parser_reg_fragment_check(struct parser_params*, rb_parser_string_t*, int, rb_parser_reg_fragment_error_func);
83
- int rb_reg_named_capture_assign_iter_impl(struct parser_params *p, const char *s, long len, rb_encoding *enc, NODE **succ_block, const rb_code_location_t *loc, rb_parser_assignable_func assignable);
84
- int rb_parser_local_defined(struct parser_params *p, ID id, const struct rb_iseq_struct *iseq);
85
- NODE *rb_parser_assignable(struct parser_params *p, ID id, NODE *val, const YYLTYPE *loc);
86
-
87
- RUBY_SYMBOL_EXPORT_END
88
-
89
- #ifndef UNIVERSAL_PARSER
90
- rb_parser_t *rb_ruby_parser_allocate(void);
91
- rb_parser_t *rb_ruby_parser_new(void);
92
- #endif
93
-
94
- #ifdef RIPPER
95
- void ripper_parser_mark(void *ptr);
96
- void ripper_parser_free(void *ptr);
97
- size_t ripper_parser_memsize(const void *ptr);
98
- void ripper_error(struct parser_params *p);
99
- VALUE ripper_value(struct parser_params *p);
100
- int rb_ruby_parser_get_yydebug(rb_parser_t *p);
101
- void rb_ruby_parser_set_value(rb_parser_t *p, VALUE value);
102
- int rb_ruby_parser_error_p(rb_parser_t *p);
103
- VALUE rb_ruby_parser_debug_output(rb_parser_t *p);
104
- void rb_ruby_parser_set_debug_output(rb_parser_t *p, VALUE output);
105
- VALUE rb_ruby_parser_parsing_thread(rb_parser_t *p);
106
- void rb_ruby_parser_set_parsing_thread(rb_parser_t *p, VALUE parsing_thread);
107
- void rb_ruby_parser_ripper_initialize(rb_parser_t *p, rb_parser_lex_gets_func *gets, rb_parser_input_data input, VALUE sourcefile_string, const char *sourcefile, int sourceline);
108
- VALUE rb_ruby_parser_result(rb_parser_t *p);
109
- rb_encoding *rb_ruby_parser_enc(rb_parser_t *p);
110
- VALUE rb_ruby_parser_ruby_sourcefile_string(rb_parser_t *p);
111
- int rb_ruby_parser_ruby_sourceline(rb_parser_t *p);
112
- int rb_ruby_parser_lex_state(rb_parser_t *p);
113
- void rb_ruby_ripper_parse0(rb_parser_t *p);
114
- int rb_ruby_ripper_dedent_string(rb_parser_t *p, rb_parser_string_t *string, int width);
115
- int rb_ruby_ripper_initialized_p(rb_parser_t *p);
116
- void rb_ruby_ripper_parser_initialize(rb_parser_t *p);
117
- long rb_ruby_ripper_column(rb_parser_t *p);
118
- long rb_ruby_ripper_token_len(rb_parser_t *p);
119
- rb_parser_string_t *rb_ruby_ripper_lex_lastline(rb_parser_t *p);
120
- VALUE rb_ruby_ripper_lex_state_name(struct parser_params *p, int state);
121
- #ifdef UNIVERSAL_PARSER
122
- rb_parser_t *rb_ripper_parser_params_allocate(const rb_parser_config_t *config);
123
- #endif
124
- struct parser_params *rb_ruby_ripper_parser_allocate(void);
125
- #endif
126
-
127
- #ifdef UNIVERSAL_PARSER
128
- #undef rb_encoding
129
- #endif
130
-
131
- #endif /* INTERNAL_PARSE_H */
@@ -1,71 +0,0 @@
1
- #ifndef INTERNAL_RATIONAL_H /*-*-C-*-vi:se ft=c:*/
2
- #define INTERNAL_RATIONAL_H
3
- /**
4
- * @author Ruby developers <ruby-core@ruby-lang.org>
5
- * @copyright This file is a part of the programming language Ruby.
6
- * Permission is hereby granted, to either redistribute and/or
7
- * modify this file, provided that the conditions mentioned in the
8
- * file COPYING are met. Consult the file for details.
9
- * @brief Internal header for Rational.
10
- */
11
- #include "ruby/internal/config.h" /* for HAVE_LIBGMP */
12
- #include "ruby/ruby.h" /* for struct RBasic */
13
- #include "internal/numeric.h" /* for INT_POSITIVE_P */
14
- #include "ruby_assert.h" /* for assert */
15
-
16
- struct RRational {
17
- struct RBasic basic;
18
- VALUE num;
19
- VALUE den;
20
- };
21
-
22
- #define RRATIONAL(obj) ((struct RRational *)(obj))
23
-
24
- /* rational.c */
25
- VALUE rb_rational_canonicalize(VALUE x);
26
- VALUE rb_rational_uminus(VALUE self);
27
- VALUE rb_rational_plus(VALUE self, VALUE other);
28
- VALUE rb_rational_minus(VALUE self, VALUE other);
29
- VALUE rb_rational_mul(VALUE self, VALUE other);
30
- VALUE rb_rational_div(VALUE self, VALUE other);
31
- VALUE rb_lcm(VALUE x, VALUE y);
32
- VALUE rb_rational_reciprocal(VALUE x);
33
- VALUE rb_cstr_to_rat(const char *, int);
34
- VALUE rb_rational_hash(VALUE self);
35
- VALUE rb_rational_abs(VALUE self);
36
- VALUE rb_rational_cmp(VALUE self, VALUE other);
37
- VALUE rb_rational_pow(VALUE self, VALUE other);
38
- VALUE rb_rational_floor(VALUE self, int ndigits);
39
- VALUE rb_numeric_quo(VALUE x, VALUE y);
40
- VALUE rb_flo_round_by_rational(int argc, VALUE *argv, VALUE num);
41
- VALUE rb_float_numerator(VALUE x);
42
- VALUE rb_float_denominator(VALUE x);
43
-
44
- static inline void RATIONAL_SET_NUM(VALUE r, VALUE n);
45
- static inline void RATIONAL_SET_DEN(VALUE r, VALUE d);
46
-
47
- RUBY_SYMBOL_EXPORT_BEGIN
48
- /* rational.c (export) */
49
- VALUE rb_gcd(VALUE x, VALUE y);
50
- VALUE rb_gcd_normal(VALUE self, VALUE other);
51
- #if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
52
- VALUE rb_gcd_gmp(VALUE x, VALUE y);
53
- #endif
54
- RUBY_SYMBOL_EXPORT_END
55
-
56
- static inline void
57
- RATIONAL_SET_NUM(VALUE r, VALUE n)
58
- {
59
- assert(RB_INTEGER_TYPE_P(n));
60
- RB_OBJ_WRITE(r, &RRATIONAL(r)->num, n);
61
- }
62
-
63
- static inline void
64
- RATIONAL_SET_DEN(VALUE r, VALUE d)
65
- {
66
- assert(RB_INTEGER_TYPE_P(d));
67
- assert(INT_POSITIVE_P(d));
68
- RB_OBJ_WRITE(r, &RRATIONAL(r)->den, d);
69
- }
70
-
71
- #endif /* INTERNAL_RATIONAL_H */
@@ -1,33 +0,0 @@
1
- #ifndef INTERNAL_RE_H /*-*-C-*-vi:se ft=c:*/
2
- #define INTERNAL_RE_H
3
- /**
4
- * @author Ruby developers <ruby-core@ruby-lang.org>
5
- * @copyright This file is a part of the programming language Ruby.
6
- * Permission is hereby granted, to either redistribute and/or
7
- * modify this file, provided that the conditions mentioned in the
8
- * file COPYING are met. Consult the file for details.
9
- * @brief Internal header for Regexp.
10
- */
11
- #include "ruby/internal/stdbool.h" /* for bool */
12
- #include "ruby/ruby.h" /* for VALUE */
13
-
14
- /* re.c */
15
- VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline);
16
- VALUE rb_reg_check_preprocess(VALUE);
17
- long rb_reg_search0(VALUE, VALUE, long, int, int, VALUE *);
18
- VALUE rb_reg_match_p(VALUE re, VALUE str, long pos);
19
- bool rb_reg_start_with_p(VALUE re, VALUE str);
20
- VALUE rb_reg_hash(VALUE re);
21
- VALUE rb_reg_equal(VALUE re1, VALUE re2);
22
- VALUE rb_backref_set_string(VALUE string, long pos, long len);
23
- void rb_match_unbusy(VALUE);
24
- int rb_match_count(VALUE match);
25
- VALUE rb_reg_new_ary(VALUE ary, int options);
26
- VALUE rb_reg_last_defined(VALUE match);
27
-
28
- #define ARG_REG_OPTION_MASK \
29
- (ONIG_OPTION_IGNORECASE|ONIG_OPTION_MULTILINE|ONIG_OPTION_EXTEND)
30
- #define ARG_ENCODING_FIXED 16
31
- #define ARG_ENCODING_NONE 32
32
-
33
- #endif /* INTERNAL_RE_H */
@@ -1,125 +0,0 @@
1
- #ifndef INTERNAL_RUBY_PARSE_H
2
- #define INTERNAL_RUBY_PARSE_H
3
-
4
- #include "internal.h"
5
- #include "internal/bignum.h"
6
- #include "internal/compilers.h"
7
- #include "internal/complex.h"
8
- #include "internal/parse.h"
9
- #include "internal/rational.h"
10
- #include "rubyparser.h"
11
- #include "vm.h"
12
-
13
- struct lex_pointer_string {
14
- VALUE str;
15
- long ptr;
16
- };
17
-
18
- // Add Ruby's Parser struct and enum for Kanayago
19
- enum lex_type {
20
- lex_type_str,
21
- lex_type_io,
22
- lex_type_array,
23
- lex_type_generic,
24
- };
25
-
26
- struct ruby_parser {
27
- rb_parser_t *parser_params;
28
- enum lex_type type;
29
- union {
30
- struct lex_pointer_string lex_str;
31
- struct {
32
- VALUE file;
33
- } lex_io;
34
- struct {
35
- VALUE ary;
36
- } lex_array;
37
- } data;
38
- };
39
- // End for Kanayago
40
-
41
- RUBY_SYMBOL_EXPORT_BEGIN
42
- #ifdef UNIVERSAL_PARSER
43
- const rb_parser_config_t *rb_ruby_parser_config(void);
44
- rb_parser_t *rb_parser_params_new(void);
45
- #endif
46
- VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
47
- VALUE rb_parser_new(void);
48
- VALUE rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line);
49
- VALUE rb_str_new_parser_string(rb_parser_string_t *str);
50
- VALUE rb_str_new_mutable_parser_string(rb_parser_string_t *str);
51
- rb_parser_string_t *rb_parser_lex_get_str(struct parser_params *p, struct lex_pointer_string *ptr_str);
52
-
53
- VALUE rb_node_str_string_val(const NODE *);
54
- VALUE rb_node_sym_string_val(const NODE *);
55
- VALUE rb_node_dstr_string_val(const NODE *);
56
- VALUE rb_node_regx_string_val(const NODE *);
57
- VALUE rb_node_dregx_string_val(const NODE *);
58
- VALUE rb_node_line_lineno_val(const NODE *);
59
- VALUE rb_node_file_path_val(const NODE *);
60
- VALUE rb_node_encoding_val(const NODE *);
61
-
62
- VALUE rb_node_integer_literal_val(const NODE *);
63
- VALUE rb_node_float_literal_val(const NODE *);
64
- VALUE rb_node_rational_literal_val(const NODE *);
65
- VALUE rb_node_imaginary_literal_val(const NODE *);
66
- RUBY_SYMBOL_EXPORT_END
67
-
68
- VALUE rb_parser_end_seen_p(VALUE);
69
- VALUE rb_parser_encoding(VALUE);
70
- VALUE rb_parser_set_yydebug(VALUE, VALUE);
71
- VALUE rb_parser_build_script_lines_from(rb_parser_ary_t *script_lines);
72
- void rb_parser_set_options(VALUE, int, int, int, int);
73
- VALUE rb_parser_load_file(VALUE parser, VALUE name);
74
- void rb_parser_set_script_lines(VALUE vparser);
75
- void rb_parser_error_tolerant(VALUE vparser);
76
- void rb_parser_keep_tokens(VALUE vparser);
77
-
78
- VALUE rb_parser_compile_string(VALUE, const char*, VALUE, int);
79
- VALUE rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, int line);
80
- VALUE rb_parser_compile_generic(VALUE vparser, rb_parser_lex_gets_func *lex_gets, VALUE fname, VALUE input, int line);
81
- VALUE rb_parser_compile_array(VALUE vparser, VALUE fname, VALUE array, int start);
82
-
83
- enum lex_state_bits {
84
- EXPR_BEG_bit, /* ignore newline, +/- is a sign. */
85
- EXPR_END_bit, /* newline significant, +/- is an operator. */
86
- EXPR_ENDARG_bit, /* ditto, and unbound braces. */
87
- EXPR_ENDFN_bit, /* ditto, and unbound braces. */
88
- EXPR_ARG_bit, /* newline significant, +/- is an operator. */
89
- EXPR_CMDARG_bit, /* newline significant, +/- is an operator. */
90
- EXPR_MID_bit, /* newline significant, +/- is an operator. */
91
- EXPR_FNAME_bit, /* ignore newline, no reserved words. */
92
- EXPR_DOT_bit, /* right after `.', `&.' or `::', no reserved words. */
93
- EXPR_CLASS_bit, /* immediate after `class', no here document. */
94
- EXPR_LABEL_bit, /* flag bit, label is allowed. */
95
- EXPR_LABELED_bit, /* flag bit, just after a label. */
96
- EXPR_FITEM_bit, /* symbol literal as FNAME. */
97
- EXPR_MAX_STATE
98
- };
99
- /* examine combinations */
100
- enum lex_state_e {
101
- #define DEF_EXPR(n) EXPR_##n = (1 << EXPR_##n##_bit)
102
- DEF_EXPR(BEG),
103
- DEF_EXPR(END),
104
- DEF_EXPR(ENDARG),
105
- DEF_EXPR(ENDFN),
106
- DEF_EXPR(ARG),
107
- DEF_EXPR(CMDARG),
108
- DEF_EXPR(MID),
109
- DEF_EXPR(FNAME),
110
- DEF_EXPR(DOT),
111
- DEF_EXPR(CLASS),
112
- DEF_EXPR(LABEL),
113
- DEF_EXPR(LABELED),
114
- DEF_EXPR(FITEM),
115
- EXPR_VALUE = EXPR_BEG,
116
- EXPR_BEG_ANY = (EXPR_BEG | EXPR_MID | EXPR_CLASS),
117
- EXPR_ARG_ANY = (EXPR_ARG | EXPR_CMDARG),
118
- EXPR_END_ANY = (EXPR_END | EXPR_ENDARG | EXPR_ENDFN),
119
- EXPR_NONE = 0
120
- };
121
-
122
- VALUE rb_ruby_ast_new(const NODE *const root);
123
- rb_ast_t *rb_ruby_ast_data_get(VALUE ast_value);
124
-
125
- #endif /* INTERNAL_RUBY_PARSE_H */