Class: Ibex::Runtime::CST::RelexResult

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/runtime/cst/incremental/relexer.rb,
sig/ibex/runtime/cst/incremental/relexer.rbs

Overview

Result of comparing one fresh lexical pass with the prior token memo.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(memo:, reused_count:, scanned_count:, resynchronized_at:) ⇒ RelexResult

Returns a new instance of RelexResult.

RBS:

  • (memo: TokenMemo, reused_count: Integer, scanned_count: Integer, resynchronized_at: Integer?) -> void

Parameters:

  • memo: (TokenMemo)
  • reused_count: (Integer)
  • scanned_count: (Integer)
  • resynchronized_at: (Integer, nil)


16
17
18
19
20
21
22
# File 'lib/ibex/runtime/cst/incremental/relexer.rb', line 16

def initialize(memo:, reused_count:, scanned_count:, resynchronized_at:)
  @memo = memo
  @reused_count = reused_count
  @scanned_count = scanned_count
  @resynchronized_at = resynchronized_at
  freeze
end

Instance Attribute Details

#memoTokenMemo (readonly)

Signature:

  • TokenMemo

Returns:



9
10
11
# File 'lib/ibex/runtime/cst/incremental/relexer.rb', line 9

def memo
  @memo
end

#resynchronized_atInteger? (readonly)

Signature:

  • Integer?

Returns:

  • (Integer, nil)


12
13
14
# File 'lib/ibex/runtime/cst/incremental/relexer.rb', line 12

def resynchronized_at
  @resynchronized_at
end

#reused_countInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


10
11
12
# File 'lib/ibex/runtime/cst/incremental/relexer.rb', line 10

def reused_count
  @reused_count
end

#scanned_countInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


11
12
13
# File 'lib/ibex/runtime/cst/incremental/relexer.rb', line 11

def scanned_count
  @scanned_count
end

Instance Method Details

#reused_ratioFloat

RBS:

  • () -> Float

Returns:

  • (Float)


25
26
27
28
29
# File 'lib/ibex/runtime/cst/incremental/relexer.rb', line 25

def reused_ratio
  return 0.0 if @memo.tokens.empty?

  @reused_count.fdiv(@memo.tokens.length)
end