Class: Rley::ParseRep::ParseRepCreator
- Inherits:
-
Object
- Object
- Rley::ParseRep::ParseRepCreator
- Defined in:
- lib/rley/parse_rep/parse_rep_creator.rb
Overview
Utility class that helps to create a representation of a parse from a given Parsing object.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#parsing ⇒ Rley::Parser::GFGParsing
readonly
Link to Parsing object (= results of recognizer).
Instance Method Summary collapse
-
#create(aBuilder = nil) ⇒ Rley::PTree::ParseTree, Rley::SPPF::ParseForest
Factory method that produces the representation of the parse.
-
#initialize(aParsingResult) ⇒ ParseRepCreator
constructor
Constructor.
Constructor Details
#initialize(aParsingResult) ⇒ ParseRepCreator
Constructor. Creates and initialize a ParseRepCreator instance.
16 17 18 |
# File 'lib/rley/parse_rep/parse_rep_creator.rb', line 16 def initialize(aParsingResult) @parsing = aParsingResult end |
Instance Attribute Details
#parsing ⇒ Rley::Parser::GFGParsing (readonly)
Returns Link to Parsing object (= results of recognizer).
12 13 14 |
# File 'lib/rley/parse_rep/parse_rep_creator.rb', line 12 def parsing @parsing end |
Instance Method Details
#create(aBuilder = nil) ⇒ Rley::PTree::ParseTree, Rley::SPPF::ParseForest
Factory method that produces the representation of the parse.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# 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. =~ /^Ambiguous/ $stderr.puts parsing end raise e end a_builder.done! a_builder.result end |