Class: BitClust::Preprocessor

Inherits:
LineFilter show all
Defined in:
lib/bitclust/preprocessor.rb

Overview

Handle pragmas like #@todo, #@include, #@since, etc.

Defined Under Namespace

Classes: State

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LineFilter

#each, #gets

Methods included from ParseUtils

#parse_error

Constructor Details

#initialize(f, params = {}) ⇒ Preprocessor

Returns a new instance of Preprocessor.



68
69
70
71
72
73
# File 'lib/bitclust/preprocessor.rb', line 68

def initialize(f, params = {})
  super f
  @params = params
  @last_if = nil
  cond_init
end

Class Method Details

.process(path, params = {}) ⇒ Object



58
59
60
61
62
# File 'lib/bitclust/preprocessor.rb', line 58

def Preprocessor.process(path, params = {})
  fopen(path, 'r:UTF-8') {|f|
    return wrap(f, params).to_a
  }
end

.read(path, params = {}) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/bitclust/preprocessor.rb', line 45

def self.read(path, params = {})
  if path.respond_to?(:gets)
    io = wrap(path, params)
  else
    io = wrap(fopen(path, 'r:UTF-8'), params)
  end
  ret = +""
  while s = io.gets
    ret << s
  end
  ret
end

.wrap(f, params = {}) ⇒ Object



64
65
66
# File 'lib/bitclust/preprocessor.rb', line 64

def Preprocessor.wrap(f, params = {})
  new(LineStream.new(f), params)
end

Instance Method Details

#pathObject



75
76
77
# File 'lib/bitclust/preprocessor.rb', line 75

def path
  @f.path if @f.respond_to?(:path)
end