Class: FFI::Clang::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/ffi/clang/token.rb

Overview

Represents a single token in the source code.

Instance Method Summary collapse

Constructor Details

#initialize(token, translation_unit) ⇒ Token

Initialize a token.



76
77
78
79
# File 'lib/ffi/clang/token.rb', line 76

def initialize(token, translation_unit)
  @token = token
  @translation_unit = translation_unit
end

Instance Method Details

#extentObject

Get the extent (source range) of this token.



101
102
103
# File 'lib/ffi/clang/token.rb', line 101

def extent
  SourceRange.new Lib.get_token_extent(@translation_unit, @token)
end

#kindObject

Get the kind of this token.



83
84
85
# File 'lib/ffi/clang/token.rb', line 83

def kind
  Lib.get_token_kind(@token)
end

#locationObject

Get the location of this token.



95
96
97
# File 'lib/ffi/clang/token.rb', line 95

def location
  ExpansionLocation.new Lib.get_token_location(@translation_unit, @token)
end

#spellingObject

Get the spelling (text) of this token.



89
90
91
# File 'lib/ffi/clang/token.rb', line 89

def spelling
  Lib.extract_string Lib.get_token_spelliing(@translation_unit, @token)
end