Class: Rly::PlyDump

Inherits:
Object
  • Object
show all
Defined in:
lib/rly/parse/ply_dump.rb

Defined Under Namespace

Classes: TinyContext

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(grammar) ⇒ PlyDump


10
11
12
13
14
15
16
17
# File 'lib/rly/parse/ply_dump.rb', line 10

def initialize(grammar)
  @grammar = grammar
  @backlog = ""
  if grammar
    @t = Rly::LRTable.new(grammar)
    @t.parse_table(self)
  end
end

Instance Attribute Details

#backlogObject (readonly)

Returns the value of attribute backlog


8
9
10
# File 'lib/rly/parse/ply_dump.rb', line 8

def backlog
  @backlog
end

Class Method Details

.stubObject


25
26
27
# File 'lib/rly/parse/ply_dump.rb', line 25

def self.stub
  PlyDump.new(nil)
end

Instance Method Details

#debug(*args) ⇒ Object


34
35
36
37
# File 'lib/rly/parse/ply_dump.rb', line 34

def debug(*args)
  s = sprintf(*args)
  @backlog += s + "\n"
end

#info(*args) ⇒ Object


29
30
31
32
# File 'lib/rly/parse/ply_dump.rb', line 29

def info(*args)
  s = sprintf(*args)
  @backlog += s + "\n"
end

#to_sObject


19
20
21
22
23
# File 'lib/rly/parse/ply_dump.rb', line 19

def to_s
  fn = File.join(File.dirname(__FILE__), '..', '..', '..', 'assets', 'ply_dump.erb')
  e = ERB.new(open(fn).read)
  e.result(TinyContext.new(g: @grammar, backlog: @backlog, ver: Rly::VERSION).get_binding)
end