Class: Rattler::Runtime::PackratParser

Inherits:
RecursiveDescentParser show all
Defined in:
lib/rattler/runtime/packrat_parser.rb

Overview

A PackratParser is a recursive descent parser that memoizes the results of applying nonterminal rules so that each rule method is invoked at most once at a given parse position.

Direct Known Subclasses

ExtendedPackratParser

Defined Under Namespace

Classes: MemoEntry

Instance Attribute Summary

Attributes inherited from Parser

#source

Instance Method Summary collapse

Methods inherited from RecursiveDescentParser

#match, #method_missing, #respond_to?

Methods included from ParserHelper

#select_captures

Methods inherited from Parser

#fail, #fail!, #fail_parse, #failure, #failure?, #parse, #parse!, parse!, #parse_fully, #parse_fully!, parse_fully!, #pos, #pos=

Methods inherited from Util::Node

#==, #[], [], #attrs, #can_equal?, #child, #children, #each, #empty?, #eql?, #inspect, #method_missing, #name, #pretty_print, #pretty_print_cycle, #respond_to?, #same_contents?, #to_graphviz, #with_attrs, #with_attrs!, #with_children

Constructor Details

#initialize(source, options = {}) ⇒ PackratParser

Create a new packrat parser to parse source.

Parameters:

  • source (String)

    the source to parse

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :tab_size (Integer) — default: 8

    tab size to use to calculate column numbers



15
16
17
18
# File 'lib/rattler/runtime/packrat_parser.rb', line 15

def initialize(source, options={})
  super
  @memo = Hash.new {|h, match_method_name| h[match_method_name] = {} }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rattler::Runtime::RecursiveDescentParser