Class: Flexr::Codegen::Direct

Inherits:
Table show all
Defined in:
lib/flexr/codegen/direct.rb

Instance Attribute Summary

Attributes inherited from Base

#compiled

Instance Method Summary collapse

Methods inherited from Table

#header, #source

Methods inherited from Base

#initialize, #stats

Constructor Details

This class inherits a constructor from Flexr::Codegen::Base

Instance Method Details

#generate(state: :initial) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/flexr/codegen/direct.rb', line 6

def generate(state: :initial)
  dfa = compiled.machines.fetch(state).dfa
  {
    nxt: dfa.transitions.flatten.map { |value| value || -1 }.freeze,
    classes: dfa.class_count
  }.freeze
end