Class: Parslet::Atoms::Rule::Position::LR

Inherits:
Struct
  • Object
show all
Defined in:
lib/parslet/atoms/rule/position.rb

Overview

A LR is info holder for left recursion

seed: the last left recursion exp parse result
rule: the rule starting left recursion
head: when left recursion detected, head holds info to re-eval involved rules

Defined Under Namespace

Classes: Head

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#headObject

Returns the value of attribute head

Returns:

  • (Object)

    the current value of head



11
12
13
# File 'lib/parslet/atoms/rule/position.rb', line 11

def head
  @head
end

#posObject

Returns the value of attribute pos

Returns:

  • (Object)

    the current value of pos



11
12
13
# File 'lib/parslet/atoms/rule/position.rb', line 11

def pos
  @pos
end

#ruleObject

Returns the value of attribute rule

Returns:

  • (Object)

    the current value of rule



11
12
13
# File 'lib/parslet/atoms/rule/position.rb', line 11

def rule
  @rule
end

#seedObject Also known as: answer

Returns the value of attribute seed

Returns:

  • (Object)

    the current value of seed



11
12
13
# File 'lib/parslet/atoms/rule/position.rb', line 11

def seed
  @seed
end

Instance Method Details

#detected?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/parslet/atoms/rule/position.rb', line 32

def detected?
  self.head != nil
end

#setup_for_re_eval_involved_rules(lr_stack) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/parslet/atoms/rule/position.rb', line 36

def setup_for_re_eval_involved_rules(lr_stack)
  self.head ||= Head.new(rule, [], [])
  lr_stack.top_down do |lr|
    return if lr.head == self.head
    lr.head = self.head
    self.head.involved_rules.push lr.rule
  end
end