Class: BitClust::Preprocessor

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

Overview

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

bitclust#285: prefix は #% が正式(GitHub が #@since 等の @英字 を ユーザー mention として解釈してしまうため)。旧 prefix #@ も、凍結タグ (frozen-*)の旧ソースを再取込する場合に備えて引き続き受け付ける。

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.



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

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

Class Method Details

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



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/bitclust/preprocessor.rb', line 50

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

Instance Method Details

#pathObject



81
82
83
# File 'lib/bitclust/preprocessor.rb', line 81

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