1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003
|
# frozen_string_literal: true
# :markup: markdown
=begin
--
This file is generated by the templates/template.rb script and should not be
modified manually. See templates/lib/prism/dsl.rb.erb
if you are looking to modify the template
++
=end
module Prism
# The DSL module provides a set of methods that can be used to create prism
# nodes in a more concise manner. For example, instead of writing:
#
# source = Prism::Source.for("[1]")
#
# Prism::ArrayNode.new(
# source,
# 0,
# Prism::Location.new(source, 0, 3),
# 0,
# [
# Prism::IntegerNode.new(
# source,
# 0,
# Prism::Location.new(source, 1, 1),
# Prism::IntegerBaseFlags::DECIMAL,
# 1
# )
# ],
# Prism::Location.new(source, 0, 1),
# Prism::Location.new(source, 2, 1)
# )
#
# you could instead write:
#
# class Builder
# include Prism::DSL
#
# attr_reader :default_source
#
# def initialize
# @default_source = source("[1]")
# end
#
# def build
# array_node(
# location: location(start_offset: 0, length: 3),
# elements: [
# integer_node(
# location: location(start_offset: 1, length: 1),
# flags: integer_base_flag(:decimal),
# value: 1
# )
# ],
# opening_loc: location(start_offset: 0, length: 1),
# closing_loc: location(start_offset: 2, length: 1)
# )
# end
# end
#
# This is mostly helpful in the context of generating trees programmatically.
module DSL
# Provide all of these methods as module methods as well, to allow for
# building nodes like Prism::DSL.nil_node.
extend self
# Create a new Source object.
def source(string)
Source.for(string)
end
# Create a new Location object.
def location(source: default_source, start_offset: 0, length: 0)
Location.new(source, start_offset, length)
end
# Create a new AliasGlobalVariableNode node.
def alias_global_variable_node(source: default_source, node_id: 0, location: default_location, flags: 0, new_name: global_variable_read_node(source: source), old_name: global_variable_read_node(source: source), keyword_loc: location)
AliasGlobalVariableNode.new(source, node_id, location, flags, new_name, old_name, keyword_loc)
end
# Create a new AliasMethodNode node.
def alias_method_node(source: default_source, node_id: 0, location: default_location, flags: 0, new_name: symbol_node(source: source), old_name: symbol_node(source: source), keyword_loc: location)
AliasMethodNode.new(source, node_id, location, flags, new_name, old_name, keyword_loc)
end
# Create a new AlternationPatternNode node.
def alternation_pattern_node(source: default_source, node_id: 0, location: default_location, flags: 0, left: default_node(source, location), right: default_node(source, location), operator_loc: location)
AlternationPatternNode.new(source, node_id, location, flags, left, right, operator_loc)
end
# Create a new AndNode node.
def and_node(source: default_source, node_id: 0, location: default_location, flags: 0, left: default_node(source, location), right: default_node(source, location), operator_loc: location)
AndNode.new(source, node_id, location, flags, left, right, operator_loc)
end
# Create a new ArgumentsNode node.
def arguments_node(source: default_source, node_id: 0, location: default_location, flags: 0, arguments: [])
ArgumentsNode.new(source, node_id, location, flags, arguments)
end
# Create a new ArrayNode node.
def array_node(source: default_source, node_id: 0, location: default_location, flags: 0, elements: [], opening_loc: nil, closing_loc: nil)
ArrayNode.new(source, node_id, location, flags, elements, opening_loc, closing_loc)
end
# Create a new ArrayPatternNode node.
def array_pattern_node(source: default_source, node_id: 0, location: default_location, flags: 0, constant: nil, requireds: [], rest: nil, posts: [], opening_loc: nil, closing_loc: nil)
ArrayPatternNode.new(source, node_id, location, flags, constant, requireds, rest, posts, opening_loc, closing_loc)
end
# Create a new AssocNode node.
def assoc_node(source: default_source, node_id: 0, location: default_location, flags: 0, key: default_node(source, location), value: default_node(source, location), operator_loc: nil)
AssocNode.new(source, node_id, location, flags, key, value, operator_loc)
end
# Create a new AssocSplatNode node.
def assoc_splat_node(source: default_source, node_id: 0, location: default_location, flags: 0, value: nil, operator_loc: location)
AssocSplatNode.new(source, node_id, location, flags, value, operator_loc)
end
# Create a new BackReferenceReadNode node.
def back_reference_read_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"")
BackReferenceReadNode.new(source, node_id, location, flags, name)
end
# Create a new BeginNode node.
def begin_node(source: default_source, node_id: 0, location: default_location, flags: 0, begin_keyword_loc: nil, statements: nil, rescue_clause: nil, else_clause: nil, ensure_clause: nil, end_keyword_loc: nil)
BeginNode.new(source, node_id, location, flags, begin_keyword_loc, statements, rescue_clause, else_clause, ensure_clause, end_keyword_loc)
end
# Create a new BlockArgumentNode node.
def block_argument_node(source: default_source, node_id: 0, location: default_location, flags: 0, expression: nil, operator_loc: location)
BlockArgumentNode.new(source, node_id, location, flags, expression, operator_loc)
end
# Create a new BlockLocalVariableNode node.
def block_local_variable_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"")
BlockLocalVariableNode.new(source, node_id, location, flags, name)
end
# Create a new BlockNode node.
def block_node(source: default_source, node_id: 0, location: default_location, flags: 0, locals: [], parameters: nil, body: nil, opening_loc: location, closing_loc: location)
BlockNode.new(source, node_id, location, flags, locals, parameters, body, opening_loc, closing_loc)
end
# Create a new BlockParameterNode node.
def block_parameter_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: nil, name_loc: nil, operator_loc: location)
BlockParameterNode.new(source, node_id, location, flags, name, name_loc, operator_loc)
end
# Create a new BlockParametersNode node.
def block_parameters_node(source: default_source, node_id: 0, location: default_location, flags: 0, parameters: nil, locals: [], opening_loc: nil, closing_loc: nil)
BlockParametersNode.new(source, node_id, location, flags, parameters, locals, opening_loc, closing_loc)
end
# Create a new BreakNode node.
def break_node(source: default_source, node_id: 0, location: default_location, flags: 0, arguments: nil, keyword_loc: location)
BreakNode.new(source, node_id, location, flags, arguments, keyword_loc)
end
# Create a new CallAndWriteNode node.
def call_and_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, receiver: nil, call_operator_loc: nil, message_loc: nil, read_name: :"", write_name: :"", operator_loc: location, value: default_node(source, location))
CallAndWriteNode.new(source, node_id, location, flags, receiver, call_operator_loc, message_loc, read_name, write_name, operator_loc, value)
end
# Create a new CallNode node.
def call_node(source: default_source, node_id: 0, location: default_location, flags: 0, receiver: nil, call_operator_loc: nil, name: :"", message_loc: nil, opening_loc: nil, arguments: nil, closing_loc: nil, block: nil)
CallNode.new(source, node_id, location, flags, receiver, call_operator_loc, name, message_loc, opening_loc, arguments, closing_loc, block)
end
# Create a new CallOperatorWriteNode node.
def call_operator_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, receiver: nil, call_operator_loc: nil, message_loc: nil, read_name: :"", write_name: :"", binary_operator: :"", binary_operator_loc: location, value: default_node(source, location))
CallOperatorWriteNode.new(source, node_id, location, flags, receiver, call_operator_loc, message_loc, read_name, write_name, binary_operator, binary_operator_loc, value)
end
# Create a new CallOrWriteNode node.
def call_or_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, receiver: nil, call_operator_loc: nil, message_loc: nil, read_name: :"", write_name: :"", operator_loc: location, value: default_node(source, location))
CallOrWriteNode.new(source, node_id, location, flags, receiver, call_operator_loc, message_loc, read_name, write_name, operator_loc, value)
end
# Create a new CallTargetNode node.
def call_target_node(source: default_source, node_id: 0, location: default_location, flags: 0, receiver: default_node(source, location), call_operator_loc: location, name: :"", message_loc: location)
CallTargetNode.new(source, node_id, location, flags, receiver, call_operator_loc, name, message_loc)
end
# Create a new CapturePatternNode node.
def capture_pattern_node(source: default_source, node_id: 0, location: default_location, flags: 0, value: default_node(source, location), target: local_variable_target_node(source: source), operator_loc: location)
CapturePatternNode.new(source, node_id, location, flags, value, target, operator_loc)
end
# Create a new CaseMatchNode node.
def case_match_node(source: default_source, node_id: 0, location: default_location, flags: 0, predicate: nil, conditions: [], else_clause: nil, case_keyword_loc: location, end_keyword_loc: location)
CaseMatchNode.new(source, node_id, location, flags, predicate, conditions, else_clause, case_keyword_loc, end_keyword_loc)
end
# Create a new CaseNode node.
def case_node(source: default_source, node_id: 0, location: default_location, flags: 0, predicate: nil, conditions: [], else_clause: nil, case_keyword_loc: location, end_keyword_loc: location)
CaseNode.new(source, node_id, location, flags, predicate, conditions, else_clause, case_keyword_loc, end_keyword_loc)
end
# Create a new ClassNode node.
def class_node(source: default_source, node_id: 0, location: default_location, flags: 0, locals: [], class_keyword_loc: location, constant_path: constant_read_node(source: source), inheritance_operator_loc: nil, superclass: nil, body: nil, end_keyword_loc: location, name: :"")
ClassNode.new(source, node_id, location, flags, locals, class_keyword_loc, constant_path, inheritance_operator_loc, superclass, body, end_keyword_loc, name)
end
# Create a new ClassVariableAndWriteNode node.
def class_variable_and_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, operator_loc: location, value: default_node(source, location))
ClassVariableAndWriteNode.new(source, node_id, location, flags, name, name_loc, operator_loc, value)
end
# Create a new ClassVariableOperatorWriteNode node.
def class_variable_operator_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, binary_operator_loc: location, value: default_node(source, location), binary_operator: :"")
ClassVariableOperatorWriteNode.new(source, node_id, location, flags, name, name_loc, binary_operator_loc, value, binary_operator)
end
# Create a new ClassVariableOrWriteNode node.
def class_variable_or_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, operator_loc: location, value: default_node(source, location))
ClassVariableOrWriteNode.new(source, node_id, location, flags, name, name_loc, operator_loc, value)
end
# Create a new ClassVariableReadNode node.
def class_variable_read_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"")
ClassVariableReadNode.new(source, node_id, location, flags, name)
end
# Create a new ClassVariableTargetNode node.
def class_variable_target_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"")
ClassVariableTargetNode.new(source, node_id, location, flags, name)
end
# Create a new ClassVariableWriteNode node.
def class_variable_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, value: default_node(source, location), operator_loc: location)
ClassVariableWriteNode.new(source, node_id, location, flags, name, name_loc, value, operator_loc)
end
# Create a new ConstantAndWriteNode node.
def constant_and_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, operator_loc: location, value: default_node(source, location))
ConstantAndWriteNode.new(source, node_id, location, flags, name, name_loc, operator_loc, value)
end
# Create a new ConstantOperatorWriteNode node.
def constant_operator_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, binary_operator_loc: location, value: default_node(source, location), binary_operator: :"")
ConstantOperatorWriteNode.new(source, node_id, location, flags, name, name_loc, binary_operator_loc, value, binary_operator)
end
# Create a new ConstantOrWriteNode node.
def constant_or_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, operator_loc: location, value: default_node(source, location))
ConstantOrWriteNode.new(source, node_id, location, flags, name, name_loc, operator_loc, value)
end
# Create a new ConstantPathAndWriteNode node.
def constant_path_and_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, target: constant_path_node(source: source), operator_loc: location, value: default_node(source, location))
ConstantPathAndWriteNode.new(source, node_id, location, flags, target, operator_loc, value)
end
# Create a new ConstantPathNode node.
def constant_path_node(source: default_source, node_id: 0, location: default_location, flags: 0, parent: nil, name: nil, delimiter_loc: location, name_loc: location)
ConstantPathNode.new(source, node_id, location, flags, parent, name, delimiter_loc, name_loc)
end
# Create a new ConstantPathOperatorWriteNode node.
def constant_path_operator_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, target: constant_path_node(source: source), binary_operator_loc: location, value: default_node(source, location), binary_operator: :"")
ConstantPathOperatorWriteNode.new(source, node_id, location, flags, target, binary_operator_loc, value, binary_operator)
end
# Create a new ConstantPathOrWriteNode node.
def constant_path_or_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, target: constant_path_node(source: source), operator_loc: location, value: default_node(source, location))
ConstantPathOrWriteNode.new(source, node_id, location, flags, target, operator_loc, value)
end
# Create a new ConstantPathTargetNode node.
def constant_path_target_node(source: default_source, node_id: 0, location: default_location, flags: 0, parent: nil, name: nil, delimiter_loc: location, name_loc: location)
ConstantPathTargetNode.new(source, node_id, location, flags, parent, name, delimiter_loc, name_loc)
end
# Create a new ConstantPathWriteNode node.
def constant_path_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, target: constant_path_node(source: source), operator_loc: location, value: default_node(source, location))
ConstantPathWriteNode.new(source, node_id, location, flags, target, operator_loc, value)
end
# Create a new ConstantReadNode node.
def constant_read_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"")
ConstantReadNode.new(source, node_id, location, flags, name)
end
# Create a new ConstantTargetNode node.
def constant_target_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"")
ConstantTargetNode.new(source, node_id, location, flags, name)
end
# Create a new ConstantWriteNode node.
def constant_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, value: default_node(source, location), operator_loc: location)
ConstantWriteNode.new(source, node_id, location, flags, name, name_loc, value, operator_loc)
end
# Create a new DefNode node.
def def_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, receiver: nil, parameters: nil, body: nil, locals: [], def_keyword_loc: location, operator_loc: nil, lparen_loc: nil, rparen_loc: nil, equal_loc: nil, end_keyword_loc: nil)
DefNode.new(source, node_id, location, flags, name, name_loc, receiver, parameters, body, locals, def_keyword_loc, operator_loc, lparen_loc, rparen_loc, equal_loc, end_keyword_loc)
end
# Create a new DefinedNode node.
def defined_node(source: default_source, node_id: 0, location: default_location, flags: 0, lparen_loc: nil, value: default_node(source, location), rparen_loc: nil, keyword_loc: location)
DefinedNode.new(source, node_id, location, flags, lparen_loc, value, rparen_loc, keyword_loc)
end
# Create a new ElseNode node.
def else_node(source: default_source, node_id: 0, location: default_location, flags: 0, else_keyword_loc: location, statements: nil, end_keyword_loc: nil)
ElseNode.new(source, node_id, location, flags, else_keyword_loc, statements, end_keyword_loc)
end
# Create a new EmbeddedStatementsNode node.
def embedded_statements_node(source: default_source, node_id: 0, location: default_location, flags: 0, opening_loc: location, statements: nil, closing_loc: location)
EmbeddedStatementsNode.new(source, node_id, location, flags, opening_loc, statements, closing_loc)
end
# Create a new EmbeddedVariableNode node.
def embedded_variable_node(source: default_source, node_id: 0, location: default_location, flags: 0, operator_loc: location, variable: instance_variable_read_node(source: source))
EmbeddedVariableNode.new(source, node_id, location, flags, operator_loc, variable)
end
# Create a new EnsureNode node.
def ensure_node(source: default_source, node_id: 0, location: default_location, flags: 0, ensure_keyword_loc: location, statements: nil, end_keyword_loc: location)
EnsureNode.new(source, node_id, location, flags, ensure_keyword_loc, statements, end_keyword_loc)
end
# Create a new FalseNode node.
def false_node(source: default_source, node_id: 0, location: default_location, flags: 0)
FalseNode.new(source, node_id, location, flags)
end
# Create a new FindPatternNode node.
def find_pattern_node(source: default_source, node_id: 0, location: default_location, flags: 0, constant: nil, left: splat_node(source: source), requireds: [], right: splat_node(source: source), opening_loc: nil, closing_loc: nil)
FindPatternNode.new(source, node_id, location, flags, constant, left, requireds, right, opening_loc, closing_loc)
end
# Create a new FlipFlopNode node.
def flip_flop_node(source: default_source, node_id: 0, location: default_location, flags: 0, left: nil, right: nil, operator_loc: location)
FlipFlopNode.new(source, node_id, location, flags, left, right, operator_loc)
end
# Create a new FloatNode node.
def float_node(source: default_source, node_id: 0, location: default_location, flags: 0, value: 0.0)
FloatNode.new(source, node_id, location, flags, value)
end
# Create a new ForNode node.
def for_node(source: default_source, node_id: 0, location: default_location, flags: 0, index: local_variable_target_node(source: source), collection: default_node(source, location), statements: nil, for_keyword_loc: location, in_keyword_loc: location, do_keyword_loc: nil, end_keyword_loc: location)
ForNode.new(source, node_id, location, flags, index, collection, statements, for_keyword_loc, in_keyword_loc, do_keyword_loc, end_keyword_loc)
end
# Create a new ForwardingArgumentsNode node.
def forwarding_arguments_node(source: default_source, node_id: 0, location: default_location, flags: 0)
ForwardingArgumentsNode.new(source, node_id, location, flags)
end
# Create a new ForwardingParameterNode node.
def forwarding_parameter_node(source: default_source, node_id: 0, location: default_location, flags: 0)
ForwardingParameterNode.new(source, node_id, location, flags)
end
# Create a new ForwardingSuperNode node.
def forwarding_super_node(source: default_source, node_id: 0, location: default_location, flags: 0, block: nil)
ForwardingSuperNode.new(source, node_id, location, flags, block)
end
# Create a new GlobalVariableAndWriteNode node.
def global_variable_and_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, operator_loc: location, value: default_node(source, location))
GlobalVariableAndWriteNode.new(source, node_id, location, flags, name, name_loc, operator_loc, value)
end
# Create a new GlobalVariableOperatorWriteNode node.
def global_variable_operator_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, binary_operator_loc: location, value: default_node(source, location), binary_operator: :"")
GlobalVariableOperatorWriteNode.new(source, node_id, location, flags, name, name_loc, binary_operator_loc, value, binary_operator)
end
# Create a new GlobalVariableOrWriteNode node.
def global_variable_or_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, operator_loc: location, value: default_node(source, location))
GlobalVariableOrWriteNode.new(source, node_id, location, flags, name, name_loc, operator_loc, value)
end
# Create a new GlobalVariableReadNode node.
def global_variable_read_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"")
GlobalVariableReadNode.new(source, node_id, location, flags, name)
end
# Create a new GlobalVariableTargetNode node.
def global_variable_target_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"")
GlobalVariableTargetNode.new(source, node_id, location, flags, name)
end
# Create a new GlobalVariableWriteNode node.
def global_variable_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, value: default_node(source, location), operator_loc: location)
GlobalVariableWriteNode.new(source, node_id, location, flags, name, name_loc, value, operator_loc)
end
# Create a new HashNode node.
def hash_node(source: default_source, node_id: 0, location: default_location, flags: 0, opening_loc: location, elements: [], closing_loc: location)
HashNode.new(source, node_id, location, flags, opening_loc, elements, closing_loc)
end
# Create a new HashPatternNode node.
def hash_pattern_node(source: default_source, node_id: 0, location: default_location, flags: 0, constant: nil, elements: [], rest: nil, opening_loc: nil, closing_loc: nil)
HashPatternNode.new(source, node_id, location, flags, constant, elements, rest, opening_loc, closing_loc)
end
# Create a new IfNode node.
def if_node(source: default_source, node_id: 0, location: default_location, flags: 0, if_keyword_loc: nil, predicate: default_node(source, location), then_keyword_loc: nil, statements: nil, subsequent: nil, end_keyword_loc: nil)
IfNode.new(source, node_id, location, flags, if_keyword_loc, predicate, then_keyword_loc, statements, subsequent, end_keyword_loc)
end
# Create a new ImaginaryNode node.
def imaginary_node(source: default_source, node_id: 0, location: default_location, flags: 0, numeric: float_node(source: source))
ImaginaryNode.new(source, node_id, location, flags, numeric)
end
# Create a new ImplicitNode node.
def implicit_node(source: default_source, node_id: 0, location: default_location, flags: 0, value: local_variable_read_node(source: source))
ImplicitNode.new(source, node_id, location, flags, value)
end
# Create a new ImplicitRestNode node.
def implicit_rest_node(source: default_source, node_id: 0, location: default_location, flags: 0)
ImplicitRestNode.new(source, node_id, location, flags)
end
# Create a new InNode node.
def in_node(source: default_source, node_id: 0, location: default_location, flags: 0, pattern: default_node(source, location), statements: nil, in_loc: location, then_loc: nil)
InNode.new(source, node_id, location, flags, pattern, statements, in_loc, then_loc)
end
# Create a new IndexAndWriteNode node.
def index_and_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, receiver: nil, call_operator_loc: nil, opening_loc: location, arguments: nil, closing_loc: location, block: nil, operator_loc: location, value: default_node(source, location))
IndexAndWriteNode.new(source, node_id, location, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator_loc, value)
end
# Create a new IndexOperatorWriteNode node.
def index_operator_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, receiver: nil, call_operator_loc: nil, opening_loc: location, arguments: nil, closing_loc: location, block: nil, binary_operator: :"", binary_operator_loc: location, value: default_node(source, location))
IndexOperatorWriteNode.new(source, node_id, location, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, binary_operator, binary_operator_loc, value)
end
# Create a new IndexOrWriteNode node.
def index_or_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, receiver: nil, call_operator_loc: nil, opening_loc: location, arguments: nil, closing_loc: location, block: nil, operator_loc: location, value: default_node(source, location))
IndexOrWriteNode.new(source, node_id, location, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator_loc, value)
end
# Create a new IndexTargetNode node.
def index_target_node(source: default_source, node_id: 0, location: default_location, flags: 0, receiver: default_node(source, location), opening_loc: location, arguments: nil, closing_loc: location, block: nil)
IndexTargetNode.new(source, node_id, location, flags, receiver, opening_loc, arguments, closing_loc, block)
end
# Create a new InstanceVariableAndWriteNode node.
def instance_variable_and_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, operator_loc: location, value: default_node(source, location))
InstanceVariableAndWriteNode.new(source, node_id, location, flags, name, name_loc, operator_loc, value)
end
# Create a new InstanceVariableOperatorWriteNode node.
def instance_variable_operator_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, binary_operator_loc: location, value: default_node(source, location), binary_operator: :"")
InstanceVariableOperatorWriteNode.new(source, node_id, location, flags, name, name_loc, binary_operator_loc, value, binary_operator)
end
# Create a new InstanceVariableOrWriteNode node.
def instance_variable_or_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, operator_loc: location, value: default_node(source, location))
InstanceVariableOrWriteNode.new(source, node_id, location, flags, name, name_loc, operator_loc, value)
end
# Create a new InstanceVariableReadNode node.
def instance_variable_read_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"")
InstanceVariableReadNode.new(source, node_id, location, flags, name)
end
# Create a new InstanceVariableTargetNode node.
def instance_variable_target_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"")
InstanceVariableTargetNode.new(source, node_id, location, flags, name)
end
# Create a new InstanceVariableWriteNode node.
def instance_variable_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, value: default_node(source, location), operator_loc: location)
InstanceVariableWriteNode.new(source, node_id, location, flags, name, name_loc, value, operator_loc)
end
# Create a new IntegerNode node.
def integer_node(source: default_source, node_id: 0, location: default_location, flags: 0, value: 0)
IntegerNode.new(source, node_id, location, flags, value)
end
# Create a new InterpolatedMatchLastLineNode node.
def interpolated_match_last_line_node(source: default_source, node_id: 0, location: default_location, flags: 0, opening_loc: location, parts: [], closing_loc: location)
InterpolatedMatchLastLineNode.new(source, node_id, location, flags, opening_loc, parts, closing_loc)
end
# Create a new InterpolatedRegularExpressionNode node.
def interpolated_regular_expression_node(source: default_source, node_id: 0, location: default_location, flags: 0, opening_loc: location, parts: [], closing_loc: location)
InterpolatedRegularExpressionNode.new(source, node_id, location, flags, opening_loc, parts, closing_loc)
end
# Create a new InterpolatedStringNode node.
def interpolated_string_node(source: default_source, node_id: 0, location: default_location, flags: 0, opening_loc: nil, parts: [], closing_loc: nil)
InterpolatedStringNode.new(source, node_id, location, flags, opening_loc, parts, closing_loc)
end
# Create a new InterpolatedSymbolNode node.
def interpolated_symbol_node(source: default_source, node_id: 0, location: default_location, flags: 0, opening_loc: nil, parts: [], closing_loc: nil)
InterpolatedSymbolNode.new(source, node_id, location, flags, opening_loc, parts, closing_loc)
end
# Create a new InterpolatedXStringNode node.
def interpolated_x_string_node(source: default_source, node_id: 0, location: default_location, flags: 0, opening_loc: location, parts: [], closing_loc: location)
InterpolatedXStringNode.new(source, node_id, location, flags, opening_loc, parts, closing_loc)
end
# Create a new ItLocalVariableReadNode node.
def it_local_variable_read_node(source: default_source, node_id: 0, location: default_location, flags: 0)
ItLocalVariableReadNode.new(source, node_id, location, flags)
end
# Create a new ItParametersNode node.
def it_parameters_node(source: default_source, node_id: 0, location: default_location, flags: 0)
ItParametersNode.new(source, node_id, location, flags)
end
# Create a new KeywordHashNode node.
def keyword_hash_node(source: default_source, node_id: 0, location: default_location, flags: 0, elements: [])
KeywordHashNode.new(source, node_id, location, flags, elements)
end
# Create a new KeywordRestParameterNode node.
def keyword_rest_parameter_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: nil, name_loc: nil, operator_loc: location)
KeywordRestParameterNode.new(source, node_id, location, flags, name, name_loc, operator_loc)
end
# Create a new LambdaNode node.
def lambda_node(source: default_source, node_id: 0, location: default_location, flags: 0, locals: [], operator_loc: location, opening_loc: location, closing_loc: location, parameters: nil, body: nil)
LambdaNode.new(source, node_id, location, flags, locals, operator_loc, opening_loc, closing_loc, parameters, body)
end
# Create a new LocalVariableAndWriteNode node.
def local_variable_and_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name_loc: location, operator_loc: location, value: default_node(source, location), name: :"", depth: 0)
LocalVariableAndWriteNode.new(source, node_id, location, flags, name_loc, operator_loc, value, name, depth)
end
# Create a new LocalVariableOperatorWriteNode node.
def local_variable_operator_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name_loc: location, binary_operator_loc: location, value: default_node(source, location), name: :"", binary_operator: :"", depth: 0)
LocalVariableOperatorWriteNode.new(source, node_id, location, flags, name_loc, binary_operator_loc, value, name, binary_operator, depth)
end
# Create a new LocalVariableOrWriteNode node.
def local_variable_or_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name_loc: location, operator_loc: location, value: default_node(source, location), name: :"", depth: 0)
LocalVariableOrWriteNode.new(source, node_id, location, flags, name_loc, operator_loc, value, name, depth)
end
# Create a new LocalVariableReadNode node.
def local_variable_read_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", depth: 0)
LocalVariableReadNode.new(source, node_id, location, flags, name, depth)
end
# Create a new LocalVariableTargetNode node.
def local_variable_target_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", depth: 0)
LocalVariableTargetNode.new(source, node_id, location, flags, name, depth)
end
# Create a new LocalVariableWriteNode node.
def local_variable_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", depth: 0, name_loc: location, value: default_node(source, location), operator_loc: location)
LocalVariableWriteNode.new(source, node_id, location, flags, name, depth, name_loc, value, operator_loc)
end
# Create a new MatchLastLineNode node.
def match_last_line_node(source: default_source, node_id: 0, location: default_location, flags: 0, opening_loc: location, content_loc: location, closing_loc: location, unescaped: "")
MatchLastLineNode.new(source, node_id, location, flags, opening_loc, content_loc, closing_loc, unescaped)
end
# Create a new MatchPredicateNode node.
def match_predicate_node(source: default_source, node_id: 0, location: default_location, flags: 0, value: default_node(source, location), pattern: default_node(source, location), operator_loc: location)
MatchPredicateNode.new(source, node_id, location, flags, value, pattern, operator_loc)
end
# Create a new MatchRequiredNode node.
def match_required_node(source: default_source, node_id: 0, location: default_location, flags: 0, value: default_node(source, location), pattern: default_node(source, location), operator_loc: location)
MatchRequiredNode.new(source, node_id, location, flags, value, pattern, operator_loc)
end
# Create a new MatchWriteNode node.
def match_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, call: call_node(source: source), targets: [])
MatchWriteNode.new(source, node_id, location, flags, call, targets)
end
# Create a new MissingNode node.
def missing_node(source: default_source, node_id: 0, location: default_location, flags: 0)
MissingNode.new(source, node_id, location, flags)
end
# Create a new ModuleNode node.
def module_node(source: default_source, node_id: 0, location: default_location, flags: 0, locals: [], module_keyword_loc: location, constant_path: constant_read_node(source: source), body: nil, end_keyword_loc: location, name: :"")
ModuleNode.new(source, node_id, location, flags, locals, module_keyword_loc, constant_path, body, end_keyword_loc, name)
end
# Create a new MultiTargetNode node.
def multi_target_node(source: default_source, node_id: 0, location: default_location, flags: 0, lefts: [], rest: nil, rights: [], lparen_loc: nil, rparen_loc: nil)
MultiTargetNode.new(source, node_id, location, flags, lefts, rest, rights, lparen_loc, rparen_loc)
end
# Create a new MultiWriteNode node.
def multi_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, lefts: [], rest: nil, rights: [], lparen_loc: nil, rparen_loc: nil, operator_loc: location, value: default_node(source, location))
MultiWriteNode.new(source, node_id, location, flags, lefts, rest, rights, lparen_loc, rparen_loc, operator_loc, value)
end
# Create a new NextNode node.
def next_node(source: default_source, node_id: 0, location: default_location, flags: 0, arguments: nil, keyword_loc: location)
NextNode.new(source, node_id, location, flags, arguments, keyword_loc)
end
# Create a new NilNode node.
def nil_node(source: default_source, node_id: 0, location: default_location, flags: 0)
NilNode.new(source, node_id, location, flags)
end
# Create a new NoKeywordsParameterNode node.
def no_keywords_parameter_node(source: default_source, node_id: 0, location: default_location, flags: 0, operator_loc: location, keyword_loc: location)
NoKeywordsParameterNode.new(source, node_id, location, flags, operator_loc, keyword_loc)
end
# Create a new NumberedParametersNode node.
def numbered_parameters_node(source: default_source, node_id: 0, location: default_location, flags: 0, maximum: 0)
NumberedParametersNode.new(source, node_id, location, flags, maximum)
end
# Create a new NumberedReferenceReadNode node.
def numbered_reference_read_node(source: default_source, node_id: 0, location: default_location, flags: 0, number: 0)
NumberedReferenceReadNode.new(source, node_id, location, flags, number)
end
# Create a new OptionalKeywordParameterNode node.
def optional_keyword_parameter_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, value: default_node(source, location))
OptionalKeywordParameterNode.new(source, node_id, location, flags, name, name_loc, value)
end
# Create a new OptionalParameterNode node.
def optional_parameter_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location, operator_loc: location, value: default_node(source, location))
OptionalParameterNode.new(source, node_id, location, flags, name, name_loc, operator_loc, value)
end
# Create a new OrNode node.
def or_node(source: default_source, node_id: 0, location: default_location, flags: 0, left: default_node(source, location), right: default_node(source, location), operator_loc: location)
OrNode.new(source, node_id, location, flags, left, right, operator_loc)
end
# Create a new ParametersNode node.
def parameters_node(source: default_source, node_id: 0, location: default_location, flags: 0, requireds: [], optionals: [], rest: nil, posts: [], keywords: [], keyword_rest: nil, block: nil)
ParametersNode.new(source, node_id, location, flags, requireds, optionals, rest, posts, keywords, keyword_rest, block)
end
# Create a new ParenthesesNode node.
def parentheses_node(source: default_source, node_id: 0, location: default_location, flags: 0, body: nil, opening_loc: location, closing_loc: location)
ParenthesesNode.new(source, node_id, location, flags, body, opening_loc, closing_loc)
end
# Create a new PinnedExpressionNode node.
def pinned_expression_node(source: default_source, node_id: 0, location: default_location, flags: 0, expression: default_node(source, location), operator_loc: location, lparen_loc: location, rparen_loc: location)
PinnedExpressionNode.new(source, node_id, location, flags, expression, operator_loc, lparen_loc, rparen_loc)
end
# Create a new PinnedVariableNode node.
def pinned_variable_node(source: default_source, node_id: 0, location: default_location, flags: 0, variable: local_variable_read_node(source: source), operator_loc: location)
PinnedVariableNode.new(source, node_id, location, flags, variable, operator_loc)
end
# Create a new PostExecutionNode node.
def post_execution_node(source: default_source, node_id: 0, location: default_location, flags: 0, statements: nil, keyword_loc: location, opening_loc: location, closing_loc: location)
PostExecutionNode.new(source, node_id, location, flags, statements, keyword_loc, opening_loc, closing_loc)
end
# Create a new PreExecutionNode node.
def pre_execution_node(source: default_source, node_id: 0, location: default_location, flags: 0, statements: nil, keyword_loc: location, opening_loc: location, closing_loc: location)
PreExecutionNode.new(source, node_id, location, flags, statements, keyword_loc, opening_loc, closing_loc)
end
# Create a new ProgramNode node.
def program_node(source: default_source, node_id: 0, location: default_location, flags: 0, locals: [], statements: statements_node(source: source))
ProgramNode.new(source, node_id, location, flags, locals, statements)
end
# Create a new RangeNode node.
def range_node(source: default_source, node_id: 0, location: default_location, flags: 0, left: nil, right: nil, operator_loc: location)
RangeNode.new(source, node_id, location, flags, left, right, operator_loc)
end
# Create a new RationalNode node.
def rational_node(source: default_source, node_id: 0, location: default_location, flags: 0, numerator: 0, denominator: 0)
RationalNode.new(source, node_id, location, flags, numerator, denominator)
end
# Create a new RedoNode node.
def redo_node(source: default_source, node_id: 0, location: default_location, flags: 0)
RedoNode.new(source, node_id, location, flags)
end
# Create a new RegularExpressionNode node.
def regular_expression_node(source: default_source, node_id: 0, location: default_location, flags: 0, opening_loc: location, content_loc: location, closing_loc: location, unescaped: "")
RegularExpressionNode.new(source, node_id, location, flags, opening_loc, content_loc, closing_loc, unescaped)
end
# Create a new RequiredKeywordParameterNode node.
def required_keyword_parameter_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"", name_loc: location)
RequiredKeywordParameterNode.new(source, node_id, location, flags, name, name_loc)
end
# Create a new RequiredParameterNode node.
def required_parameter_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: :"")
RequiredParameterNode.new(source, node_id, location, flags, name)
end
# Create a new RescueModifierNode node.
def rescue_modifier_node(source: default_source, node_id: 0, location: default_location, flags: 0, expression: default_node(source, location), keyword_loc: location, rescue_expression: default_node(source, location))
RescueModifierNode.new(source, node_id, location, flags, expression, keyword_loc, rescue_expression)
end
# Create a new RescueNode node.
def rescue_node(source: default_source, node_id: 0, location: default_location, flags: 0, keyword_loc: location, exceptions: [], operator_loc: nil, reference: nil, then_keyword_loc: nil, statements: nil, subsequent: nil)
RescueNode.new(source, node_id, location, flags, keyword_loc, exceptions, operator_loc, reference, then_keyword_loc, statements, subsequent)
end
# Create a new RestParameterNode node.
def rest_parameter_node(source: default_source, node_id: 0, location: default_location, flags: 0, name: nil, name_loc: nil, operator_loc: location)
RestParameterNode.new(source, node_id, location, flags, name, name_loc, operator_loc)
end
# Create a new RetryNode node.
def retry_node(source: default_source, node_id: 0, location: default_location, flags: 0)
RetryNode.new(source, node_id, location, flags)
end
# Create a new ReturnNode node.
def return_node(source: default_source, node_id: 0, location: default_location, flags: 0, keyword_loc: location, arguments: nil)
ReturnNode.new(source, node_id, location, flags, keyword_loc, arguments)
end
# Create a new SelfNode node.
def self_node(source: default_source, node_id: 0, location: default_location, flags: 0)
SelfNode.new(source, node_id, location, flags)
end
# Create a new ShareableConstantNode node.
def shareable_constant_node(source: default_source, node_id: 0, location: default_location, flags: 0, write: constant_write_node(source: source))
ShareableConstantNode.new(source, node_id, location, flags, write)
end
# Create a new SingletonClassNode node.
def singleton_class_node(source: default_source, node_id: 0, location: default_location, flags: 0, locals: [], class_keyword_loc: location, operator_loc: location, expression: default_node(source, location), body: nil, end_keyword_loc: location)
SingletonClassNode.new(source, node_id, location, flags, locals, class_keyword_loc, operator_loc, expression, body, end_keyword_loc)
end
# Create a new SourceEncodingNode node.
def source_encoding_node(source: default_source, node_id: 0, location: default_location, flags: 0)
SourceEncodingNode.new(source, node_id, location, flags)
end
# Create a new SourceFileNode node.
def source_file_node(source: default_source, node_id: 0, location: default_location, flags: 0, filepath: "")
SourceFileNode.new(source, node_id, location, flags, filepath)
end
# Create a new SourceLineNode node.
def source_line_node(source: default_source, node_id: 0, location: default_location, flags: 0)
SourceLineNode.new(source, node_id, location, flags)
end
# Create a new SplatNode node.
def splat_node(source: default_source, node_id: 0, location: default_location, flags: 0, operator_loc: location, expression: nil)
SplatNode.new(source, node_id, location, flags, operator_loc, expression)
end
# Create a new StatementsNode node.
def statements_node(source: default_source, node_id: 0, location: default_location, flags: 0, body: [])
StatementsNode.new(source, node_id, location, flags, body)
end
# Create a new StringNode node.
def string_node(source: default_source, node_id: 0, location: default_location, flags: 0, opening_loc: nil, content_loc: location, closing_loc: nil, unescaped: "")
StringNode.new(source, node_id, location, flags, opening_loc, content_loc, closing_loc, unescaped)
end
# Create a new SuperNode node.
def super_node(source: default_source, node_id: 0, location: default_location, flags: 0, keyword_loc: location, lparen_loc: nil, arguments: nil, rparen_loc: nil, block: nil)
SuperNode.new(source, node_id, location, flags, keyword_loc, lparen_loc, arguments, rparen_loc, block)
end
# Create a new SymbolNode node.
def symbol_node(source: default_source, node_id: 0, location: default_location, flags: 0, opening_loc: nil, value_loc: nil, closing_loc: nil, unescaped: "")
SymbolNode.new(source, node_id, location, flags, opening_loc, value_loc, closing_loc, unescaped)
end
# Create a new TrueNode node.
def true_node(source: default_source, node_id: 0, location: default_location, flags: 0)
TrueNode.new(source, node_id, location, flags)
end
# Create a new UndefNode node.
def undef_node(source: default_source, node_id: 0, location: default_location, flags: 0, names: [], keyword_loc: location)
UndefNode.new(source, node_id, location, flags, names, keyword_loc)
end
# Create a new UnlessNode node.
def unless_node(source: default_source, node_id: 0, location: default_location, flags: 0, keyword_loc: location, predicate: default_node(source, location), then_keyword_loc: nil, statements: nil, else_clause: nil, end_keyword_loc: nil)
UnlessNode.new(source, node_id, location, flags, keyword_loc, predicate, then_keyword_loc, statements, else_clause, end_keyword_loc)
end
# Create a new UntilNode node.
def until_node(source: default_source, node_id: 0, location: default_location, flags: 0, keyword_loc: location, do_keyword_loc: nil, closing_loc: nil, predicate: default_node(source, location), statements: nil)
UntilNode.new(source, node_id, location, flags, keyword_loc, do_keyword_loc, closing_loc, predicate, statements)
end
# Create a new WhenNode node.
def when_node(source: default_source, node_id: 0, location: default_location, flags: 0, keyword_loc: location, conditions: [], then_keyword_loc: nil, statements: nil)
WhenNode.new(source, node_id, location, flags, keyword_loc, conditions, then_keyword_loc, statements)
end
# Create a new WhileNode node.
def while_node(source: default_source, node_id: 0, location: default_location, flags: 0, keyword_loc: location, do_keyword_loc: nil, closing_loc: nil, predicate: default_node(source, location), statements: nil)
WhileNode.new(source, node_id, location, flags, keyword_loc, do_keyword_loc, closing_loc, predicate, statements)
end
# Create a new XStringNode node.
def x_string_node(source: default_source, node_id: 0, location: default_location, flags: 0, opening_loc: location, content_loc: location, closing_loc: location, unescaped: "")
XStringNode.new(source, node_id, location, flags, opening_loc, content_loc, closing_loc, unescaped)
end
# Create a new YieldNode node.
def yield_node(source: default_source, node_id: 0, location: default_location, flags: 0, keyword_loc: location, lparen_loc: nil, arguments: nil, rparen_loc: nil)
YieldNode.new(source, node_id, location, flags, keyword_loc, lparen_loc, arguments, rparen_loc)
end
# Retrieve the value of one of the ArgumentsNodeFlags flags.
def arguments_node_flag(name)
case name
when :contains_forwarding then ArgumentsNodeFlags::CONTAINS_FORWARDING
when :contains_keywords then ArgumentsNodeFlags::CONTAINS_KEYWORDS
when :contains_keyword_splat then ArgumentsNodeFlags::CONTAINS_KEYWORD_SPLAT
when :contains_splat then ArgumentsNodeFlags::CONTAINS_SPLAT
when :contains_multiple_splats then ArgumentsNodeFlags::CONTAINS_MULTIPLE_SPLATS
else Kernel.raise ArgumentError, "invalid ArgumentsNodeFlags flag: #{name.inspect}"
end
end
# Retrieve the value of one of the ArrayNodeFlags flags.
def array_node_flag(name)
case name
when :contains_splat then ArrayNodeFlags::CONTAINS_SPLAT
else Kernel.raise ArgumentError, "invalid ArrayNodeFlags flag: #{name.inspect}"
end
end
# Retrieve the value of one of the CallNodeFlags flags.
def call_node_flag(name)
case name
when :safe_navigation then CallNodeFlags::SAFE_NAVIGATION
when :variable_call then CallNodeFlags::VARIABLE_CALL
when :attribute_write then CallNodeFlags::ATTRIBUTE_WRITE
when :ignore_visibility then CallNodeFlags::IGNORE_VISIBILITY
else Kernel.raise ArgumentError, "invalid CallNodeFlags flag: #{name.inspect}"
end
end
# Retrieve the value of one of the EncodingFlags flags.
def encoding_flag(name)
case name
when :forced_utf8_encoding then EncodingFlags::FORCED_UTF8_ENCODING
when :forced_binary_encoding then EncodingFlags::FORCED_BINARY_ENCODING
else Kernel.raise ArgumentError, "invalid EncodingFlags flag: #{name.inspect}"
end
end
# Retrieve the value of one of the IntegerBaseFlags flags.
def integer_base_flag(name)
case name
when :binary then IntegerBaseFlags::BINARY
when :decimal then IntegerBaseFlags::DECIMAL
when :octal then IntegerBaseFlags::OCTAL
when :hexadecimal then IntegerBaseFlags::HEXADECIMAL
else Kernel.raise ArgumentError, "invalid IntegerBaseFlags flag: #{name.inspect}"
end
end
# Retrieve the value of one of the InterpolatedStringNodeFlags flags.
def interpolated_string_node_flag(name)
case name
when :frozen then InterpolatedStringNodeFlags::FROZEN
when :mutable then InterpolatedStringNodeFlags::MUTABLE
else Kernel.raise ArgumentError, "invalid InterpolatedStringNodeFlags flag: #{name.inspect}"
end
end
# Retrieve the value of one of the KeywordHashNodeFlags flags.
def keyword_hash_node_flag(name)
case name
when :symbol_keys then KeywordHashNodeFlags::SYMBOL_KEYS
else Kernel.raise ArgumentError, "invalid KeywordHashNodeFlags flag: #{name.inspect}"
end
end
# Retrieve the value of one of the LoopFlags flags.
def loop_flag(name)
case name
when :begin_modifier then LoopFlags::BEGIN_MODIFIER
else Kernel.raise ArgumentError, "invalid LoopFlags flag: #{name.inspect}"
end
end
# Retrieve the value of one of the ParameterFlags flags.
def parameter_flag(name)
case name
when :repeated_parameter then ParameterFlags::REPEATED_PARAMETER
else Kernel.raise ArgumentError, "invalid ParameterFlags flag: #{name.inspect}"
end
end
# Retrieve the value of one of the ParenthesesNodeFlags flags.
def parentheses_node_flag(name)
case name
when :multiple_statements then ParenthesesNodeFlags::MULTIPLE_STATEMENTS
else Kernel.raise ArgumentError, "invalid ParenthesesNodeFlags flag: #{name.inspect}"
end
end
# Retrieve the value of one of the RangeFlags flags.
def range_flag(name)
case name
when :exclude_end then RangeFlags::EXCLUDE_END
else Kernel.raise ArgumentError, "invalid RangeFlags flag: #{name.inspect}"
end
end
# Retrieve the value of one of the RegularExpressionFlags flags.
def regular_expression_flag(name)
case name
when :ignore_case then RegularExpressionFlags::IGNORE_CASE
when :extended then RegularExpressionFlags::EXTENDED
when :multi_line then RegularExpressionFlags::MULTI_LINE
when :once then RegularExpressionFlags::ONCE
when :euc_jp then RegularExpressionFlags::EUC_JP
when :ascii_8bit then RegularExpressionFlags::ASCII_8BIT
when :windows_31j then RegularExpressionFlags::WINDOWS_31J
when :utf_8 then RegularExpressionFlags::UTF_8
when :forced_utf8_encoding then RegularExpressionFlags::FORCED_UTF8_ENCODING
when :forced_binary_encoding then RegularExpressionFlags::FORCED_BINARY_ENCODING
when :forced_us_ascii_encoding then RegularExpressionFlags::FORCED_US_ASCII_ENCODING
else Kernel.raise ArgumentError, "invalid RegularExpressionFlags flag: #{name.inspect}"
end
end
# Retrieve the value of one of the ShareableConstantNodeFlags flags.
def shareable_constant_node_flag(name)
case name
when :literal then ShareableConstantNodeFlags::LITERAL
when :experimental_everything then ShareableConstantNodeFlags::EXPERIMENTAL_EVERYTHING
when :experimental_copy then ShareableConstantNodeFlags::EXPERIMENTAL_COPY
else Kernel.raise ArgumentError, "invalid ShareableConstantNodeFlags flag: #{name.inspect}"
end
end
# Retrieve the value of one of the StringFlags flags.
def string_flag(name)
case name
when :forced_utf8_encoding then StringFlags::FORCED_UTF8_ENCODING
when :forced_binary_encoding then StringFlags::FORCED_BINARY_ENCODING
when :frozen then StringFlags::FROZEN
when :mutable then StringFlags::MUTABLE
else Kernel.raise ArgumentError, "invalid StringFlags flag: #{name.inspect}"
end
end
# Retrieve the value of one of the SymbolFlags flags.
def symbol_flag(name)
case name
when :forced_utf8_encoding then SymbolFlags::FORCED_UTF8_ENCODING
when :forced_binary_encoding then SymbolFlags::FORCED_BINARY_ENCODING
when :forced_us_ascii_encoding then SymbolFlags::FORCED_US_ASCII_ENCODING
else Kernel.raise ArgumentError, "invalid SymbolFlags flag: #{name.inspect}"
end
end
private
# The default source object that gets attached to nodes and locations if no
# source is specified.
def default_source
Source.for("")
end
# The default location object that gets attached to nodes if no location is
# specified, which uses the given source.
def default_location
Location.new(default_source, 0, 0)
end
# The default node that gets attached to nodes if no node is specified for a
# required node field.
def default_node(source, location)
MissingNode.new(source, -1, location, 0)
end
end
end
|