FFI::ClangSourceFFIClangToken

class Token

Represents a single token in the source code.

Definitions

def initialize(token, translation_unit)

Initialize a token.

Signature

parameter token FFI::Pointer

The token pointer.

parameter translation_unit TranslationUnit

The parent translation unit.

Implementation

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

def kind

Get the kind of this token.

Signature

returns Symbol

The token kind.

Implementation

def kind
	Lib.get_token_kind(@token)
end

def spelling

Get the spelling (text) of this token.

Signature

returns String

The token spelling.

Implementation

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

def location

Get the location of this token.

Signature

returns ExpansionLocation

The token location.

Implementation

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

def extent

Get the extent (source range) of this token.

Signature

returns SourceRange

The token extent.

Implementation

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