-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.rb
More file actions
executable file
·37 lines (34 loc) · 1.01 KB
/
main.rb
File metadata and controls
executable file
·37 lines (34 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$:.unshift File.dirname(__FILE__)
require 'FSMLParser'
require 'state_machine'
require 'validator'
require 'exceptions'
require 'visualizer'
require 'simulator'
require 'code_generator'
if ARGV.length == 0
puts "no input file passed as argument."
return
end
input = File.read(ARGV[0]);
begin
# parsing
parser = FSML::Parser.new(input)
machine = parser.to_ast()
# validation
validator = Validator.new(machine)
validator.validate()
# simluate with sample input
sample_input = ["ticket", "pass", "ticket", "pass", "ticket", "ticket", "pass", "pass", "ticket", "pass", "mute", "release", "ticket", "pass"]
simulator = Simulator.new(machine)
simulator.simulate(sample_input)
# generate ruby code for stepper and handler
generator = CodeGenerator.new(machine)
generator.generate
# print graph
visualizer = Visualizer.new(machine, ARGV[0])
visualizer.visualize()
visualizer.print_graph()
rescue Exceptions::FSMLException => e
puts "ERROR: Exception of type #{e.class.name} raised during the process!"
end