Class: TreeHaver::Backends::Parslet::Tree Private

Inherits:
TreeHaver::Base::Tree show all
Defined in:
lib/tree_haver/backends/parslet.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Parslet tree wrapper

Wraps Parslet parse results (Hash/Array/Slice) to provide
tree-sitter-compatible API.

Inherits from Base::Tree to get shared methods like #errors, #warnings,
#comments, #has_error?, and #inspect.

Instance Attribute Summary collapse

Attributes inherited from TreeHaver::Base::Tree

#inner_tree, #lines, #source

Instance Method Summary collapse

Methods inherited from TreeHaver::Base::Tree

#comments, #edit, #errors, #has_error?, #inspect, #warnings

Constructor Details

#initialize(parslet_result, source) ⇒ Tree

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Tree.



304
305
306
307
# File 'lib/tree_haver/backends/parslet.rb', line 304

def initialize(parslet_result, source)
  @parslet_result = parslet_result
  super(parslet_result, source: source)
end

Instance Attribute Details

#parslet_resultHash, ... (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The raw Parslet parse result

Returns:

  • (Hash, Array, Parslet::Slice)

    The parse result



302
303
304
# File 'lib/tree_haver/backends/parslet.rb', line 302

def parslet_result
  @parslet_result
end

Instance Method Details

#root_nodeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



309
310
311
# File 'lib/tree_haver/backends/parslet.rb', line 309

def root_node
  Node.new(@parslet_result, @source, type: "document")
end