# 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

#--
# rbs_inline: enabled

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]", 1, [0])
  #
  #     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.
    #
    #: (String string) -> Source
    def source(string)
      Source.for(string, 1, build_offsets(string))
    end

    # Create a new Location object.
    #
    #: (?source: Source, ?start_offset: Integer, ?length: Integer) -> Location
    def location(source: default_source, start_offset: 0, length: 0)
      Location.new(source, start_offset, length)
    end

    # Create a new AliasGlobalVariableNode node.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?new_name: (GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode), ?old_name: (GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode), ?keyword_loc: Location) -> AliasGlobalVariableNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?new_name: (SymbolNode | InterpolatedSymbolNode), ?old_name: (SymbolNode | InterpolatedSymbolNode), ?keyword_loc: Location) -> AliasMethodNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node, ?right: Prism::node, ?operator_loc: Location) -> AlternationPatternNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node, ?right: Prism::node, ?operator_loc: Location) -> AndNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: Array[Prism::node]) -> ArgumentsNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?elements: Array[Prism::node], ?opening_loc: Location?, ?closing_loc: Location?) -> ArrayNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?constant: (ConstantPathNode | ConstantReadNode)?, ?requireds: Array[Prism::node], ?rest: (ImplicitRestNode | SplatNode)?, ?posts: Array[Prism::node], ?opening_loc: Location?, ?closing_loc: Location?) -> ArrayPatternNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?key: Prism::node, ?value: Prism::node, ?operator_loc: Location?) -> AssocNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node?, ?operator_loc: Location) -> AssocSplatNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> BackReferenceReadNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?begin_keyword_loc: Location?, ?statements: StatementsNode?, ?rescue_clause: RescueNode?, ?else_clause: ElseNode?, ?ensure_clause: EnsureNode?, ?end_keyword_loc: Location?) -> BeginNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node?, ?operator_loc: Location) -> BlockArgumentNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> BlockLocalVariableNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?parameters: (BlockParametersNode | NumberedParametersNode | ItParametersNode)?, ?body: (StatementsNode | BeginNode)?, ?opening_loc: Location, ?closing_loc: Location) -> BlockNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> BlockParameterNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?parameters: ParametersNode?, ?locals: Array[BlockLocalVariableNode], ?opening_loc: Location?, ?closing_loc: Location?) -> BlockParametersNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: ArgumentsNode?, ?keyword_loc: Location) -> BreakNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?operator_loc: Location, ?value: Prism::node) -> CallAndWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?name: Symbol, ?message_loc: Location?, ?opening_loc: Location?, ?arguments: ArgumentsNode?, ?closing_loc: Location?, ?equal_loc: Location?, ?block: (BlockNode | BlockArgumentNode)?) -> CallNode
    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, equal_loc: nil, block: nil)
      CallNode.new(source, node_id, location, flags, receiver, call_operator_loc, name, message_loc, opening_loc, arguments, closing_loc, equal_loc, block)
    end

    # Create a new CallOperatorWriteNode node.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?binary_operator: Symbol, ?binary_operator_loc: Location, ?value: Prism::node) -> CallOperatorWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?operator_loc: Location, ?value: Prism::node) -> CallOrWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node, ?call_operator_loc: Location, ?name: Symbol, ?message_loc: Location) -> CallTargetNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?target: LocalVariableTargetNode, ?operator_loc: Location) -> CapturePatternNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?predicate: Prism::node?, ?conditions: Array[InNode], ?else_clause: ElseNode?, ?case_keyword_loc: Location, ?end_keyword_loc: Location) -> CaseMatchNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?predicate: Prism::node?, ?conditions: Array[WhenNode], ?else_clause: ElseNode?, ?case_keyword_loc: Location, ?end_keyword_loc: Location) -> CaseNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?class_keyword_loc: Location, ?constant_path: (ConstantReadNode | ConstantPathNode), ?inheritance_operator_loc: Location?, ?superclass: Prism::node?, ?body: (StatementsNode | BeginNode)?, ?end_keyword_loc: Location, ?name: Symbol) -> ClassNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ClassVariableAndWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> ClassVariableOperatorWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ClassVariableOrWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ClassVariableReadNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ClassVariableTargetNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> ClassVariableWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ConstantAndWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> ConstantOperatorWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ConstantOrWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?operator_loc: Location, ?value: Prism::node) -> ConstantPathAndWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?parent: Prism::node?, ?name: Symbol?, ?delimiter_loc: Location, ?name_loc: Location) -> ConstantPathNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> ConstantPathOperatorWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?operator_loc: Location, ?value: Prism::node) -> ConstantPathOrWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?parent: Prism::node?, ?name: Symbol?, ?delimiter_loc: Location, ?name_loc: Location) -> ConstantPathTargetNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?operator_loc: Location, ?value: Prism::node) -> ConstantPathWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ConstantReadNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ConstantTargetNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> ConstantWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?receiver: Prism::node?, ?parameters: ParametersNode?, ?body: (StatementsNode | BeginNode)?, ?locals: Array[Symbol], ?def_keyword_loc: Location, ?operator_loc: Location?, ?lparen_loc: Location?, ?rparen_loc: Location?, ?equal_loc: Location?, ?end_keyword_loc: Location?) -> DefNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?lparen_loc: Location?, ?value: Prism::node, ?rparen_loc: Location?, ?keyword_loc: Location) -> DefinedNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?else_keyword_loc: Location, ?statements: StatementsNode?, ?end_keyword_loc: Location?) -> ElseNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?statements: StatementsNode?, ?closing_loc: Location) -> EmbeddedStatementsNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?variable: (InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode)) -> EmbeddedVariableNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?ensure_keyword_loc: Location, ?statements: StatementsNode?, ?end_keyword_loc: Location) -> EnsureNode
    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 ErrorRecoveryNode node.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?unexpected: Prism::node?) -> ErrorRecoveryNode
    def error_recovery_node(source: default_source, node_id: 0, location: default_location, flags: 0, unexpected: nil)
      ErrorRecoveryNode.new(source, node_id, location, flags, unexpected)
    end

    # Create a new FalseNode node.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> FalseNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?constant: (ConstantPathNode | ConstantReadNode)?, ?left: SplatNode, ?requireds: Array[Prism::node], ?right: SplatNode, ?opening_loc: Location?, ?closing_loc: Location?) -> FindPatternNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node?, ?right: Prism::node?, ?operator_loc: Location) -> FlipFlopNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Float) -> FloatNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?index: (LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode), ?collection: Prism::node, ?statements: StatementsNode?, ?for_keyword_loc: Location, ?in_keyword_loc: Location, ?do_keyword_loc: Location?, ?end_keyword_loc: Location) -> ForNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> ForwardingArgumentsNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> ForwardingParameterNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?block: BlockNode?) -> ForwardingSuperNode
    def forwarding_super_node(source: default_source, node_id: 0, location: default_location, flags: 0, keyword_loc: location, block: nil)
      ForwardingSuperNode.new(source, node_id, location, flags, keyword_loc, block)
    end

    # Create a new GlobalVariableAndWriteNode node.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> GlobalVariableAndWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> GlobalVariableOperatorWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> GlobalVariableOrWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> GlobalVariableReadNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> GlobalVariableTargetNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> GlobalVariableWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?elements: Array[AssocNode | AssocSplatNode], ?closing_loc: Location) -> HashNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?constant: (ConstantPathNode | ConstantReadNode)?, ?elements: Array[AssocNode], ?rest: (AssocSplatNode | NoKeywordsParameterNode)?, ?opening_loc: Location?, ?closing_loc: Location?) -> HashPatternNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?if_keyword_loc: Location?, ?predicate: Prism::node, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?subsequent: (ElseNode | IfNode)?, ?end_keyword_loc: Location?) -> IfNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?numeric: (FloatNode | IntegerNode | RationalNode)) -> ImaginaryNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: (LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode)) -> ImplicitNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> ImplicitRestNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?pattern: Prism::node, ?statements: StatementsNode?, ?in_keyword_loc: Location, ?then_keyword_loc: Location?) -> InNode
    def in_node(source: default_source, node_id: 0, location: default_location, flags: 0, pattern: default_node(source, location), statements: nil, in_keyword_loc: location, then_keyword_loc: nil)
      InNode.new(source, node_id, location, flags, pattern, statements, in_keyword_loc, then_keyword_loc)
    end

    # Create a new IndexAndWriteNode node.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?operator_loc: Location, ?value: Prism::node) -> IndexAndWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?binary_operator: Symbol, ?binary_operator_loc: Location, ?value: Prism::node) -> IndexOperatorWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?operator_loc: Location, ?value: Prism::node) -> IndexOrWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?) -> IndexTargetNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> InstanceVariableAndWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> InstanceVariableOperatorWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> InstanceVariableOrWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> InstanceVariableReadNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> InstanceVariableTargetNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> InstanceVariableWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Integer) -> IntegerNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location) -> InterpolatedMatchLastLineNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location) -> InterpolatedRegularExpressionNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode], ?closing_loc: Location?) -> InterpolatedStringNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location?) -> InterpolatedSymbolNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location) -> InterpolatedXStringNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> ItLocalVariableReadNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> ItParametersNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?elements: Array[AssocNode | AssocSplatNode]) -> KeywordHashNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> KeywordRestParameterNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?operator_loc: Location, ?opening_loc: Location, ?closing_loc: Location, ?parameters: (BlockParametersNode | NumberedParametersNode | ItParametersNode)?, ?body: (StatementsNode | BeginNode)?) -> LambdaNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?depth: Integer) -> LocalVariableAndWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?binary_operator: Symbol, ?depth: Integer) -> LocalVariableOperatorWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?depth: Integer) -> LocalVariableOrWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?depth: Integer) -> LocalVariableReadNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?depth: Integer) -> LocalVariableTargetNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?depth: Integer, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> LocalVariableWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> MatchLastLineNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?pattern: Prism::node, ?keyword_loc: Location) -> MatchPredicateNode
    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), keyword_loc: location)
      MatchPredicateNode.new(source, node_id, location, flags, value, pattern, keyword_loc)
    end

    # Create a new MatchRequiredNode node.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?pattern: Prism::node, ?operator_loc: Location) -> MatchRequiredNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?call: CallNode, ?targets: Array[LocalVariableTargetNode]) -> MatchWriteNode
    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 ModuleNode node.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?module_keyword_loc: Location, ?constant_path: (ConstantReadNode | ConstantPathNode), ?body: (StatementsNode | BeginNode)?, ?end_keyword_loc: Location, ?name: Symbol) -> ModuleNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?lefts: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode], ?rest: (ImplicitRestNode | SplatNode)?, ?rights: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode], ?lparen_loc: Location?, ?rparen_loc: Location?) -> MultiTargetNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?lefts: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode], ?rest: (ImplicitRestNode | SplatNode)?, ?rights: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode], ?lparen_loc: Location?, ?rparen_loc: Location?, ?operator_loc: Location, ?value: Prism::node) -> MultiWriteNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: ArgumentsNode?, ?keyword_loc: Location) -> NextNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> NilNode
    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 NoBlockParameterNode node.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?keyword_loc: Location) -> NoBlockParameterNode
    def no_block_parameter_node(source: default_source, node_id: 0, location: default_location, flags: 0, operator_loc: location, keyword_loc: location)
      NoBlockParameterNode.new(source, node_id, location, flags, operator_loc, keyword_loc)
    end

    # Create a new NoKeywordsParameterNode node.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?keyword_loc: Location) -> NoKeywordsParameterNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?maximum: Integer) -> NumberedParametersNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?number: Integer) -> NumberedReferenceReadNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node) -> OptionalKeywordParameterNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> OptionalParameterNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node, ?right: Prism::node, ?operator_loc: Location) -> OrNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?requireds: Array[RequiredParameterNode | MultiTargetNode], ?optionals: Array[OptionalParameterNode], ?rest: (RestParameterNode | ImplicitRestNode)?, ?posts: Array[RequiredParameterNode | MultiTargetNode], ?keywords: Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode], ?keyword_rest: (KeywordRestParameterNode | ForwardingParameterNode | NoKeywordsParameterNode)?, ?block: (BlockParameterNode | NoBlockParameterNode)?) -> ParametersNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?body: Prism::node?, ?opening_loc: Location, ?closing_loc: Location) -> ParenthesesNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node, ?operator_loc: Location, ?lparen_loc: Location, ?rparen_loc: Location) -> PinnedExpressionNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?variable: (LocalVariableReadNode | InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | ItLocalVariableReadNode), ?operator_loc: Location) -> PinnedVariableNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?statements: StatementsNode?, ?keyword_loc: Location, ?opening_loc: Location, ?closing_loc: Location) -> PostExecutionNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?statements: StatementsNode?, ?keyword_loc: Location, ?opening_loc: Location, ?closing_loc: Location) -> PreExecutionNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?statements: StatementsNode) -> ProgramNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node?, ?right: Prism::node?, ?operator_loc: Location) -> RangeNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?numerator: Integer, ?denominator: Integer) -> RationalNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> RedoNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> RegularExpressionNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location) -> RequiredKeywordParameterNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> RequiredParameterNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node, ?keyword_loc: Location, ?rescue_expression: Prism::node) -> RescueModifierNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?exceptions: Array[Prism::node], ?operator_loc: Location?, ?reference: (LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode)?, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?subsequent: RescueNode?) -> RescueNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> RestParameterNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> RetryNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?arguments: ArgumentsNode?) -> ReturnNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> SelfNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?write: (ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode)) -> ShareableConstantNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?class_keyword_loc: Location, ?operator_loc: Location, ?expression: Prism::node, ?body: (StatementsNode | BeginNode)?, ?end_keyword_loc: Location) -> SingletonClassNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> SourceEncodingNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?filepath: String) -> SourceFileNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> SourceLineNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?expression: Prism::node?) -> SplatNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?body: Array[Prism::node]) -> StatementsNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?content_loc: Location, ?closing_loc: Location?, ?unescaped: String) -> StringNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?lparen_loc: Location?, ?arguments: ArgumentsNode?, ?rparen_loc: Location?, ?block: (BlockNode | BlockArgumentNode)?) -> SuperNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?value_loc: Location?, ?closing_loc: Location?, ?unescaped: String) -> SymbolNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> TrueNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?names: Array[SymbolNode | InterpolatedSymbolNode], ?keyword_loc: Location) -> UndefNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?unless_keyword_loc: Location, ?predicate: Prism::node, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?else_clause: ElseNode?, ?end_keyword_loc: Location?) -> UnlessNode
    def unless_node(source: default_source, node_id: 0, location: default_location, flags: 0, unless_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, unless_keyword_loc, predicate, then_keyword_loc, statements, else_clause, end_keyword_loc)
    end

    # Create a new UntilNode node.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?until_keyword_loc: Location, ?do_keyword_loc: Location?, ?end_keyword_loc: Location?, ?predicate: Prism::node, ?statements: StatementsNode?) -> UntilNode
    def until_node(source: default_source, node_id: 0, location: default_location, flags: 0, until_keyword_loc: location, do_keyword_loc: nil, end_keyword_loc: nil, predicate: default_node(source, location), statements: nil)
      UntilNode.new(source, node_id, location, flags, until_keyword_loc, do_keyword_loc, end_keyword_loc, predicate, statements)
    end

    # Create a new WhenNode node.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?when_keyword_loc: Location, ?conditions: Array[Prism::node], ?then_keyword_loc: Location?, ?statements: StatementsNode?) -> WhenNode
    def when_node(source: default_source, node_id: 0, location: default_location, flags: 0, when_keyword_loc: location, conditions: [], then_keyword_loc: nil, statements: nil)
      WhenNode.new(source, node_id, location, flags, when_keyword_loc, conditions, then_keyword_loc, statements)
    end

    # Create a new WhileNode node.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?while_keyword_loc: Location, ?do_keyword_loc: Location?, ?end_keyword_loc: Location?, ?predicate: Prism::node, ?statements: StatementsNode?) -> WhileNode
    def while_node(source: default_source, node_id: 0, location: default_location, flags: 0, while_keyword_loc: location, do_keyword_loc: nil, end_keyword_loc: nil, predicate: default_node(source, location), statements: nil)
      WhileNode.new(source, node_id, location, flags, while_keyword_loc, do_keyword_loc, end_keyword_loc, predicate, statements)
    end

    # Create a new XStringNode node.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> XStringNode
    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.
    #
    #: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?lparen_loc: Location?, ?arguments: ArgumentsNode?, ?rparen_loc: Location?) -> YieldNode
    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.
    #
    #: (Symbol name) -> Integer
    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.
    #
    #: (Symbol name) -> Integer
    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.
    #
    #: (Symbol name) -> Integer
    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.
    #
    #: (Symbol name) -> Integer
    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.
    #
    #: (Symbol name) -> Integer
    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.
    #
    #: (Symbol name) -> Integer
    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.
    #
    #: (Symbol name) -> Integer
    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.
    #
    #: (Symbol name) -> Integer
    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.
    #
    #: (Symbol name) -> Integer
    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.
    #
    #: (Symbol name) -> Integer
    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.
    #
    #: (Symbol name) -> Integer
    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.
    #
    #: (Symbol name) -> Integer
    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.
    #
    #: (Symbol name) -> Integer
    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.
    #
    #: (Symbol name) -> Integer
    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.
    #
    #: (Symbol name) -> Integer
    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.
    #
    #: () -> Source
    def default_source
      Source.for("", 1, [0])
    end

    # The default location object that gets attached to nodes if no location is
    # specified, which uses the given source.
    #
    #: () -> Location
    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.
    #
    #: (Source source, Location location) -> node
    def default_node(source, location)
      ErrorRecoveryNode.new(source, -1, location, 0, nil)
    end

    private

    # Build the newline byte offset array for the given source string.
    #
    #: (String source) -> Array[Integer]
    def build_offsets(source)
      offsets = [0]
      start = 0
      while (index = source.byteindex("\n", start))
        offsets << (start = index + 1)
      end
      offsets
    end
  end
end
