Class: RedSnow::ParseResult

Inherits:
Object
  • Object
show all
Defined in:
lib/redsnow/parseresult.rb

Overview

Parse Result

See Also:

Constant Summary

VERSION_KEY =

Version key

:_version
SUPPORTED_VERSIONS =

Supported version of Api Blueprint

["2.0"]

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (ParseResult) initialize(result_handle)

Returns a new instance of ParseResult

Parameters:

  • result_handle (FFI::Pointer)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/redsnow/parseresult.rb', line 19

def initialize(result_handle)

  warnings = RedSnow::Binding.sc_warnings_handler(result_handle)
  warningsSize = RedSnow::Binding.sc_warnings_size(warnings)
  @warnings = Array.new
  for index in 0..(warningsSize - 1) do
    sc_warning_handler = RedSnow::Binding.sc_warning_handler(warnings, index)

    warning = Hash.new
    warning[:message] = RedSnow::Binding.sc_warning_message(sc_warning_handler)
    warning[:code] = RedSnow::Binding.sc_warning_code(sc_warning_handler)
    warning[:ok] = RedSnow::Binding.sc_warning_ok(sc_warning_handler)

    sc_location_handler = RedSnow::Binding.sc_location_handler(sc_warning_handler)
    sc_location_size = RedSnow::Binding.sc_location_size(sc_location_handler)
    warning[:location] = Array.new
    if sc_location_size > 0
      for index in 0..(sc_location_size - 1)
        location = Location.new(sc_location_handler, index)
        warning[:location] << location
      end
    end
    @warnings << warning
  end

  error_handler = RedSnow::Binding.sc_error_handler(result_handle)
  @error = Hash.new
  @error[:message] = RedSnow::Binding.sc_error_message(error_handler)
  @error[:code] = RedSnow::Binding.sc_error_code(error_handler)
  @error[:ok] = RedSnow::Binding.sc_error_ok(error_handler)

  sc_location_handler = RedSnow::Binding.sc_location_handler(error_handler)
  sc_location_size = RedSnow::Binding.sc_location_size(sc_location_handler)
  @error[:location] = Array.new
  if sc_location_size > 0
    for index in 0..(sc_location_size - 1) do
      location = Location.new(sc_location_handler, index)
      @error[:location] << location
    end
  end
end

Instance Attribute Details

- (Object) ast

Returns the value of attribute ast



9
10
11
# File 'lib/redsnow/parseresult.rb', line 9

def ast
  @ast
end

- (Object) error

Returns the value of attribute error



10
11
12
# File 'lib/redsnow/parseresult.rb', line 10

def error
  @error
end

- (Object) warnings

Returns the value of attribute warnings



11
12
13
# File 'lib/redsnow/parseresult.rb', line 11

def warnings
  @warnings
end