myco 0.1.0.dev → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +7 -7
  2. data/LICENSE +1 -1
  3. data/README.md +79 -0
  4. data/lib/myco/backtrace.rb +1 -1
  5. data/lib/myco/bootstrap/component.rb +78 -39
  6. data/lib/myco/bootstrap/find_constant.rb +12 -1
  7. data/lib/myco/bootstrap/instance.rb +5 -12
  8. data/lib/myco/bootstrap/meme.rb +176 -28
  9. data/lib/myco/bootstrap.my +8 -7
  10. data/lib/myco/code_loader.rb +332 -0
  11. data/lib/myco/command/inoculate.my +83 -0
  12. data/lib/myco/command.my +26 -26
  13. data/lib/myco/core/BasicDecorators.my +62 -0
  14. data/lib/myco/core/BasicObject.my +12 -34
  15. data/lib/myco/core/Decorator.my +1 -0
  16. data/lib/myco/core/FileToplevel.my +0 -3
  17. data/lib/myco/core/Myco.my +4 -0
  18. data/lib/myco/core/Object.my +6 -4
  19. data/lib/myco/eval.rb +17 -18
  20. data/lib/myco/misc.rb +16 -0
  21. data/lib/myco/parser/ast/argument_assembly.rb +76 -0
  22. data/lib/myco/parser/ast/array_assembly.rb +57 -0
  23. data/lib/myco/parser/ast/branch_operator.rb +73 -0
  24. data/lib/myco/parser/ast/constant_access.rb +4 -18
  25. data/lib/myco/parser/ast/constant_define.rb +3 -3
  26. data/lib/myco/parser/ast/constant_reopen.rb +12 -13
  27. data/lib/myco/parser/ast/declare_category.rb +8 -6
  28. data/lib/myco/parser/ast/declare_decorator.rb +4 -4
  29. data/lib/myco/parser/ast/declare_file.rb +4 -4
  30. data/lib/myco/parser/ast/declare_meme.rb +53 -11
  31. data/lib/myco/parser/ast/declare_object.rb +9 -7
  32. data/lib/myco/parser/ast/declare_string.rb +5 -5
  33. data/lib/myco/parser/ast/invoke.rb +18 -36
  34. data/lib/myco/parser/ast/invoke_method.rb +28 -0
  35. data/lib/myco/parser/ast/local_variable_access_ambiguous.rb +9 -13
  36. data/lib/myco/parser/ast/misc.rb +128 -33
  37. data/lib/myco/parser/ast/myco_module_scope.rb +26 -0
  38. data/lib/myco/parser/ast/quest.rb +3 -3
  39. data/lib/myco/parser/ast/to_ruby/array_assembly.rb +15 -0
  40. data/lib/myco/parser/ast/to_ruby/block.rb +14 -0
  41. data/lib/myco/parser/ast/to_ruby/block_pass.rb +6 -0
  42. data/lib/myco/parser/ast/to_ruby/branch_operator.rb +9 -0
  43. data/lib/myco/parser/ast/to_ruby/constant_access.rb +10 -0
  44. data/lib/myco/parser/ast/to_ruby/constant_assignment.rb +6 -0
  45. data/lib/myco/parser/ast/to_ruby/constant_define.rb +9 -0
  46. data/lib/myco/parser/ast/to_ruby/constant_reopen.rb +6 -0
  47. data/lib/myco/parser/ast/to_ruby/declare_category.rb +7 -0
  48. data/lib/myco/parser/ast/to_ruby/declare_decorator.rb +6 -0
  49. data/lib/myco/parser/ast/to_ruby/declare_file.rb +6 -0
  50. data/lib/myco/parser/ast/to_ruby/declare_meme.rb +16 -0
  51. data/lib/myco/parser/ast/to_ruby/declare_object.rb +8 -0
  52. data/lib/myco/parser/ast/to_ruby/declare_string.rb +6 -0
  53. data/lib/myco/parser/ast/to_ruby/dynamic_string.rb +14 -0
  54. data/lib/myco/parser/ast/to_ruby/dynamic_symbol.rb +7 -0
  55. data/lib/myco/parser/ast/to_ruby/eval_expression.rb +6 -0
  56. data/lib/myco/parser/ast/to_ruby/false_literal.rb +6 -0
  57. data/lib/myco/parser/ast/to_ruby/hash_literal.rb +16 -0
  58. data/lib/myco/parser/ast/to_ruby/invoke.rb +6 -0
  59. data/lib/myco/parser/ast/to_ruby/invoke_method.rb +35 -0
  60. data/lib/myco/parser/ast/to_ruby/iter.rb +10 -0
  61. data/lib/myco/parser/ast/to_ruby/local_variable_access_ambiguous.rb +16 -0
  62. data/lib/myco/parser/ast/to_ruby/local_variable_assignment.rb +8 -0
  63. data/lib/myco/parser/ast/to_ruby/myco_module_scope.rb +8 -0
  64. data/lib/myco/parser/ast/to_ruby/null_literal.rb +6 -0
  65. data/lib/myco/parser/ast/to_ruby/parameters.rb +60 -0
  66. data/lib/myco/parser/ast/to_ruby/quest.rb +13 -0
  67. data/lib/myco/parser/ast/to_ruby/return.rb +7 -0
  68. data/lib/myco/parser/ast/to_ruby/scoped_constant.rb +11 -0
  69. data/lib/myco/parser/ast/to_ruby/self.rb +6 -0
  70. data/lib/myco/parser/ast/to_ruby/splat_value.rb +33 -0
  71. data/lib/myco/parser/ast/to_ruby/string_literal.rb +6 -0
  72. data/lib/myco/parser/ast/to_ruby/symbol_literal.rb +6 -0
  73. data/lib/myco/parser/ast/to_ruby/toplevel_constant.rb +11 -0
  74. data/lib/myco/parser/ast/to_ruby/true_literal.rb +6 -0
  75. data/lib/myco/parser/ast/to_ruby/void_literal.rb +6 -0
  76. data/lib/myco/parser/ast/to_ruby.rb +138 -0
  77. data/lib/myco/parser/ast.rb +6 -0
  78. data/lib/myco/parser/peg_parser.rb +361 -181
  79. data/lib/myco/parser.rb +27 -11
  80. data/lib/myco/tools/BasicCommand.my +42 -0
  81. data/lib/myco/tools/Generator.my +18 -0
  82. data/lib/myco/toolset.rb +0 -3
  83. data/lib/myco/version.rb +1 -4
  84. data/lib/myco.rb +2 -0
  85. metadata +230 -160
  86. data/lib/myco/parser/builder.output +0 -3995
  87. data/lib/myco/parser/builder.racc +0 -585
  88. data/lib/myco/parser/builder.rb +0 -1592
  89. data/lib/myco/parser/lexer.rb +0 -2306
  90. data/lib/myco/parser/lexer.rl +0 -393
  91. data/lib/myco/parser/lexer_char_classes.rl +0 -56
  92. data/lib/myco/parser/lexer_common.rb +0 -95
  93. data/lib/myco/parser/lexer_skeleton.rl +0 -154
  94. data/lib/myco/parser/peg_parser.kpeg +0 -759
  95. data/lib/myco/tools/OptionParser.my +0 -38
@@ -356,12 +356,12 @@ class CodeTools::PegParser
356
356
  # :startdoc:
357
357
 
358
358
  #%
359
- attr_accessor :processor
359
+ attr_accessor :builder
360
360
  attr_accessor :root_node
361
361
 
362
- # Generate an AST::Node of the given type (generated by the @processor)
362
+ # Generate an AST::Node of the given type (generated by the @builder)
363
363
  def node type, locator, *args
364
- @processor.send :"process_#{type}", locator.line, *args
364
+ @builder.__send__ type, locator, *args
365
365
  end
366
366
 
367
367
  # Generate a Token with the given type, text, and row_col
@@ -402,7 +402,25 @@ class CodeTools::PegParser
402
402
  # TODO: rigorously test and refine
403
403
  #
404
404
  def encode_escapes str
405
- str.gsub /\\(.)/ do "#{$1}" end
405
+ str.gsub /\\(.)/ do
406
+ case $1
407
+ when "a"; "\a" # \a 0x07 Bell or alert
408
+ when "b"; "\b" # \b 0x08 Backspace
409
+ # TODO: # \cx Control-x
410
+ # TODO: # \C-x Control-x
411
+ when "e"; "\e" # \e 0x1b Escape
412
+ when "f"; "\f" # \f 0x0c Formfeed
413
+ # TODO: # \M-\C-x Meta-Control-x
414
+ when "n"; "\n" # \n 0x0a Newline
415
+ # TODO: # \nnn Octal notation, where n is a digit
416
+ when "r"; "\r" # \r 0x0d Carriage return
417
+ when "s"; "\s" # \s 0x20 Space
418
+ when "t"; "\t" # \t 0x09 Tab
419
+ when "v"; "\v" # \v 0x0b Vertical tab
420
+ # TODO: # \xnn Hexadecimal notation, where n is a digit
421
+ else; "#{$1}"
422
+ end
423
+ end
406
424
  end
407
425
 
408
426
  # Given a node,op list ([node, op, node, op, ... node]) and operator types,
@@ -424,7 +442,7 @@ class CodeTools::PegParser
424
442
 
425
443
  result = block_given? ?
426
444
  yield(n0,op,n1) :
427
- node(:call, op, n0, op.sym, node(:array, n1, [n1]))
445
+ node(:invoke, op, n0, op.sym, node(:argass, n1, [n1]))
428
446
  input.unshift result
429
447
  else
430
448
  output.push n0
@@ -437,44 +455,6 @@ class CodeTools::PegParser
437
455
 
438
456
  input.replace output
439
457
  end
440
-
441
- # Given a locator and an node(:array), refactor the splat-related nodes
442
- # in a copy of the original node body and return a replacement for the node.
443
- #
444
- def args_assemble loc, orig_node
445
- list = orig_node.body.dup
446
- tmp = []
447
-
448
- special_type_check = Proc.new { |x|
449
- case x
450
- when Myco::ToolSet::AST::SplatValue; :splat
451
- when Myco::ToolSet::AST::ConcatArgs; :argscat
452
- when Myco::ToolSet::AST::PushArgs; :argspush
453
- when Myco::ToolSet::AST::BlockPass; :block_pass
454
- else; nil
455
- end
456
- }
457
-
458
- # Get the original value in the new_node
459
- tmp << list.shift until list.empty? or special_type_check.call(list.first)
460
- new_node = tmp.empty? ? list.shift : node(:array, loc, tmp)
461
-
462
- # Continue to reduce until all elements have been used
463
- until list.empty?
464
- arg = list.shift
465
- type = special_type_check.call(arg)
466
- if type == :block_pass
467
- new_node = arg.tap { |n| n.arguments = new_node }
468
- elsif type != nil
469
- new_node = node(:argscat, loc, new_node, arg)
470
- else
471
- new_node = node(:argspush, loc, new_node, arg)
472
- end
473
- end
474
-
475
- new_node || orig_node
476
- end
477
-
478
458
 
479
459
 
480
460
  # :stopdoc:
@@ -1718,7 +1698,7 @@ class CodeTools::PegParser
1718
1698
  return _tmp
1719
1699
  end
1720
1700
 
1721
- # t_FLOAT = < c_num+ "." c_num+ > {token(:t_FLOAT, text)}
1701
+ # t_FLOAT = < "-"? c_num+ "." c_num+ > {token(:t_FLOAT, text)}
1722
1702
  def _t_FLOAT
1723
1703
 
1724
1704
  _save = self.pos
@@ -1728,6 +1708,16 @@ class CodeTools::PegParser
1728
1708
  _save1 = self.pos
1729
1709
  while true # sequence
1730
1710
  _save2 = self.pos
1711
+ _tmp = match_string("-")
1712
+ unless _tmp
1713
+ _tmp = true
1714
+ self.pos = _save2
1715
+ end
1716
+ unless _tmp
1717
+ self.pos = _save1
1718
+ break
1719
+ end
1720
+ _save3 = self.pos
1731
1721
  _tmp = apply(:_c_num)
1732
1722
  if _tmp
1733
1723
  while true
@@ -1736,7 +1726,7 @@ class CodeTools::PegParser
1736
1726
  end
1737
1727
  _tmp = true
1738
1728
  else
1739
- self.pos = _save2
1729
+ self.pos = _save3
1740
1730
  end
1741
1731
  unless _tmp
1742
1732
  self.pos = _save1
@@ -1747,7 +1737,7 @@ class CodeTools::PegParser
1747
1737
  self.pos = _save1
1748
1738
  break
1749
1739
  end
1750
- _save3 = self.pos
1740
+ _save4 = self.pos
1751
1741
  _tmp = apply(:_c_num)
1752
1742
  if _tmp
1753
1743
  while true
@@ -1756,7 +1746,7 @@ class CodeTools::PegParser
1756
1746
  end
1757
1747
  _tmp = true
1758
1748
  else
1759
- self.pos = _save3
1749
+ self.pos = _save4
1760
1750
  end
1761
1751
  unless _tmp
1762
1752
  self.pos = _save1
@@ -1783,23 +1773,42 @@ class CodeTools::PegParser
1783
1773
  return _tmp
1784
1774
  end
1785
1775
 
1786
- # t_INTEGER = < c_num+ > {token(:t_INTEGER, text)}
1776
+ # t_INTEGER = < "-"? c_num+ > {token(:t_INTEGER, text)}
1787
1777
  def _t_INTEGER
1788
1778
 
1789
1779
  _save = self.pos
1790
1780
  while true # sequence
1791
1781
  _text_start = self.pos
1782
+
1792
1783
  _save1 = self.pos
1793
- _tmp = apply(:_c_num)
1794
- if _tmp
1795
- while true
1796
- _tmp = apply(:_c_num)
1797
- break unless _tmp
1784
+ while true # sequence
1785
+ _save2 = self.pos
1786
+ _tmp = match_string("-")
1787
+ unless _tmp
1788
+ _tmp = true
1789
+ self.pos = _save2
1798
1790
  end
1799
- _tmp = true
1800
- else
1801
- self.pos = _save1
1802
- end
1791
+ unless _tmp
1792
+ self.pos = _save1
1793
+ break
1794
+ end
1795
+ _save3 = self.pos
1796
+ _tmp = apply(:_c_num)
1797
+ if _tmp
1798
+ while true
1799
+ _tmp = apply(:_c_num)
1800
+ break unless _tmp
1801
+ end
1802
+ _tmp = true
1803
+ else
1804
+ self.pos = _save3
1805
+ end
1806
+ unless _tmp
1807
+ self.pos = _save1
1808
+ end
1809
+ break
1810
+ end # end sequence
1811
+
1803
1812
  if _tmp
1804
1813
  text = get_text(_text_start)
1805
1814
  end
@@ -2232,6 +2241,84 @@ class CodeTools::PegParser
2232
2241
  return _tmp
2233
2242
  end
2234
2243
 
2244
+ # t_OP_AND_Q = < "&?" > {token(:t_OP_AND_Q, text)}
2245
+ def _t_OP_AND_Q
2246
+
2247
+ _save = self.pos
2248
+ while true # sequence
2249
+ _text_start = self.pos
2250
+ _tmp = match_string("&?")
2251
+ if _tmp
2252
+ text = get_text(_text_start)
2253
+ end
2254
+ unless _tmp
2255
+ self.pos = _save
2256
+ break
2257
+ end
2258
+ @result = begin; token(:t_OP_AND_Q, text); end
2259
+ _tmp = true
2260
+ unless _tmp
2261
+ self.pos = _save
2262
+ end
2263
+ break
2264
+ end # end sequence
2265
+
2266
+ set_failed_rule :_t_OP_AND_Q unless _tmp
2267
+ return _tmp
2268
+ end
2269
+
2270
+ # t_OP_OR_Q = < "|?" > {token(:t_OP_OR_Q, text)}
2271
+ def _t_OP_OR_Q
2272
+
2273
+ _save = self.pos
2274
+ while true # sequence
2275
+ _text_start = self.pos
2276
+ _tmp = match_string("|?")
2277
+ if _tmp
2278
+ text = get_text(_text_start)
2279
+ end
2280
+ unless _tmp
2281
+ self.pos = _save
2282
+ break
2283
+ end
2284
+ @result = begin; token(:t_OP_OR_Q, text); end
2285
+ _tmp = true
2286
+ unless _tmp
2287
+ self.pos = _save
2288
+ end
2289
+ break
2290
+ end # end sequence
2291
+
2292
+ set_failed_rule :_t_OP_OR_Q unless _tmp
2293
+ return _tmp
2294
+ end
2295
+
2296
+ # t_OP_VOID_Q = < "??" > {token(:t_OP_VOID_Q, text)}
2297
+ def _t_OP_VOID_Q
2298
+
2299
+ _save = self.pos
2300
+ while true # sequence
2301
+ _text_start = self.pos
2302
+ _tmp = match_string("??")
2303
+ if _tmp
2304
+ text = get_text(_text_start)
2305
+ end
2306
+ unless _tmp
2307
+ self.pos = _save
2308
+ break
2309
+ end
2310
+ @result = begin; token(:t_OP_VOID_Q, text); end
2311
+ _tmp = true
2312
+ unless _tmp
2313
+ self.pos = _save
2314
+ end
2315
+ break
2316
+ end # end sequence
2317
+
2318
+ set_failed_rule :_t_OP_VOID_Q unless _tmp
2319
+ return _tmp
2320
+ end
2321
+
2235
2322
  # t_OP_COMPARE = < ("<=>" | "=~" | "==" | "<=" | ">=" | "<" | ">") > {token(:t_OP_COMPARE, text)}
2236
2323
  def _t_OP_COMPARE
2237
2324
 
@@ -3426,7 +3513,7 @@ class CodeTools::PegParser
3426
3513
  return _tmp
3427
3514
  end
3428
3515
 
3429
- # constant_list = constant:n0 (const_sep constant:n)*:nrest {node(:array, n0, [n0, *nrest])}
3516
+ # constant_list = constant:n0 (const_sep constant:n)*:nrest {node(:arrass, n0, [n0, *nrest])}
3430
3517
  def _constant_list
3431
3518
 
3432
3519
  _save = self.pos
@@ -3465,7 +3552,7 @@ class CodeTools::PegParser
3465
3552
  self.pos = _save
3466
3553
  break
3467
3554
  end
3468
- @result = begin; node(:array, n0, [n0, *nrest]); end
3555
+ @result = begin; node(:arrass, n0, [n0, *nrest]); end
3469
3556
  _tmp = true
3470
3557
  unless _tmp
3471
3558
  self.pos = _save
@@ -3673,11 +3760,16 @@ class CodeTools::PegParser
3673
3760
  return _tmp
3674
3761
  end
3675
3762
 
3676
- # category_sepd_exprs = category_expr:n0 (arg_sep category_expr:n)*:nrest { [n0, *nrest] }
3763
+ # category_sepd_exprs = arg_sep category_expr:n0 (arg_sep category_expr:n)*:nrest { [n0, *nrest] }
3677
3764
  def _category_sepd_exprs
3678
3765
 
3679
3766
  _save = self.pos
3680
3767
  while true # sequence
3768
+ _tmp = apply(:_arg_sep)
3769
+ unless _tmp
3770
+ self.pos = _save
3771
+ break
3772
+ end
3681
3773
  _tmp = apply(:_category_expr)
3682
3774
  n0 = @result
3683
3775
  unless _tmp
@@ -3724,7 +3816,7 @@ class CodeTools::PegParser
3724
3816
  return _tmp
3725
3817
  end
3726
3818
 
3727
- # category = category_name:n0 arg_sep category_sepd_exprs?:nlist &(arg_sep_opt (t_CATGRY_BEGIN | t_DECLARE_END)) {node(:category, n0, n0, (nlist ? node(:block, nlist.first, nlist) : node(:null, n0)))}
3819
+ # category = category_name:n0 category_sepd_exprs?:nlist &(arg_sep_opt (t_CATGRY_BEGIN | t_DECLARE_END)) {node(:category, n0, n0, (nlist ? node(:block, nlist.first, nlist) : node(:null, n0)))}
3728
3820
  def _category
3729
3821
 
3730
3822
  _save = self.pos
@@ -3735,11 +3827,6 @@ class CodeTools::PegParser
3735
3827
  self.pos = _save
3736
3828
  break
3737
3829
  end
3738
- _tmp = apply(:_arg_sep)
3739
- unless _tmp
3740
- self.pos = _save
3741
- break
3742
- end
3743
3830
  _save1 = self.pos
3744
3831
  _tmp = apply(:_category_sepd_exprs)
3745
3832
  @result = nil unless _tmp
@@ -4294,7 +4381,7 @@ class CodeTools::PegParser
4294
4381
  return _tmp
4295
4382
  end
4296
4383
 
4297
- # invoke_assignment = invoke_assignment_lhs:lhs c_spc_nl* t_ASSIGN:to c_spc_nl* assign_rhs:rhs { lhs.name = :"#{lhs.name}=" orig_arguments = lhs.arguments && lhs.arguments.body || [] lhs.arguments = node(:array, rhs, [rhs, *orig_arguments]) lhs }
4384
+ # invoke_assignment = invoke_assignment_lhs:lhs c_spc_nl* t_ASSIGN:to c_spc_nl* assign_rhs:rhs { lhs.name = :"#{lhs.name}=" orig_arguments = lhs.arguments && lhs.arguments.body || [] arg_order = lhs.name==:"[]=" ? [*orig_arguments, rhs] : [rhs, *orig_arguments] lhs.arguments = node(:argass, rhs, arg_order) lhs }
4298
4385
  def _invoke_assignment
4299
4386
 
4300
4387
  _save = self.pos
@@ -4338,7 +4425,8 @@ class CodeTools::PegParser
4338
4425
  @result = begin;
4339
4426
  lhs.name = :"#{lhs.name}="
4340
4427
  orig_arguments = lhs.arguments && lhs.arguments.body || []
4341
- lhs.arguments = node(:array, rhs, [rhs, *orig_arguments])
4428
+ arg_order = lhs.name==:"[]=" ? [*orig_arguments, rhs] : [rhs, *orig_arguments]
4429
+ lhs.arguments = node(:argass, rhs, arg_order)
4342
4430
  lhs
4343
4431
  ; end
4344
4432
  _tmp = true
@@ -4415,7 +4503,7 @@ class CodeTools::PegParser
4415
4503
  return _tmp
4416
4504
  end
4417
4505
 
4418
- # invoke = t_IDENTIFIER:tn (c_spc_nl* arg_list:na)?:na (c_spc_nl* invoke_body:n)?:nlist {node(:invoke, tn, nil, tn.sym, na, *nlist)}
4506
+ # invoke = t_IDENTIFIER:tn (c_spc* arg_list:na)?:na (c_spc_nl* invoke_body:n)?:nlist {node(:invoke, tn, nil, tn.sym, na, *nlist)}
4419
4507
  def _invoke
4420
4508
 
4421
4509
  _save = self.pos
@@ -4431,7 +4519,7 @@ class CodeTools::PegParser
4431
4519
  _save2 = self.pos
4432
4520
  while true # sequence
4433
4521
  while true
4434
- _tmp = apply(:_c_spc_nl)
4522
+ _tmp = apply(:_c_spc)
4435
4523
  break unless _tmp
4436
4524
  end
4437
4525
  _tmp = true
@@ -4500,7 +4588,14 @@ class CodeTools::PegParser
4500
4588
  return _tmp
4501
4589
  end
4502
4590
 
4503
- # op_invoke = op_invoke_id:tn (c_spc_nl* arg_list:na)?:na (c_spc_nl* invoke_body:n)?:nlist {node(:invoke, tn, nil, tn.sym, na, *nlist)}
4591
+ # op_invoke_id = left_op_normal
4592
+ def _op_invoke_id
4593
+ _tmp = apply(:_left_op_normal)
4594
+ set_failed_rule :_op_invoke_id unless _tmp
4595
+ return _tmp
4596
+ end
4597
+
4598
+ # op_invoke = op_invoke_id:tn (c_spc* arg_list:na)?:na (c_spc_nl* invoke_body:n)?:nlist {node(:invoke, tn, nil, tn.sym, na, *nlist)}
4504
4599
  def _op_invoke
4505
4600
 
4506
4601
  _save = self.pos
@@ -4516,7 +4611,7 @@ class CodeTools::PegParser
4516
4611
  _save2 = self.pos
4517
4612
  while true # sequence
4518
4613
  while true
4519
- _tmp = apply(:_c_spc_nl)
4614
+ _tmp = apply(:_c_spc)
4520
4615
  break unless _tmp
4521
4616
  end
4522
4617
  _tmp = true
@@ -4585,10 +4680,57 @@ class CodeTools::PegParser
4585
4680
  return _tmp
4586
4681
  end
4587
4682
 
4588
- # op_invoke_id = left_op
4589
- def _op_invoke_id
4590
- _tmp = apply(:_left_op)
4591
- set_failed_rule :_op_invoke_id unless _tmp
4683
+ # elem_invoke = lit_array:na (c_spc_nl* invoke_body:n)?:nlist {node(:invoke, na, nil, :"[]", node(:argass, na, na.body), *nlist)}
4684
+ def _elem_invoke
4685
+
4686
+ _save = self.pos
4687
+ while true # sequence
4688
+ _tmp = apply(:_lit_array)
4689
+ na = @result
4690
+ unless _tmp
4691
+ self.pos = _save
4692
+ break
4693
+ end
4694
+ _save1 = self.pos
4695
+
4696
+ _save2 = self.pos
4697
+ while true # sequence
4698
+ while true
4699
+ _tmp = apply(:_c_spc_nl)
4700
+ break unless _tmp
4701
+ end
4702
+ _tmp = true
4703
+ unless _tmp
4704
+ self.pos = _save2
4705
+ break
4706
+ end
4707
+ _tmp = apply(:_invoke_body)
4708
+ n = @result
4709
+ unless _tmp
4710
+ self.pos = _save2
4711
+ end
4712
+ break
4713
+ end # end sequence
4714
+
4715
+ @result = nil unless _tmp
4716
+ unless _tmp
4717
+ _tmp = true
4718
+ self.pos = _save1
4719
+ end
4720
+ nlist = @result
4721
+ unless _tmp
4722
+ self.pos = _save
4723
+ break
4724
+ end
4725
+ @result = begin; node(:invoke, na, nil, :"[]", node(:argass, na, na.body), *nlist); end
4726
+ _tmp = true
4727
+ unless _tmp
4728
+ self.pos = _save
4729
+ end
4730
+ break
4731
+ end # end sequence
4732
+
4733
+ set_failed_rule :_elem_invoke unless _tmp
4592
4734
  return _tmp
4593
4735
  end
4594
4736
 
@@ -5156,7 +5298,7 @@ class CodeTools::PegParser
5156
5298
  return _tmp
5157
5299
  end
5158
5300
 
5159
- # arg_list = (t_ARGS_BEGIN:tb arg_sep_opt t_ARGS_END {args_assemble(tb, node(:array, tb, []))} | t_ARGS_BEGIN:tb arg_sep_opt in_arg_list:nlist arg_sep_opt t_ARGS_END {args_assemble(tb, node(:array, tb, nlist))})
5301
+ # arg_list = (t_ARGS_BEGIN:tb arg_sep_opt t_ARGS_END {node(:argass, tb, [])} | t_ARGS_BEGIN:tb arg_sep_opt in_arg_list:nlist arg_sep_opt t_ARGS_END {node(:argass, tb, nlist)})
5160
5302
  def _arg_list
5161
5303
 
5162
5304
  _save = self.pos
@@ -5180,7 +5322,7 @@ class CodeTools::PegParser
5180
5322
  self.pos = _save1
5181
5323
  break
5182
5324
  end
5183
- @result = begin; args_assemble(tb, node(:array, tb, [])); end
5325
+ @result = begin; node(:argass, tb, []); end
5184
5326
  _tmp = true
5185
5327
  unless _tmp
5186
5328
  self.pos = _save1
@@ -5220,7 +5362,7 @@ class CodeTools::PegParser
5220
5362
  self.pos = _save2
5221
5363
  break
5222
5364
  end
5223
- @result = begin; args_assemble(tb, node(:array, tb, nlist)); end
5365
+ @result = begin; node(:argass, tb, nlist); end
5224
5366
  _tmp = true
5225
5367
  unless _tmp
5226
5368
  self.pos = _save2
@@ -5237,7 +5379,7 @@ class CodeTools::PegParser
5237
5379
  return _tmp
5238
5380
  end
5239
5381
 
5240
- # lit_array = (t_ARRAY_BEGIN:tb arg_sep_opt t_ARRAY_END {args_assemble(tb, node(:array, tb, []))} | t_ARRAY_BEGIN:tb arg_sep_opt in_arg_list:nlist arg_sep_opt t_ARRAY_END {args_assemble(tb, node(:array, tb, nlist))})
5382
+ # lit_array = (t_ARRAY_BEGIN:tb arg_sep_opt t_ARRAY_END {node(:arrass, tb, [])} | t_ARRAY_BEGIN:tb arg_sep_opt in_arg_list:nlist arg_sep_opt t_ARRAY_END {node(:arrass, tb, nlist)})
5241
5383
  def _lit_array
5242
5384
 
5243
5385
  _save = self.pos
@@ -5261,7 +5403,7 @@ class CodeTools::PegParser
5261
5403
  self.pos = _save1
5262
5404
  break
5263
5405
  end
5264
- @result = begin; args_assemble(tb, node(:array, tb, [])); end
5406
+ @result = begin; node(:arrass, tb, []); end
5265
5407
  _tmp = true
5266
5408
  unless _tmp
5267
5409
  self.pos = _save1
@@ -5301,7 +5443,7 @@ class CodeTools::PegParser
5301
5443
  self.pos = _save2
5302
5444
  break
5303
5445
  end
5304
- @result = begin; args_assemble(tb, node(:array, tb, nlist)); end
5446
+ @result = begin; node(:arrass, tb, nlist); end
5305
5447
  _tmp = true
5306
5448
  unless _tmp
5307
5449
  self.pos = _save2
@@ -5721,8 +5863,8 @@ class CodeTools::PegParser
5721
5863
  return _tmp
5722
5864
  end
5723
5865
 
5724
- # left_op = (t_OP_EXP | t_OP_MULT | t_OP_DIV | t_OP_MOD | t_OP_PLUS | t_OP_MINUS | t_OP_COMPARE | t_OP_AND | t_OP_OR)
5725
- def _left_op
5866
+ # left_op_normal = (t_OP_EXP | t_OP_MULT | t_OP_DIV | t_OP_MOD | t_OP_PLUS | t_OP_MINUS | t_OP_COMPARE)
5867
+ def _left_op_normal
5726
5868
 
5727
5869
  _save = self.pos
5728
5870
  while true # choice
@@ -5747,12 +5889,51 @@ class CodeTools::PegParser
5747
5889
  _tmp = apply(:_t_OP_COMPARE)
5748
5890
  break if _tmp
5749
5891
  self.pos = _save
5892
+ break
5893
+ end # end choice
5894
+
5895
+ set_failed_rule :_left_op_normal unless _tmp
5896
+ return _tmp
5897
+ end
5898
+
5899
+ # left_op_branch = (t_OP_AND | t_OP_OR | t_OP_AND_Q | t_OP_OR_Q | t_OP_VOID_Q)
5900
+ def _left_op_branch
5901
+
5902
+ _save = self.pos
5903
+ while true # choice
5750
5904
  _tmp = apply(:_t_OP_AND)
5751
5905
  break if _tmp
5752
5906
  self.pos = _save
5753
5907
  _tmp = apply(:_t_OP_OR)
5754
5908
  break if _tmp
5755
5909
  self.pos = _save
5910
+ _tmp = apply(:_t_OP_AND_Q)
5911
+ break if _tmp
5912
+ self.pos = _save
5913
+ _tmp = apply(:_t_OP_OR_Q)
5914
+ break if _tmp
5915
+ self.pos = _save
5916
+ _tmp = apply(:_t_OP_VOID_Q)
5917
+ break if _tmp
5918
+ self.pos = _save
5919
+ break
5920
+ end # end choice
5921
+
5922
+ set_failed_rule :_left_op_branch unless _tmp
5923
+ return _tmp
5924
+ end
5925
+
5926
+ # left_op = (left_op_normal | left_op_branch)
5927
+ def _left_op
5928
+
5929
+ _save = self.pos
5930
+ while true # choice
5931
+ _tmp = apply(:_left_op_normal)
5932
+ break if _tmp
5933
+ self.pos = _save
5934
+ _tmp = apply(:_left_op_branch)
5935
+ break if _tmp
5936
+ self.pos = _save
5756
5937
  break
5757
5938
  end # end choice
5758
5939
 
@@ -5760,7 +5941,7 @@ class CodeTools::PegParser
5760
5941
  return _tmp
5761
5942
  end
5762
5943
 
5763
- # left_chained_atoms = expr_atom:n0 (c_spc_nl* left_op:to c_spc_nl* expr_atom:n1 { [to, n1] })+:list { list.unshift n0 list.flatten! collapse(list, :t_OP_EXP) collapse(list, :t_OP_MULT, :t_OP_DIV, :t_OP_MOD) collapse(list, :t_OP_PLUS, :t_OP_MINUS) collapse(list, :t_OP_COMPARE) collapse(list, :t_OP_AND, :t_OP_OR) do |n0,op,n1| type = { :t_OP_AND=>:and, :t_OP_OR=>:or }[op.type] node(type, op, n0, n1) end # There should only be one resulting node left raise "Failed to fully collapse left_chained_atoms: #{list}" \ unless list.count == 1 list.first }
5944
+ # left_chained_atoms = expr_atom:n0 (c_spc_nl* left_op:to c_spc_nl* expr_atom:n1 { [to, n1] })+:list { list.unshift n0 list.flatten! collapse(list, :t_OP_EXP) collapse(list, :t_OP_MULT, :t_OP_DIV, :t_OP_MOD) collapse(list, :t_OP_PLUS, :t_OP_MINUS) collapse(list, :t_OP_COMPARE) collapse(list, :t_OP_AND, :t_OP_OR, :t_OP_AND_Q, :t_OP_OR_Q, :t_OP_VOID_Q) do |n0,op,n1| node(:branch_op, op, op.sym, n0, n1) end # There should only be one resulting node left raise "Failed to fully collapse left_chained_atoms: #{list}" \ unless list.count == 1 list.first }
5764
5945
  def _left_chained_atoms
5765
5946
 
5766
5947
  _save = self.pos
@@ -5879,9 +6060,9 @@ class CodeTools::PegParser
5879
6060
  collapse(list, :t_OP_MULT, :t_OP_DIV, :t_OP_MOD)
5880
6061
  collapse(list, :t_OP_PLUS, :t_OP_MINUS)
5881
6062
  collapse(list, :t_OP_COMPARE)
5882
- collapse(list, :t_OP_AND, :t_OP_OR) do |n0,op,n1|
5883
- type = { :t_OP_AND=>:and, :t_OP_OR=>:or }[op.type]
5884
- node(type, op, n0, n1)
6063
+ collapse(list, :t_OP_AND, :t_OP_OR,
6064
+ :t_OP_AND_Q, :t_OP_OR_Q, :t_OP_VOID_Q) do |n0,op,n1|
6065
+ node(:branch_op, op, op.sym, n0, n1)
5885
6066
  end
5886
6067
 
5887
6068
  # There should only be one resulting node left
@@ -5919,21 +6100,13 @@ class CodeTools::PegParser
5919
6100
  return _tmp
5920
6101
  end
5921
6102
 
5922
- # left_chained_invocations = expr_atom_not_chained:n0 (c_spc_nl* left_invoke_op:to c_spc_nl* (invoke | op_invoke):n1 { [to, n1] })+:list { list.unshift n0 list.flatten! collapse(list, :t_DOT, :t_QUEST) do |n0,op,n1| op.type==:t_DOT ? (n1.receiver=n0; n1) : node(:quest, op, n0, n1) end # There should only be one resulting node left raise "Failed to fully collapse left_chained_invocations: #{list}" \ unless list.count == 1 list.first }
5923
- def _left_chained_invocations
6103
+ # left_chained_invocation = (c_spc_nl* left_invoke_op:to c_spc_nl* (invoke | op_invoke):n1 { [to, n1] } | c_spc* elem_invoke:n1 { [token(:t_DOT, ""), n1] })
6104
+ def _left_chained_invocation
5924
6105
 
5925
6106
  _save = self.pos
5926
- while true # sequence
5927
- _tmp = apply(:_expr_atom_not_chained)
5928
- n0 = @result
5929
- unless _tmp
5930
- self.pos = _save
5931
- break
5932
- end
5933
- _save1 = self.pos
5934
- _ary = []
6107
+ while true # choice
5935
6108
 
5936
- _save2 = self.pos
6109
+ _save1 = self.pos
5937
6110
  while true # sequence
5938
6111
  while true
5939
6112
  _tmp = apply(:_c_spc_nl)
@@ -5941,13 +6114,13 @@ class CodeTools::PegParser
5941
6114
  end
5942
6115
  _tmp = true
5943
6116
  unless _tmp
5944
- self.pos = _save2
6117
+ self.pos = _save1
5945
6118
  break
5946
6119
  end
5947
6120
  _tmp = apply(:_left_invoke_op)
5948
6121
  to = @result
5949
6122
  unless _tmp
5950
- self.pos = _save2
6123
+ self.pos = _save1
5951
6124
  break
5952
6125
  end
5953
6126
  while true
@@ -5956,89 +6129,89 @@ class CodeTools::PegParser
5956
6129
  end
5957
6130
  _tmp = true
5958
6131
  unless _tmp
5959
- self.pos = _save2
6132
+ self.pos = _save1
5960
6133
  break
5961
6134
  end
5962
6135
 
5963
- _save5 = self.pos
6136
+ _save4 = self.pos
5964
6137
  while true # choice
5965
6138
  _tmp = apply(:_invoke)
5966
6139
  break if _tmp
5967
- self.pos = _save5
6140
+ self.pos = _save4
5968
6141
  _tmp = apply(:_op_invoke)
5969
6142
  break if _tmp
5970
- self.pos = _save5
6143
+ self.pos = _save4
5971
6144
  break
5972
6145
  end # end choice
5973
6146
 
5974
6147
  n1 = @result
5975
6148
  unless _tmp
5976
- self.pos = _save2
6149
+ self.pos = _save1
5977
6150
  break
5978
6151
  end
5979
6152
  @result = begin; [to, n1] ; end
5980
6153
  _tmp = true
5981
6154
  unless _tmp
5982
- self.pos = _save2
6155
+ self.pos = _save1
5983
6156
  end
5984
6157
  break
5985
6158
  end # end sequence
5986
6159
 
5987
- if _tmp
5988
- _ary << @result
6160
+ break if _tmp
6161
+ self.pos = _save
6162
+
6163
+ _save5 = self.pos
6164
+ while true # sequence
5989
6165
  while true
6166
+ _tmp = apply(:_c_spc)
6167
+ break unless _tmp
6168
+ end
6169
+ _tmp = true
6170
+ unless _tmp
6171
+ self.pos = _save5
6172
+ break
6173
+ end
6174
+ _tmp = apply(:_elem_invoke)
6175
+ n1 = @result
6176
+ unless _tmp
6177
+ self.pos = _save5
6178
+ break
6179
+ end
6180
+ @result = begin; [token(:t_DOT, ""), n1] ; end
6181
+ _tmp = true
6182
+ unless _tmp
6183
+ self.pos = _save5
6184
+ end
6185
+ break
6186
+ end # end sequence
5990
6187
 
5991
- _save6 = self.pos
5992
- while true # sequence
5993
- while true
5994
- _tmp = apply(:_c_spc_nl)
5995
- break unless _tmp
5996
- end
5997
- _tmp = true
5998
- unless _tmp
5999
- self.pos = _save6
6000
- break
6001
- end
6002
- _tmp = apply(:_left_invoke_op)
6003
- to = @result
6004
- unless _tmp
6005
- self.pos = _save6
6006
- break
6007
- end
6008
- while true
6009
- _tmp = apply(:_c_spc_nl)
6010
- break unless _tmp
6011
- end
6012
- _tmp = true
6013
- unless _tmp
6014
- self.pos = _save6
6015
- break
6016
- end
6188
+ break if _tmp
6189
+ self.pos = _save
6190
+ break
6191
+ end # end choice
6017
6192
 
6018
- _save9 = self.pos
6019
- while true # choice
6020
- _tmp = apply(:_invoke)
6021
- break if _tmp
6022
- self.pos = _save9
6023
- _tmp = apply(:_op_invoke)
6024
- break if _tmp
6025
- self.pos = _save9
6026
- break
6027
- end # end choice
6193
+ set_failed_rule :_left_chained_invocation unless _tmp
6194
+ return _tmp
6195
+ end
6028
6196
 
6029
- n1 = @result
6030
- unless _tmp
6031
- self.pos = _save6
6032
- break
6033
- end
6034
- @result = begin; [to, n1] ; end
6035
- _tmp = true
6036
- unless _tmp
6037
- self.pos = _save6
6038
- end
6039
- break
6040
- end # end sequence
6197
+ # left_chained_invocations = expr_atom_not_chained:n0 left_chained_invocation+:list { list.unshift n0 list.flatten! collapse(list, :t_DOT, :t_QUEST) do |n0,op,n1| op.type==:t_DOT ? (n1.receiver=n0; n1) : node(:quest, op, n0, n1) end # There should only be one resulting node left raise "Failed to fully collapse left_chained_invocations: #{list}" \ unless list.count == 1 list.first }
6198
+ def _left_chained_invocations
6041
6199
 
6200
+ _save = self.pos
6201
+ while true # sequence
6202
+ _tmp = apply(:_expr_atom_not_chained)
6203
+ n0 = @result
6204
+ unless _tmp
6205
+ self.pos = _save
6206
+ break
6207
+ end
6208
+ _save1 = self.pos
6209
+ _ary = []
6210
+ _tmp = apply(:_left_chained_invocation)
6211
+ if _tmp
6212
+ _ary << @result
6213
+ while true
6214
+ _tmp = apply(:_left_chained_invocation)
6042
6215
  _ary << @result if _tmp
6043
6216
  break unless _tmp
6044
6217
  end
@@ -6077,7 +6250,7 @@ class CodeTools::PegParser
6077
6250
  return _tmp
6078
6251
  end
6079
6252
 
6080
- # unary_operation = t_OP_NOT:to expr_atom:n0 {node(:call, to, n0, :"!", nil)}
6253
+ # unary_operation = t_OP_NOT:to expr_atom:n0 {node(:invoke, to, n0, :"!", nil)}
6081
6254
  def _unary_operation
6082
6255
 
6083
6256
  _save = self.pos
@@ -6094,7 +6267,7 @@ class CodeTools::PegParser
6094
6267
  self.pos = _save
6095
6268
  break
6096
6269
  end
6097
- @result = begin; node(:call, to, n0, :"!", nil); end
6270
+ @result = begin; node(:invoke, to, n0, :"!", nil); end
6098
6271
  _tmp = true
6099
6272
  unless _tmp
6100
6273
  self.pos = _save
@@ -6733,7 +6906,7 @@ class CodeTools::PegParser
6733
6906
  return _tmp
6734
6907
  end
6735
6908
 
6736
- # decorator = meme_name:ni arg_list?:na {node(:deco, ni, ni, na)}
6909
+ # decorator = meme_name:ni arg_list?:na {node(:deco, ni, ni, (na ? node(:arrass, na, na.body) : nil))}
6737
6910
  def _decorator
6738
6911
 
6739
6912
  _save = self.pos
@@ -6756,7 +6929,7 @@ class CodeTools::PegParser
6756
6929
  self.pos = _save
6757
6930
  break
6758
6931
  end
6759
- @result = begin; node(:deco, ni, ni, na); end
6932
+ @result = begin; node(:deco, ni, ni, (na ? node(:arrass, na, na.body) : nil)); end
6760
6933
  _tmp = true
6761
6934
  unless _tmp
6762
6935
  self.pos = _save
@@ -6768,7 +6941,7 @@ class CodeTools::PegParser
6768
6941
  return _tmp
6769
6942
  end
6770
6943
 
6771
- # decorators_and_meme_name = decorator:n0 (c_spc* decorator:n)*:nrest {node(:array, n0, [n0, *nrest].reverse)}
6944
+ # decorators_and_meme_name = decorator:n0 (c_spc* decorator:n)*:nrest {node(:arrass, n0, [n0, *nrest].reverse)}
6772
6945
  def _decorators_and_meme_name
6773
6946
 
6774
6947
  _save = self.pos
@@ -6811,7 +6984,7 @@ class CodeTools::PegParser
6811
6984
  self.pos = _save
6812
6985
  break
6813
6986
  end
6814
- @result = begin; node(:array, n0, [n0, *nrest].reverse); end
6987
+ @result = begin; node(:arrass, n0, [n0, *nrest].reverse); end
6815
6988
  _tmp = true
6816
6989
  unless _tmp
6817
6990
  self.pos = _save
@@ -6983,8 +7156,8 @@ class CodeTools::PegParser
6983
7156
  Rules[:_t_TRUE] = rule_info("t_TRUE", "< \"true\" > {token(:t_TRUE, text)}")
6984
7157
  Rules[:_t_FALSE] = rule_info("t_FALSE", "< \"false\" > {token(:t_FALSE, text)}")
6985
7158
  Rules[:_t_SELF] = rule_info("t_SELF", "< \"self\" > {token(:t_SELF, text)}")
6986
- Rules[:_t_FLOAT] = rule_info("t_FLOAT", "< c_num+ \".\" c_num+ > {token(:t_FLOAT, text)}")
6987
- Rules[:_t_INTEGER] = rule_info("t_INTEGER", "< c_num+ > {token(:t_INTEGER, text)}")
7159
+ Rules[:_t_FLOAT] = rule_info("t_FLOAT", "< \"-\"? c_num+ \".\" c_num+ > {token(:t_FLOAT, text)}")
7160
+ Rules[:_t_INTEGER] = rule_info("t_INTEGER", "< \"-\"? c_num+ > {token(:t_INTEGER, text)}")
6988
7161
  Rules[:_t_JUMP] = rule_info("t_JUMP", "< \"->\" > {token(:t_JUMP, text)}")
6989
7162
  Rules[:_t_DOT] = rule_info("t_DOT", "< \".\" > {token(:t_DOT, text)}")
6990
7163
  Rules[:_t_QUEST] = rule_info("t_QUEST", "< \".\" c_spc_nl* \"?\" > {token(:t_QUEST, text)}")
@@ -7000,6 +7173,9 @@ class CodeTools::PegParser
7000
7173
  Rules[:_t_OP_EXP] = rule_info("t_OP_EXP", "< \"**\" > {token(:t_OP_EXP, text)}")
7001
7174
  Rules[:_t_OP_AND] = rule_info("t_OP_AND", "< \"&&\" > {token(:t_OP_AND, text)}")
7002
7175
  Rules[:_t_OP_OR] = rule_info("t_OP_OR", "< \"||\" > {token(:t_OP_OR, text)}")
7176
+ Rules[:_t_OP_AND_Q] = rule_info("t_OP_AND_Q", "< \"&?\" > {token(:t_OP_AND_Q, text)}")
7177
+ Rules[:_t_OP_OR_Q] = rule_info("t_OP_OR_Q", "< \"|?\" > {token(:t_OP_OR_Q, text)}")
7178
+ Rules[:_t_OP_VOID_Q] = rule_info("t_OP_VOID_Q", "< \"??\" > {token(:t_OP_VOID_Q, text)}")
7003
7179
  Rules[:_t_OP_COMPARE] = rule_info("t_OP_COMPARE", "< (\"<=>\" | \"=~\" | \"==\" | \"<=\" | \">=\" | \"<\" | \">\") > {token(:t_OP_COMPARE, text)}")
7004
7180
  Rules[:_string_norm] = rule_info("string_norm", "/[^\\\\\\\"]/")
7005
7181
  Rules[:_t_STRING_BODY] = rule_info("t_STRING_BODY", "< string_norm* (\"\\\\\" c_any string_norm*)* > {token(:t_STRING_BODY, text)}")
@@ -7025,14 +7201,14 @@ class CodeTools::PegParser
7025
7201
  Rules[:_dyn_symstr] = rule_info("dyn_symstr", "lit_symstr:n0 dyn_string_parts:nrest {node(:dsym, n0, n0.value.to_s, nrest)}")
7026
7202
  Rules[:_constant] = rule_info("constant", "(constant:n0 t_SCOPE:ts t_CONSTANT:tc {node(:colon2, ts, n0, tc.sym)} | t_SCOPE:ts t_CONSTANT:tc {node(:colon3, ts, tc.sym)} | t_CONSTANT:tc {node(:const, tc, tc.sym)})")
7027
7203
  Rules[:_const_sep] = rule_info("const_sep", "(c_spc_nl* t_CONST_SEP c_spc_nl*)+")
7028
- Rules[:_constant_list] = rule_info("constant_list", "constant:n0 (const_sep constant:n)*:nrest {node(:array, n0, [n0, *nrest])}")
7204
+ Rules[:_constant_list] = rule_info("constant_list", "constant:n0 (const_sep constant:n)*:nrest {node(:arrass, n0, [n0, *nrest])}")
7029
7205
  Rules[:_id_as_symbol] = rule_info("id_as_symbol", "t_IDENTIFIER:t0 {node(:lit, t0, t0.sym)}")
7030
7206
  Rules[:_declobj_sepd_exprs] = rule_info("declobj_sepd_exprs", "declobj_expr:n0 (arg_sep declobj_expr:n)*:nrest arg_sep_opt { [n0, *nrest] }")
7031
7207
  Rules[:_declobj_expr_body] = rule_info("declobj_expr_body", "(arg_sep_opt declobj_sepd_exprs:nlist t_DECLARE_END:te {node(:block, nlist.first, nlist)} | arg_sep_opt t_DECLARE_END:te {node(:null, te)})")
7032
7208
  Rules[:_declobj] = rule_info("declobj", "constant_list:n0 c_spc_nl* t_DECLARE_BEGIN:t declobj_expr_body:n1 {node(:declobj, t, n0, n1)}")
7033
7209
  Rules[:_category_expr] = rule_info("category_expr", "declobj_expr_not_category")
7034
- Rules[:_category_sepd_exprs] = rule_info("category_sepd_exprs", "category_expr:n0 (arg_sep category_expr:n)*:nrest { [n0, *nrest] }")
7035
- Rules[:_category] = rule_info("category", "category_name:n0 arg_sep category_sepd_exprs?:nlist &(arg_sep_opt (t_CATGRY_BEGIN | t_DECLARE_END)) {node(:category, n0, n0, (nlist ? node(:block, nlist.first, nlist) : node(:null, n0)))}")
7210
+ Rules[:_category_sepd_exprs] = rule_info("category_sepd_exprs", "arg_sep category_expr:n0 (arg_sep category_expr:n)*:nrest { [n0, *nrest] }")
7211
+ Rules[:_category] = rule_info("category", "category_name:n0 category_sepd_exprs?:nlist &(arg_sep_opt (t_CATGRY_BEGIN | t_DECLARE_END)) {node(:category, n0, n0, (nlist ? node(:block, nlist.first, nlist) : node(:null, n0)))}")
7036
7212
  Rules[:_copen] = rule_info("copen", "constant:n0 c_spc_nl* t_REOPEN:tb c_spc_nl* t_DECLARE_BEGIN declobj_expr_body:n1 {node(:copen, tb, n0, n1)}")
7037
7213
  Rules[:_cdefn] = rule_info("cdefn", "constant:n0 c_spc_nl* t_DEFINE:t c_spc_nl* declobj:n1 {node(:cdefn, t, n0, n1)}")
7038
7214
  Rules[:_t_DECLSTR_BEGIN] = rule_info("t_DECLSTR_BEGIN", "< /[^\\s{:,<][^\\s]+/ > { \# Table of replacement characters to use when calculating \# the ending delimiter from the starting delimiter. \# Directional characters are replaced with their opposite. @declstr_replace_tbl ||= %w{ < > ( ) { } [ ] } \# Calculate the ending delimiter to look for and store it @declstr_destrlim = text \\ .split(/(?<=[^a-zA-Z])|(?=[^a-zA-Z])/) .map { |str| idx = @declstr_replace_tbl.find_index(str) idx.nil? ? str : (idx.odd? ? @declstr_replace_tbl[idx-1] : @declstr_replace_tbl[idx+1]) } .reverse .join '' token(:t_DECLSTR_BEGIN, text) }")
@@ -7046,11 +7222,12 @@ class CodeTools::PegParser
7046
7222
  Rules[:_assign_rhs] = rule_info("assign_rhs", "arg_expr")
7047
7223
  Rules[:_local_assignment] = rule_info("local_assignment", "t_IDENTIFIER:ti c_spc_nl* t_ASSIGN:to c_spc_nl* assign_rhs:rhs {node(:lasgn, to, ti.sym, rhs)}")
7048
7224
  Rules[:_invoke_assignment_lhs] = rule_info("invoke_assignment_lhs", "(left_chained_invocations | invoke)")
7049
- Rules[:_invoke_assignment] = rule_info("invoke_assignment", "invoke_assignment_lhs:lhs c_spc_nl* t_ASSIGN:to c_spc_nl* assign_rhs:rhs { lhs.name = :\"\#{lhs.name}=\" orig_arguments = lhs.arguments && lhs.arguments.body || [] lhs.arguments = node(:array, rhs, [rhs, *orig_arguments]) lhs }")
7225
+ Rules[:_invoke_assignment] = rule_info("invoke_assignment", "invoke_assignment_lhs:lhs c_spc_nl* t_ASSIGN:to c_spc_nl* assign_rhs:rhs { lhs.name = :\"\#{lhs.name}=\" orig_arguments = lhs.arguments && lhs.arguments.body || [] arg_order = lhs.name==:\"[]=\" ? [*orig_arguments, rhs] : [rhs, *orig_arguments] lhs.arguments = node(:argass, rhs, arg_order) lhs }")
7050
7226
  Rules[:_invoke_body] = rule_info("invoke_body", "(c_spc_nl* param_list:n)?:np c_spc_nl* meme_enclosed_expr_body:nb { [np, nb] }")
7051
- Rules[:_invoke] = rule_info("invoke", "t_IDENTIFIER:tn (c_spc_nl* arg_list:na)?:na (c_spc_nl* invoke_body:n)?:nlist {node(:invoke, tn, nil, tn.sym, na, *nlist)}")
7052
- Rules[:_op_invoke] = rule_info("op_invoke", "op_invoke_id:tn (c_spc_nl* arg_list:na)?:na (c_spc_nl* invoke_body:n)?:nlist {node(:invoke, tn, nil, tn.sym, na, *nlist)}")
7053
- Rules[:_op_invoke_id] = rule_info("op_invoke_id", "left_op")
7227
+ Rules[:_invoke] = rule_info("invoke", "t_IDENTIFIER:tn (c_spc* arg_list:na)?:na (c_spc_nl* invoke_body:n)?:nlist {node(:invoke, tn, nil, tn.sym, na, *nlist)}")
7228
+ Rules[:_op_invoke_id] = rule_info("op_invoke_id", "left_op_normal")
7229
+ Rules[:_op_invoke] = rule_info("op_invoke", "op_invoke_id:tn (c_spc* arg_list:na)?:na (c_spc_nl* invoke_body:n)?:nlist {node(:invoke, tn, nil, tn.sym, na, *nlist)}")
7230
+ Rules[:_elem_invoke] = rule_info("elem_invoke", "lit_array:na (c_spc_nl* invoke_body:n)?:nlist {node(:invoke, na, nil, :\"[]\", node(:argass, na, na.body), *nlist)}")
7054
7231
  Rules[:_arg_sep] = rule_info("arg_sep", "(c_spc* t_ARG_SEP c_spc*)+")
7055
7232
  Rules[:_arg_sep_opt] = rule_info("arg_sep_opt", "(c_spc | t_ARG_SEP)*")
7056
7233
  Rules[:_in_arg_normal] = rule_info("in_arg_normal", "(in_arg_splat | arg_expr:n0 !in_arg_kwarg_mark { n0 })")
@@ -7061,17 +7238,20 @@ class CodeTools::PegParser
7061
7238
  Rules[:_in_arg_splat] = rule_info("in_arg_splat", "t_OP_MULT:to expr_atom:n0 {node(:splat, to, n0)}")
7062
7239
  Rules[:_in_arg_block] = rule_info("in_arg_block", "t_OP_TOPROC:to expr_atom:n0 {node(:block_pass, to, nil, n0)}")
7063
7240
  Rules[:_in_arg_list] = rule_info("in_arg_list", "(in_arg_normals:n0 arg_sep in_arg_kwargs:n1 arg_sep in_arg_block:n2 { [*n0,n1,n2] } | in_arg_normals:n0 arg_sep in_arg_kwargs:n1 { [*n0,n1] } | in_arg_normals:n0 arg_sep in_arg_block:n1 { [*n0,n1] } | in_arg_kwargs:n0 arg_sep in_arg_block:n1 { [n0, n1] } | in_arg_normals:n0 { [*n0] } | in_arg_kwargs:n0 { [n0] } | in_arg_block:n0 { [n0] })")
7064
- Rules[:_arg_list] = rule_info("arg_list", "(t_ARGS_BEGIN:tb arg_sep_opt t_ARGS_END {args_assemble(tb, node(:array, tb, []))} | t_ARGS_BEGIN:tb arg_sep_opt in_arg_list:nlist arg_sep_opt t_ARGS_END {args_assemble(tb, node(:array, tb, nlist))})")
7065
- Rules[:_lit_array] = rule_info("lit_array", "(t_ARRAY_BEGIN:tb arg_sep_opt t_ARRAY_END {args_assemble(tb, node(:array, tb, []))} | t_ARRAY_BEGIN:tb arg_sep_opt in_arg_list:nlist arg_sep_opt t_ARRAY_END {args_assemble(tb, node(:array, tb, nlist))})")
7241
+ Rules[:_arg_list] = rule_info("arg_list", "(t_ARGS_BEGIN:tb arg_sep_opt t_ARGS_END {node(:argass, tb, [])} | t_ARGS_BEGIN:tb arg_sep_opt in_arg_list:nlist arg_sep_opt t_ARGS_END {node(:argass, tb, nlist)})")
7242
+ Rules[:_lit_array] = rule_info("lit_array", "(t_ARRAY_BEGIN:tb arg_sep_opt t_ARRAY_END {node(:arrass, tb, [])} | t_ARRAY_BEGIN:tb arg_sep_opt in_arg_list:nlist arg_sep_opt t_ARRAY_END {node(:arrass, tb, nlist)})")
7066
7243
  Rules[:_param] = rule_info("param", "(t_IDENTIFIER:ti c_spc_nl* t_ASSIGN:to c_spc_nl* arg_expr:nv { [:optional, node(:lasgn, ti, ti.sym, nv)] } | t_IDENTIFIER:ti c_spc_nl* t_MEME_MARK:to c_spc_nl* arg_expr?:nv { [:kwargs, node(:lasgn, ti, ti.sym, (nv || node(:lit, to, :*)))] } | t_OP_EXP c_spc_nl* t_IDENTIFIER:ti { [:kwrest, ti.sym] } | t_OP_MULT c_spc_nl* t_IDENTIFIER:ti { [:rest, ti.sym] } | t_OP_TOPROC c_spc_nl* t_IDENTIFIER:ti { [:block, ti.sym] } | t_IDENTIFIER:ti { [:required, ti.sym] })")
7067
7244
  Rules[:_param_sepd] = rule_info("param_sepd", "arg_sep param:n0 { n0 }")
7068
7245
  Rules[:_param_sepds] = rule_info("param_sepds", "param:n0 (arg_sep param:n)*:nrest arg_sep_opt { [n0, *nrest] }")
7069
7246
  Rules[:_param_list] = rule_info("param_list", "(t_PARAMS_BEGIN:tb t_PARAMS_END { node(:args, tb, nil, nil, nil, nil, nil, nil, nil) } | t_PARAMS_BEGIN:tb param_sepds:plist t_PARAMS_END { required, optional, rest, kwargs, kwrest, block = 6.times.map { [] } required << plist.shift[1] while plist[0] && plist[0][0] == :required optional << plist.shift[1] while plist[0] && plist[0][0] == :optional rest << plist.shift[1] while plist[0] && plist[0][0] == :rest kwargs << plist.shift[1] while plist[0] && plist[0][0] == :kwargs kwrest << plist.shift[1] while plist[0] && plist[0][0] == :kwrest block << plist.shift[1] while plist[0] && plist[0][0] == :block required = required optional = optional.empty? ? nil : node(:block, tb, optional) rest = rest.first post = nil kwargs = kwargs.empty? ? nil : node(:block, tb, kwargs) kwrest = kwrest.first block = block.first node(:args, tb, required, optional, rest, post, kwargs, kwrest, block) })")
7070
- Rules[:_left_op] = rule_info("left_op", "(t_OP_EXP | t_OP_MULT | t_OP_DIV | t_OP_MOD | t_OP_PLUS | t_OP_MINUS | t_OP_COMPARE | t_OP_AND | t_OP_OR)")
7071
- Rules[:_left_chained_atoms] = rule_info("left_chained_atoms", "expr_atom:n0 (c_spc_nl* left_op:to c_spc_nl* expr_atom:n1 { [to, n1] })+:list { list.unshift n0 list.flatten! collapse(list, :t_OP_EXP) collapse(list, :t_OP_MULT, :t_OP_DIV, :t_OP_MOD) collapse(list, :t_OP_PLUS, :t_OP_MINUS) collapse(list, :t_OP_COMPARE) collapse(list, :t_OP_AND, :t_OP_OR) do |n0,op,n1| type = { :t_OP_AND=>:and, :t_OP_OR=>:or }[op.type] node(type, op, n0, n1) end \# There should only be one resulting node left raise \"Failed to fully collapse left_chained_atoms: \#{list}\" \\ unless list.count == 1 list.first }")
7247
+ Rules[:_left_op_normal] = rule_info("left_op_normal", "(t_OP_EXP | t_OP_MULT | t_OP_DIV | t_OP_MOD | t_OP_PLUS | t_OP_MINUS | t_OP_COMPARE)")
7248
+ Rules[:_left_op_branch] = rule_info("left_op_branch", "(t_OP_AND | t_OP_OR | t_OP_AND_Q | t_OP_OR_Q | t_OP_VOID_Q)")
7249
+ Rules[:_left_op] = rule_info("left_op", "(left_op_normal | left_op_branch)")
7250
+ Rules[:_left_chained_atoms] = rule_info("left_chained_atoms", "expr_atom:n0 (c_spc_nl* left_op:to c_spc_nl* expr_atom:n1 { [to, n1] })+:list { list.unshift n0 list.flatten! collapse(list, :t_OP_EXP) collapse(list, :t_OP_MULT, :t_OP_DIV, :t_OP_MOD) collapse(list, :t_OP_PLUS, :t_OP_MINUS) collapse(list, :t_OP_COMPARE) collapse(list, :t_OP_AND, :t_OP_OR, :t_OP_AND_Q, :t_OP_OR_Q, :t_OP_VOID_Q) do |n0,op,n1| node(:branch_op, op, op.sym, n0, n1) end \# There should only be one resulting node left raise \"Failed to fully collapse left_chained_atoms: \#{list}\" \\ unless list.count == 1 list.first }")
7072
7251
  Rules[:_left_invoke_op] = rule_info("left_invoke_op", "(t_QUEST | t_DOT)")
7073
- Rules[:_left_chained_invocations] = rule_info("left_chained_invocations", "expr_atom_not_chained:n0 (c_spc_nl* left_invoke_op:to c_spc_nl* (invoke | op_invoke):n1 { [to, n1] })+:list { list.unshift n0 list.flatten! collapse(list, :t_DOT, :t_QUEST) do |n0,op,n1| op.type==:t_DOT ? (n1.receiver=n0; n1) : node(:quest, op, n0, n1) end \# There should only be one resulting node left raise \"Failed to fully collapse left_chained_invocations: \#{list}\" \\ unless list.count == 1 list.first }")
7074
- Rules[:_unary_operation] = rule_info("unary_operation", "t_OP_NOT:to expr_atom:n0 {node(:call, to, n0, :\"!\", nil)}")
7252
+ Rules[:_left_chained_invocation] = rule_info("left_chained_invocation", "(c_spc_nl* left_invoke_op:to c_spc_nl* (invoke | op_invoke):n1 { [to, n1] } | c_spc* elem_invoke:n1 { [token(:t_DOT, \"\"), n1] })")
7253
+ Rules[:_left_chained_invocations] = rule_info("left_chained_invocations", "expr_atom_not_chained:n0 left_chained_invocation+:list { list.unshift n0 list.flatten! collapse(list, :t_DOT, :t_QUEST) do |n0,op,n1| op.type==:t_DOT ? (n1.receiver=n0; n1) : node(:quest, op, n0, n1) end \# There should only be one resulting node left raise \"Failed to fully collapse left_chained_invocations: \#{list}\" \\ unless list.count == 1 list.first }")
7254
+ Rules[:_unary_operation] = rule_info("unary_operation", "t_OP_NOT:to expr_atom:n0 {node(:invoke, to, n0, :\"!\", nil)}")
7075
7255
  Rules[:_t_inln_sep] = rule_info("t_inln_sep", "!t_ARG_SEP t_EXPR_SEP")
7076
7256
  Rules[:_inln_sep] = rule_info("inln_sep", "(c_spc* t_inln_sep c_spc*)+")
7077
7257
  Rules[:_inln_sep_opt] = rule_info("inln_sep_opt", "(c_spc | t_inln_sep)*")
@@ -7087,8 +7267,8 @@ class CodeTools::PegParser
7087
7267
  Rules[:_meme_either_body] = rule_info("meme_either_body", "(meme_enclosed_expr_body | meme_inline_expr_body)")
7088
7268
  Rules[:_cmeme] = rule_info("cmeme", "constant:n0 c_spc* t_MEME_MARK:tm c_spc_nl* meme_inline_expr_body:n1 {node(:cdecl, tm, n0, n1)}")
7089
7269
  Rules[:_meme_name] = rule_info("meme_name", "(id_as_symbol | lit_string_as_symbol)")
7090
- Rules[:_decorator] = rule_info("decorator", "meme_name:ni arg_list?:na {node(:deco, ni, ni, na)}")
7091
- Rules[:_decorators_and_meme_name] = rule_info("decorators_and_meme_name", "decorator:n0 (c_spc* decorator:n)*:nrest {node(:array, n0, [n0, *nrest].reverse)}")
7270
+ Rules[:_decorator] = rule_info("decorator", "meme_name:ni arg_list?:na {node(:deco, ni, ni, (na ? node(:arrass, na, na.body) : nil))}")
7271
+ Rules[:_decorators_and_meme_name] = rule_info("decorators_and_meme_name", "decorator:n0 (c_spc* decorator:n)*:nrest {node(:arrass, n0, [n0, *nrest].reverse)}")
7092
7272
  Rules[:_meme] = rule_info("meme", "(decorators_and_meme_name:nd c_spc* t_MEME_MARK:tm (c_spc_nl* param_list:n)?:np c_spc_nl* meme_either_body:nb {node(:meme, tm, nd.body.shift.name, nd, np, nb)} | decorators_and_meme_name:nd {node(:meme, tm, nd.body.shift.name, nd, nil, nil)})")
7093
7273
  # :startdoc:
7094
7274
  end