Class: Ibex::Runtime::CST::RelexResult
- Inherits:
-
Object
- Object
- Ibex::Runtime::CST::RelexResult
- 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
- #memo ⇒ TokenMemo readonly
- #resynchronized_at ⇒ Integer? readonly
- #reused_count ⇒ Integer readonly
- #scanned_count ⇒ Integer readonly
Instance Method Summary collapse
-
#initialize(memo:, reused_count:, scanned_count:, resynchronized_at:) ⇒ RelexResult
constructor
A new instance of RelexResult.
- #reused_ratio ⇒ Float
Constructor Details
#initialize(memo:, reused_count:, scanned_count:, resynchronized_at:) ⇒ RelexResult
Returns a new instance of RelexResult.
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
#memo ⇒ TokenMemo (readonly)
9 10 11 |
# File 'lib/ibex/runtime/cst/incremental/relexer.rb', line 9 def memo @memo end |
#resynchronized_at ⇒ Integer? (readonly)
12 13 14 |
# File 'lib/ibex/runtime/cst/incremental/relexer.rb', line 12 def resynchronized_at @resynchronized_at end |
#reused_count ⇒ Integer (readonly)
10 11 12 |
# File 'lib/ibex/runtime/cst/incremental/relexer.rb', line 10 def reused_count @reused_count end |
#scanned_count ⇒ Integer (readonly)
11 12 13 |
# File 'lib/ibex/runtime/cst/incremental/relexer.rb', line 11 def scanned_count @scanned_count end |
Instance Method Details
#reused_ratio ⇒ 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 |