class Parslet::Parser

Public Class Methods

from_hash(hash) click to toggle source

This turns a Hash into a Parslet::Parser

# File lib/parslet-export/parser.rb, line 12
def self.from_hash(hash)
  new.tap do |parser|
    # Parsers have to have a #root method
    parser.define_singleton_method(hash["atom"]) do
      hash["parslet"].to_parslet
    end
  end
end

Public Instance Methods

to_hash() click to toggle source

This turns a Parslet::Parser into a Hash

# File lib/parslet-export/parser.rb, line 4
def to_hash
  {
    "atom" => "root",
    "parslet" => root.to_hash
  }
end