Class: XDry::ParsingDriver

Inherits:
Object
  • Object
show all
Defined in:
lib/xdry/parsing/driver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(oglobal) ⇒ ParsingDriver

Returns a new instance of ParsingDriver.



15
16
17
18
19
# File 'lib/xdry/parsing/driver.rb', line 15

def initialize oglobal
  @oglobal = oglobal
  @verbose = false
  @markers = []
end

Instance Attribute Details

#markersObject (readonly)

Returns the value of attribute markers.



13
14
15
# File 'lib/xdry/parsing/driver.rb', line 13

def markers
  @markers
end

#verboseObject

Returns the value of attribute verbose.



12
13
14
# File 'lib/xdry/parsing/driver.rb', line 12

def verbose
  @verbose
end

Instance Method Details

#parse_file(file_name) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/xdry/parsing/driver.rb', line 21

def parse_file file_name
  gen = Generator.new { |g|
    file_ref = FileRef.new(file_name)
    File.open(file_name) do |file|
      new_lines_generator g, file_ref, file
    end
  }
  parse_data_in_file_scope gen
end

#parse_fragment(file_ref, lines, start_lineno, start_scope) ⇒ Object



39
40
41
42
43
44
# File 'lib/xdry/parsing/driver.rb', line 39

def parse_fragment file_ref, lines, start_lineno, start_scope
  gen = Generator.new { |g|
    new_lines_from_array_generator g, file_ref, start_lineno, lines
  }
  parse_data_in_scopes gen, start_scope.all_scopes
end

#parse_string(file_name, source) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/xdry/parsing/driver.rb', line 31

def parse_string file_name, source
  gen = Generator.new { |g|
    file_ref = TestFileRef.new(file_name, source)
    new_lines_generator g, file_ref, StringIO.new(source)
  }
  parse_data_in_file_scope gen
end