Class: StackPath

Inherits:
Object show all
Defined in:
lib/rpdf2txt-rockit/glr_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, links = []) ⇒ StackPath

Returns a new instance of StackPath.



368
369
370
371
# File 'lib/rpdf2txt-rockit/glr_parser.rb', line 368

def initialize(from, links = [])
  @from, @links = from, Array.new
  links.each {|link| self.add_link(link)}
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



365
366
367
# File 'lib/rpdf2txt-rockit/glr_parser.rb', line 365

def from
  @from
end

Returns the value of attribute links.



366
367
368
# File 'lib/rpdf2txt-rockit/glr_parser.rb', line 366

def links
  @links
end

#toObject (readonly)

Returns the value of attribute to.



365
366
367
# File 'lib/rpdf2txt-rockit/glr_parser.rb', line 365

def to
  @to
end

Instance Method Details



373
374
375
376
# File 'lib/rpdf2txt-rockit/glr_parser.rb', line 373

def add_link(link)
  @links.push link
  @to = link.stack
end

#add_path(aStackPath) ⇒ Object



378
379
380
381
382
# File 'lib/rpdf2txt-rockit/glr_parser.rb', line 378

def add_path(aStackPath)
  @links.concat aStackPath.links
  @to = @links.last.stack
  self
end

#includes_link?(link) ⇒ Boolean

Returns:

  • (Boolean)


384
385
386
# File 'lib/rpdf2txt-rockit/glr_parser.rb', line 384

def includes_link?(link)
  @links.detect {|l| l==link}
end

#inspectObject



388
389
390
391
# File 'lib/rpdf2txt-rockit/glr_parser.rb', line 388

def inspect
  "#{from.state}(#{from.lexer.position.char_position}) " +
    @links.map {|l| "-#{l.tree.inspect}-> #{l.stack.state} (#{l.stack.lexer.position.char_position}) "}.join
end