Class: C2FFI4RB::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/c2ffi4rb/parser.rb

Constant Summary collapse

TYPE_TABLE =
{
  "unsigned-int": :uint,
  "unsigned-char": :uchar,
  "unsigned-long": :ulong,
  "function-pointer": :pointer
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.



16
17
18
19
20
# File 'lib/c2ffi4rb/parser.rb', line 16

def initialize
  @struct_type = {}
  @toplevels = []
  @anon_counter = 0
end

Class Method Details

.parse(arr) ⇒ Object



12
13
14
# File 'lib/c2ffi4rb/parser.rb', line 12

def self.parse(arr)
  Parser.new.parse(arr)
end

Instance Method Details

#parse(arr) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/c2ffi4rb/parser.rb', line 22

def parse(arr)
  arr.each do |form|
    s = parse_toplevel(form)
    @toplevels << s if s
  end

  @toplevels.each do |t|
    puts
    case t
    when String
      puts "#{t}"
    when Array
      t.each do |l|
        puts "#{l}"
      end
    end
  end
end