kanayago 0.1.1 → 0.2.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 (77) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +12 -0
  3. data/.ruby-version +1 -0
  4. data/README.md +20 -29
  5. data/Rakefile +43 -96
  6. data/ext/kanayago/extconf.rb +6 -0
  7. data/ext/kanayago/id.h +12 -5
  8. data/ext/kanayago/id_table.h +15 -0
  9. data/ext/kanayago/include/ruby/st.h +199 -0
  10. data/ext/kanayago/internal/array.h +3 -0
  11. data/ext/kanayago/internal/basic_operators.h +1 -0
  12. data/ext/kanayago/internal/bignum.h +1 -0
  13. data/ext/kanayago/internal/bits.h +82 -0
  14. data/ext/kanayago/internal/encoding.h +4 -1
  15. data/ext/kanayago/internal/error.h +33 -0
  16. data/ext/kanayago/internal/fixnum.h +1 -0
  17. data/ext/kanayago/internal/gc.h +47 -11
  18. data/ext/kanayago/internal/hash.h +3 -0
  19. data/ext/kanayago/internal/imemo.h +93 -32
  20. data/ext/kanayago/internal/io.h +30 -7
  21. data/ext/kanayago/internal/namespace.h +81 -0
  22. data/ext/kanayago/internal/numeric.h +1 -0
  23. data/ext/kanayago/internal/parse.h +17 -3
  24. data/ext/kanayago/internal/re.h +7 -2
  25. data/ext/kanayago/internal/sanitizers.h +88 -39
  26. data/ext/kanayago/internal/set_table.h +70 -0
  27. data/ext/kanayago/internal/string.h +33 -16
  28. data/ext/kanayago/internal/symbol.h +4 -3
  29. data/ext/kanayago/internal/thread.h +42 -9
  30. data/ext/kanayago/internal/variable.h +13 -11
  31. data/ext/kanayago/internal/vm.h +4 -5
  32. data/ext/kanayago/internal.h +0 -3
  33. data/ext/kanayago/kanayago.c +554 -235
  34. data/ext/kanayago/kanayago.h +5 -0
  35. data/ext/kanayago/literal_node.c +343 -0
  36. data/ext/kanayago/literal_node.h +30 -0
  37. data/ext/kanayago/method.h +18 -2
  38. data/ext/kanayago/node.c +7 -1
  39. data/ext/kanayago/node.h +14 -3
  40. data/ext/kanayago/parse.c +7602 -7156
  41. data/ext/kanayago/parse.h +39 -39
  42. data/ext/kanayago/parser_st.c +2 -1
  43. data/ext/kanayago/pattern_node.c +78 -0
  44. data/ext/kanayago/pattern_node.h +13 -0
  45. data/ext/kanayago/ruby_atomic.h +43 -0
  46. data/ext/kanayago/ruby_parser.c +7 -35
  47. data/ext/kanayago/rubyparser.h +83 -80
  48. data/ext/kanayago/scope_node.c +34 -0
  49. data/ext/kanayago/scope_node.h +8 -0
  50. data/ext/kanayago/shape.h +321 -111
  51. data/ext/kanayago/st.c +905 -21
  52. data/ext/kanayago/statement_node.c +795 -0
  53. data/ext/kanayago/statement_node.h +66 -0
  54. data/ext/kanayago/string_node.c +192 -0
  55. data/ext/kanayago/string_node.h +19 -0
  56. data/ext/kanayago/symbol.h +2 -9
  57. data/ext/kanayago/thread_pthread.h +10 -3
  58. data/ext/kanayago/universal_parser.c +1 -20
  59. data/ext/kanayago/variable_node.c +72 -0
  60. data/ext/kanayago/variable_node.h +12 -0
  61. data/ext/kanayago/vm_core.h +205 -71
  62. data/lib/kanayago/literal_node.rb +87 -0
  63. data/lib/kanayago/pattern_node.rb +19 -0
  64. data/lib/kanayago/statement_node.rb +222 -0
  65. data/lib/kanayago/string_node.rb +43 -0
  66. data/lib/kanayago/variable_node.rb +23 -0
  67. data/lib/kanayago/version.rb +1 -1
  68. data/lib/kanayago.rb +22 -0
  69. data/patch/3.4/copy_target.rb +78 -0
  70. data/patch/3.4/kanayago.patch +162 -0
  71. data/patch/head/copy_target.rb +84 -0
  72. data/patch/head/kanayago.patch +162 -0
  73. data/sample/minitest_generator.rb +266 -0
  74. data/sample/test_generator.rb +272 -0
  75. data/typeprof.conf.json +9 -0
  76. metadata +32 -4
  77. data/ext/kanayago/parse.tmp.y +0 -16145
@@ -248,6 +248,7 @@ typedef struct RNode_SCOPE {
248
248
 
249
249
  rb_ast_id_table_t *nd_tbl;
250
250
  struct RNode *nd_body;
251
+ struct RNode *nd_parent;
251
252
  struct RNode_ARGS *nd_args;
252
253
  } rb_node_scope_t;
253
254
 
@@ -265,6 +266,9 @@ typedef struct RNode_IF {
265
266
  struct RNode *nd_cond;
266
267
  struct RNode *nd_body;
267
268
  struct RNode *nd_else;
269
+ rb_code_location_t if_keyword_loc;
270
+ rb_code_location_t then_keyword_loc;
271
+ rb_code_location_t end_keyword_loc;
268
272
  } rb_node_if_t;
269
273
 
270
274
  typedef struct RNode_UNLESS {
@@ -283,6 +287,8 @@ typedef struct RNode_CASE {
283
287
 
284
288
  struct RNode *nd_head;
285
289
  struct RNode *nd_body;
290
+ rb_code_location_t case_keyword_loc;
291
+ rb_code_location_t end_keyword_loc;
286
292
  } rb_node_case_t;
287
293
 
288
294
  typedef struct RNode_CASE2 {
@@ -290,6 +296,8 @@ typedef struct RNode_CASE2 {
290
296
 
291
297
  struct RNode *nd_head;
292
298
  struct RNode *nd_body;
299
+ rb_code_location_t case_keyword_loc;
300
+ rb_code_location_t end_keyword_loc;
293
301
  } rb_node_case2_t;
294
302
 
295
303
  typedef struct RNode_CASE3 {
@@ -297,6 +305,8 @@ typedef struct RNode_CASE3 {
297
305
 
298
306
  struct RNode *nd_head;
299
307
  struct RNode *nd_body;
308
+ rb_code_location_t case_keyword_loc;
309
+ rb_code_location_t end_keyword_loc;
300
310
  } rb_node_case3_t;
301
311
 
302
312
  typedef struct RNode_WHEN {
@@ -305,6 +315,8 @@ typedef struct RNode_WHEN {
305
315
  struct RNode *nd_head;
306
316
  struct RNode *nd_body;
307
317
  struct RNode *nd_next;
318
+ rb_code_location_t keyword_loc;
319
+ rb_code_location_t then_keyword_loc;
308
320
  } rb_node_when_t;
309
321
 
310
322
  typedef struct RNode_IN {
@@ -313,26 +325,21 @@ typedef struct RNode_IN {
313
325
  struct RNode *nd_head;
314
326
  struct RNode *nd_body;
315
327
  struct RNode *nd_next;
328
+ rb_code_location_t in_keyword_loc;
329
+ rb_code_location_t then_keyword_loc;
330
+ rb_code_location_t operator_loc;
316
331
  } rb_node_in_t;
317
332
 
318
- /* RNode_WHILE and RNode_UNTIL should be same structure */
319
- typedef struct RNode_WHILE {
320
- NODE node;
321
-
322
- struct RNode *nd_cond;
323
- struct RNode *nd_body;
324
- long nd_state;
325
- } rb_node_while_t;
326
-
327
- typedef struct RNode_UNTIL {
333
+ typedef struct RNode_LOOP {
328
334
  NODE node;
329
335
 
330
336
  struct RNode *nd_cond;
331
337
  struct RNode *nd_body;
332
338
  long nd_state;
333
- } rb_node_until_t;
339
+ rb_code_location_t keyword_loc;
340
+ rb_code_location_t closing_loc;
341
+ } rb_node_while_t, rb_node_until_t;
334
342
 
335
- /* RNode_ITER and RNode_FOR should be same structure */
336
343
  typedef struct RNode_ITER {
337
344
  NODE node;
338
345
 
@@ -345,6 +352,10 @@ typedef struct RNode_FOR {
345
352
 
346
353
  struct RNode *nd_body;
347
354
  struct RNode *nd_iter;
355
+ rb_code_location_t for_keyword_loc;
356
+ rb_code_location_t in_keyword_loc;
357
+ rb_code_location_t do_keyword_loc;
358
+ rb_code_location_t end_keyword_loc;
348
359
  } rb_node_for_t;
349
360
 
350
361
  typedef struct RNode_FOR_MASGN {
@@ -353,26 +364,13 @@ typedef struct RNode_FOR_MASGN {
353
364
  struct RNode *nd_var;
354
365
  } rb_node_for_masgn_t;
355
366
 
356
- /* RNode_BREAK, RNode_NEXT and RNode_REDO should be same structure */
357
- typedef struct RNode_BREAK {
358
- NODE node;
359
-
360
- struct RNode *nd_chain;
361
- struct RNode *nd_stts;
362
- } rb_node_break_t;
363
-
364
- typedef struct RNode_NEXT {
367
+ typedef struct RNode_EXITS {
365
368
  NODE node;
366
369
 
367
370
  struct RNode *nd_chain;
368
371
  struct RNode *nd_stts;
369
- } rb_node_next_t;
370
-
371
- typedef struct RNode_REDO {
372
- NODE node;
373
-
374
- struct RNode *nd_chain;
375
- } rb_node_redo_t;
372
+ rb_code_location_t keyword_loc;
373
+ } rb_node_exits_t, rb_node_break_t, rb_node_next_t, rb_node_redo_t;
376
374
 
377
375
  typedef struct RNode_RETRY {
378
376
  NODE node;
@@ -408,20 +406,13 @@ typedef struct RNode_ENSURE {
408
406
  struct RNode *nd_ensr;
409
407
  } rb_node_ensure_t;
410
408
 
411
- /* RNode_AND and RNode_OR should be same structure */
412
- typedef struct RNode_AND {
409
+ typedef struct {
413
410
  NODE node;
414
411
 
415
412
  struct RNode *nd_1st;
416
413
  struct RNode *nd_2nd;
417
- } rb_node_and_t;
418
-
419
- typedef struct RNode_OR {
420
- NODE node;
421
-
422
- struct RNode *nd_1st;
423
- struct RNode *nd_2nd;
424
- } rb_node_or_t;
414
+ rb_code_location_t operator_loc;
415
+ } rb_node_and_t, rb_node_or_t;
425
416
 
426
417
  typedef struct RNode_MASGN {
427
418
  NODE node;
@@ -482,6 +473,10 @@ typedef struct RNode_OP_ASGN1 {
482
473
  ID nd_mid;
483
474
  struct RNode *nd_index;
484
475
  struct RNode *nd_rvalue;
476
+ rb_code_location_t call_operator_loc;
477
+ rb_code_location_t opening_loc;
478
+ rb_code_location_t closing_loc;
479
+ rb_code_location_t binary_operator_loc;
485
480
  } rb_node_op_asgn1_t;
486
481
 
487
482
  typedef struct RNode_OP_ASGN2 {
@@ -492,6 +487,9 @@ typedef struct RNode_OP_ASGN2 {
492
487
  ID nd_vid;
493
488
  ID nd_mid;
494
489
  bool nd_aid;
490
+ rb_code_location_t call_operator_loc;
491
+ rb_code_location_t message_loc;
492
+ rb_code_location_t binary_operator_loc;
495
493
  } rb_node_op_asgn2_t;
496
494
 
497
495
  typedef struct RNode_OP_ASGN_AND {
@@ -558,6 +556,9 @@ typedef struct RNode_SUPER {
558
556
  NODE node;
559
557
 
560
558
  struct RNode *nd_args;
559
+ rb_code_location_t keyword_loc;
560
+ rb_code_location_t lparen_loc;
561
+ rb_code_location_t rparen_loc;
561
562
  } rb_node_super_t;
562
563
 
563
564
  typedef struct RNode_ZSUPER {
@@ -600,12 +601,16 @@ typedef struct RNode_RETURN {
600
601
  NODE node;
601
602
 
602
603
  struct RNode *nd_stts;
604
+ rb_code_location_t keyword_loc;
603
605
  } rb_node_return_t;
604
606
 
605
607
  typedef struct RNode_YIELD {
606
608
  NODE node;
607
609
 
608
610
  struct RNode *nd_head;
611
+ rb_code_location_t keyword_loc;
612
+ rb_code_location_t lparen_loc;
613
+ rb_code_location_t rparen_loc;
609
614
  } rb_node_yield_t;
610
615
 
611
616
  typedef struct RNode_LVAR {
@@ -656,14 +661,6 @@ typedef struct RNode_BACK_REF {
656
661
  long nd_nth;
657
662
  } rb_node_back_ref_t;
658
663
 
659
- /* RNode_MATCH and RNode_REGX should be same structure */
660
- typedef struct RNode_MATCH {
661
- NODE node;
662
-
663
- struct rb_parser_string *string;
664
- int options;
665
- } rb_node_match_t;
666
-
667
664
  typedef struct RNode_MATCH2 {
668
665
  NODE node;
669
666
 
@@ -719,14 +716,13 @@ typedef struct RNode_IMAGINARY {
719
716
  enum rb_numeric_type type;
720
717
  } rb_node_imaginary_t;
721
718
 
722
- /* RNode_STR and RNode_XSTR should be same structure */
723
719
  typedef struct RNode_STR {
724
720
  NODE node;
725
721
 
726
722
  struct rb_parser_string *string;
727
723
  } rb_node_str_t;
728
724
 
729
- /* RNode_DSTR, RNode_DXSTR, RNode_DREGX and RNode_DSYM should be same structure */
725
+ /* NODE_DSTR, NODE_DXSTR, NODE_DREGX, NODE_DSYM */
730
726
  typedef struct RNode_DSTR {
731
727
  NODE node;
732
728
 
@@ -747,14 +743,19 @@ typedef struct RNode_EVSTR {
747
743
  NODE node;
748
744
 
749
745
  struct RNode *nd_body;
746
+ rb_code_location_t opening_loc;
747
+ rb_code_location_t closing_loc;
750
748
  } rb_node_evstr_t;
751
749
 
752
- typedef struct RNode_REGX {
750
+ typedef struct RNode_REGX { /* also RNode_MATCH */
753
751
  NODE node;
754
752
 
755
753
  struct rb_parser_string *string;
756
754
  int options;
757
- } rb_node_regx_t;
755
+ rb_code_location_t opening_loc;
756
+ rb_code_location_t content_loc;
757
+ rb_code_location_t closing_loc;
758
+ } rb_node_regx_t, rb_node_match_t;
758
759
 
759
760
  typedef rb_node_dstr_t rb_node_dregx_t;
760
761
 
@@ -838,6 +839,7 @@ typedef struct RNode_SPLAT {
838
839
  NODE node;
839
840
 
840
841
  struct RNode *nd_head;
842
+ rb_code_location_t operator_loc;
841
843
  } rb_node_splat_t;
842
844
 
843
845
  typedef struct RNode_BLOCK_PASS {
@@ -846,6 +848,7 @@ typedef struct RNode_BLOCK_PASS {
846
848
  struct RNode *nd_head;
847
849
  struct RNode *nd_body;
848
850
  unsigned int forwarding: 1;
851
+ rb_code_location_t operator_loc;
849
852
  } rb_node_block_pass_t;
850
853
 
851
854
  typedef struct RNode_DEFN {
@@ -868,6 +871,7 @@ typedef struct RNode_ALIAS {
868
871
 
869
872
  struct RNode *nd_1st;
870
873
  struct RNode *nd_2nd;
874
+ rb_code_location_t keyword_loc;
871
875
  } rb_node_alias_t;
872
876
 
873
877
  typedef struct RNode_VALIAS {
@@ -875,12 +879,14 @@ typedef struct RNode_VALIAS {
875
879
 
876
880
  ID nd_alias;
877
881
  ID nd_orig;
882
+ rb_code_location_t keyword_loc;
878
883
  } rb_node_valias_t;
879
884
 
880
885
  typedef struct RNode_UNDEF {
881
886
  NODE node;
882
887
 
883
888
  rb_parser_ary_t *nd_undefs;
889
+ rb_code_location_t keyword_loc;
884
890
  } rb_node_undef_t;
885
891
 
886
892
  typedef struct RNode_CLASS {
@@ -889,6 +895,9 @@ typedef struct RNode_CLASS {
889
895
  struct RNode *nd_cpath;
890
896
  struct RNode *nd_body;
891
897
  struct RNode *nd_super;
898
+ rb_code_location_t class_keyword_loc;
899
+ rb_code_location_t inheritance_operator_loc;
900
+ rb_code_location_t end_keyword_loc;
892
901
  } rb_node_class_t;
893
902
 
894
903
  typedef struct RNode_MODULE {
@@ -896,6 +905,8 @@ typedef struct RNode_MODULE {
896
905
 
897
906
  struct RNode *nd_cpath;
898
907
  struct RNode *nd_body;
908
+ rb_code_location_t module_keyword_loc;
909
+ rb_code_location_t end_keyword_loc;
899
910
  } rb_node_module_t;
900
911
 
901
912
  typedef struct RNode_SCLASS {
@@ -903,6 +914,9 @@ typedef struct RNode_SCLASS {
903
914
 
904
915
  struct RNode *nd_recv;
905
916
  struct RNode *nd_body;
917
+ rb_code_location_t class_keyword_loc;
918
+ rb_code_location_t operator_loc;
919
+ rb_code_location_t end_keyword_loc;
906
920
  } rb_node_sclass_t;
907
921
 
908
922
  typedef struct RNode_COLON2 {
@@ -910,31 +924,26 @@ typedef struct RNode_COLON2 {
910
924
 
911
925
  struct RNode *nd_head;
912
926
  ID nd_mid;
927
+ rb_code_location_t delimiter_loc;
928
+ rb_code_location_t name_loc;
913
929
  } rb_node_colon2_t;
914
930
 
915
931
  typedef struct RNode_COLON3 {
916
932
  NODE node;
917
933
 
918
934
  ID nd_mid;
935
+ rb_code_location_t delimiter_loc;
936
+ rb_code_location_t name_loc;
919
937
  } rb_node_colon3_t;
920
938
 
921
- /* RNode_DOT2, RNode_DOT3, RNode_FLIP2 and RNode_FLIP3 should be same structure */
922
- typedef struct RNode_DOT2 {
939
+ /* NODE_DOT2, NODE_DOT3, NODE_FLIP2, NODE_FLIP3 */
940
+ typedef struct RNode_DOTS {
923
941
  NODE node;
924
942
 
925
943
  struct RNode *nd_beg;
926
944
  struct RNode *nd_end;
927
- } rb_node_dot2_t;
928
-
929
- typedef struct RNode_DOT3 {
930
- NODE node;
931
-
932
- struct RNode *nd_beg;
933
- struct RNode *nd_end;
934
- } rb_node_dot3_t;
935
-
936
- typedef rb_node_dot2_t rb_node_flip2_t;
937
- typedef rb_node_dot3_t rb_node_flip3_t;
945
+ rb_code_location_t operator_loc;
946
+ } rb_node_dot2_t, rb_node_dot3_t, rb_node_flip2_t, rb_node_flip3_t;
938
947
 
939
948
  typedef struct RNode_SELF {
940
949
  NODE node;
@@ -962,12 +971,16 @@ typedef struct RNode_DEFINED {
962
971
  NODE node;
963
972
 
964
973
  struct RNode *nd_head;
974
+ rb_code_location_t keyword_loc;
965
975
  } rb_node_defined_t;
966
976
 
967
977
  typedef struct RNode_POSTEXE {
968
978
  NODE node;
969
979
 
970
980
  struct RNode *nd_body;
981
+ rb_code_location_t keyword_loc;
982
+ rb_code_location_t opening_loc;
983
+ rb_code_location_t closing_loc;
971
984
  } rb_node_postexe_t;
972
985
 
973
986
  typedef struct RNode_SYM {
@@ -990,6 +1003,9 @@ typedef struct RNode_LAMBDA {
990
1003
  NODE node;
991
1004
 
992
1005
  struct RNode *nd_body;
1006
+ rb_code_location_t operator_loc;
1007
+ rb_code_location_t opening_loc;
1008
+ rb_code_location_t closing_loc;
993
1009
  } rb_node_lambda_t;
994
1010
 
995
1011
  typedef struct RNode_ARYPTN {
@@ -1151,7 +1167,7 @@ typedef struct RNode_ERROR {
1151
1167
  #define RNODE_FILE(node) ((rb_node_file_t *)(node))
1152
1168
  #define RNODE_ENCODING(node) ((rb_node_encoding_t *)(node))
1153
1169
 
1154
- /* FL : 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: FINALIZE, 8: UNUSED, 9: UNUSED, 10: EXIVAR, 11: FREEZE */
1170
+ /* FL : 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: FINALIZE, 8..10: UNUSED, 11: FREEZE */
1155
1171
  /* NODE_FL: 0..4: UNUSED, 5: UNUSED, 6: UNUSED, 7: NODE_FL_NEWLINE,
1156
1172
  * 8..14: nd_type,
1157
1173
  * 15..: nd_line
@@ -1204,6 +1220,8 @@ typedef struct parser_params rb_parser_t;
1204
1220
  typedef struct rb_imemo_tmpbuf_struct rb_imemo_tmpbuf_t;
1205
1221
  #endif
1206
1222
 
1223
+ typedef NODE *(*rb_parser_assignable_func)(struct parser_params *p, ID id, NODE *val, const rb_code_location_t *loc);
1224
+
1207
1225
  #ifdef UNIVERSAL_PARSER
1208
1226
  typedef struct rb_parser_config_struct {
1209
1227
  /* Memory */
@@ -1221,14 +1239,12 @@ typedef struct rb_parser_config_struct {
1221
1239
 
1222
1240
  // VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
1223
1241
  VALUE (*compile_callback)(VALUE (*func)(VALUE), VALUE arg);
1224
- NODE *(*reg_named_capture_assign)(struct parser_params* p, VALUE regexp, const rb_code_location_t *loc);
1242
+ NODE *(*reg_named_capture_assign)(struct parser_params* p, VALUE regexp, const rb_code_location_t *loc, rb_parser_assignable_func assignable);
1225
1243
 
1226
1244
  /* Variable */
1227
1245
  VALUE (*attr_get)(VALUE obj, ID id);
1228
1246
 
1229
1247
  /* Array */
1230
- VALUE (*ary_new)(void);
1231
- VALUE (*ary_push)(VALUE ary, VALUE elem);
1232
1248
  VALUE (*ary_new_from_args)(long n, ...);
1233
1249
  VALUE (*ary_unshift)(VALUE ary, VALUE item);
1234
1250
 
@@ -1248,29 +1264,22 @@ typedef struct rb_parser_config_struct {
1248
1264
  const char *(*id2name)(ID id);
1249
1265
  VALUE (*id2str)(ID id);
1250
1266
  VALUE (*id2sym)(ID x);
1251
- ID (*sym2id)(VALUE sym);
1252
1267
 
1253
1268
  /* String */
1254
1269
  RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
1255
1270
  VALUE (*str_catf)(VALUE str, const char *format, ...);
1256
1271
  VALUE (*str_cat_cstr)(VALUE str, const char *ptr);
1257
- void (*str_modify)(VALUE str);
1258
- void (*str_set_len)(VALUE str, long len);
1259
- VALUE (*str_cat)(VALUE str, const char *ptr, long len);
1260
1272
  VALUE (*str_resize)(VALUE str, long len);
1261
1273
  VALUE (*str_new)(const char *ptr, long len);
1262
1274
  VALUE (*str_new_cstr)(const char *ptr);
1263
1275
  VALUE (*str_to_interned_str)(VALUE);
1264
- int (*is_ascii_string)(VALUE str);
1265
1276
  VALUE (*enc_str_new)(const char *ptr, long len, rb_encoding *enc);
1266
1277
  RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 0)
1267
1278
  VALUE (*str_vcatf)(VALUE str, const char *fmt, va_list ap);
1268
1279
  RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
1269
1280
  VALUE (*rb_sprintf)(const char *format, ...);
1270
1281
  char *(*rstring_ptr)(VALUE str);
1271
- char *(*rstring_end)(VALUE str);
1272
1282
  long (*rstring_len)(VALUE str);
1273
- VALUE (*obj_as_string)(VALUE);
1274
1283
 
1275
1284
  /* Numeric */
1276
1285
  VALUE (*int2num)(int v);
@@ -1297,14 +1306,12 @@ typedef struct rb_parser_config_struct {
1297
1306
  rb_encoding* (*enc_get)(VALUE obj);
1298
1307
  int (*enc_asciicompat)(rb_encoding *enc);
1299
1308
  rb_encoding *(*utf8_encoding)(void);
1300
- VALUE (*enc_associate)(VALUE obj, rb_encoding *enc);
1301
1309
  rb_encoding *(*ascii8bit_encoding)(void);
1302
1310
  int (*enc_codelen)(int c, rb_encoding *enc);
1303
1311
  int (*enc_mbcput)(unsigned int c, void *buf, rb_encoding *enc);
1304
1312
  int (*enc_find_index)(const char *name);
1305
1313
  rb_encoding *(*enc_from_index)(int idx);
1306
1314
  int (*enc_isspace)(OnigCodePoint c, rb_encoding *enc);
1307
- rb_encoding *(*usascii_encoding)(void);
1308
1315
  int (*enc_mbminlen)(rb_encoding *enc);
1309
1316
  bool (*enc_isascii)(OnigCodePoint c, rb_encoding *enc);
1310
1317
  OnigCodePoint (*enc_mbc_to_codepoint)(const char *p, const char *e, rb_encoding *enc);
@@ -1325,7 +1332,6 @@ typedef struct rb_parser_config_struct {
1325
1332
  /* Eval */
1326
1333
  VALUE (*errinfo)(void);
1327
1334
  void (*set_errinfo)(VALUE err);
1328
- void (*exc_raise)(VALUE mesg);
1329
1335
  VALUE (*make_exception)(int argc, const VALUE *argv);
1330
1336
 
1331
1337
  /* GC */
@@ -1383,9 +1389,6 @@ rb_parser_t *rb_ruby_parser_allocate(const rb_parser_config_t *config);
1383
1389
  rb_parser_t *rb_ruby_parser_new(const rb_parser_config_t *config);
1384
1390
  #endif
1385
1391
 
1386
- long rb_parser_string_length(rb_parser_string_t *str);
1387
- char *rb_parser_string_pointer(rb_parser_string_t *str);
1388
-
1389
1392
  RUBY_SYMBOL_EXPORT_END
1390
1393
 
1391
1394
  #endif /* RUBY_RUBYPARSER_H */
@@ -0,0 +1,34 @@
1
+ #include "kanayago.h"
2
+
3
+ VALUE rb_cScopeNode;
4
+
5
+ VALUE
6
+ scope_node_new(const NODE *node)
7
+ {
8
+ VALUE result = rb_class_new_instance(0, 0, rb_cScopeNode);
9
+
10
+ rb_ivar_set(result, symbol("args"), ast_to_node_instance((const NODE *)(RNODE_SCOPE(node)->nd_args)));
11
+ rb_ivar_set(result, symbol("body"), ast_to_node_instance(RNODE_SCOPE(node)->nd_body));
12
+
13
+ return result;
14
+ }
15
+
16
+ static VALUE
17
+ scope_node_args_get(VALUE self)
18
+ {
19
+ return rb_ivar_get(self, symbol("args"));
20
+ }
21
+
22
+ static VALUE
23
+ scope_node_body_get(VALUE self)
24
+ {
25
+ return rb_ivar_get(self, symbol("body"));
26
+ }
27
+
28
+ void
29
+ Init_ScopeNode(VALUE module)
30
+ {
31
+ rb_cScopeNode = rb_define_class_under(module, "ScopeNode", rb_cObject);
32
+ rb_define_method(rb_cScopeNode, "args", scope_node_args_get, 0);
33
+ rb_define_method(rb_cScopeNode, "body", scope_node_body_get, 0);
34
+ }
@@ -0,0 +1,8 @@
1
+ #ifndef KANAYAGO_SCOPE_NODE_H
2
+ #define KANAYAGO_SCOPE_NODE_H
3
+
4
+ VALUE scope_node_new(const NODE *);
5
+ void Init_ScopeNode(VALUE);
6
+
7
+ #endif
8
+