class Rley::ParseRep::ParseRepCreator
Utility class that helps to create a representation of a parse from a given Parsing object.
Attributes
@return [Rley::Parser::GFGParsing]
Link to Parsing object (= results of recognizer)
Public Class Methods
Source
# File lib/rley/parse_rep/parse_rep_creator.rb, line 16 def initialize(aParsingResult) @parsing = aParsingResult end
Constructor. Creates and initialize a ParseRepCreator
instance. @return [ParseRepCreator]
Public Instance Methods
Source
# File lib/rley/parse_rep/parse_rep_creator.rb, line 23 def create(aBuilder = nil) a_walker = walker(parsing) a_builder = builder(parsing, aBuilder) begin loop do event = a_walker.next # puts "EVENT #{event[0]} #{event[1]}" a_builder.receive_event(*event) end rescue StopIteration # Do nothing: gobble the exception rescue StandardError => e if e.message =~ /^Ambiguous/ $stderr.puts parsing end raise e end a_builder.done! a_builder.result end
Factory method that produces the representation of the parse. @return [Rley::PTree::ParseTree, Rley::SPPF::ParseForest
]
The parse representation.
Private Instance Methods
Source
# File lib/rley/parse_rep/parse_rep_creator.rb, line 61 def jump_to_start false end
By default, when a end vertex is re-visited don’t jump its corresponding start vertex.
Source
# File lib/rley/parse_rep/parse_rep_creator.rb, line 52 def walker(aParseResult) walker_factory = Parser::ParseWalkerFactory.new accept_entry = aParseResult.accepting_entry accept_index = aParseResult.chart.last_index walker_factory.build_walker(accept_entry, accept_index, jump_to_start) end
Create a Parsing walker, that is, an object that will iterate over the relevant nodes (= parsing entries) of a GFGParsing