Ruby/nfa2dfa

DESCRIPTION

Finite automaton determinizer as semestral project for MI-RUB on CVUT-FIT

SYNOPSIS

A basic example with reading file from standart input

require 'nfa2dfa'
ARGV.each do |arg|
  input_mat = Nfa2Dfa::Automaton.init(arg)
  if input_mat != NIL
    #puts input_mat.to_str
    input_mat.to_graph(arg + ".png")
    if input_mat.deterministic? 
      puts "Is DKA"
    else
      puts "Is NKA, going to create DKA"
      puts ""
      output_mat = input_mat.determine
      output_mat.to_graph(arg + "determined.png")
    end
  end
end

Command line usage

nfa2dfa create_deterministic automat_file_path

or

nfa2dfa automaton_to_png automat_file_path

Automaton definiton file syntax

<state1> <state2> ...
<alphabet1> <alpbabet2> ...
<stateX>-<alphabetX>-<stateX> <stateX>-<alphabetX>-<stateX> ...
<initial_state>
<final_state1> <final_state2> ...

INSTALLATION

gem install nfa2dfa

or

(1) Create your Gemfile

source 'https://rubygems.org'
gem 'ruby-graphviz'
gem "nfa2dfa", "~> 1.0.2"

(2) Install necessary gems

bundle install

This gem uses gem Ruby-Graphviz.

Therefore you also need to install GraphViz