From 48a9d9c1f0120b1d2d54b29749600fb98d10729a Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 15 Mar 2008 10:16:20 +0100 Subject: [PATCH] biglot: generic class for polyglots with two glots and a set of transitions --- ext/ohcount_native/glots/biglot.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 ext/ohcount_native/glots/biglot.rb diff --git a/ext/ohcount_native/glots/biglot.rb b/ext/ohcount_native/glots/biglot.rb new file mode 100644 index 0000000..b067930 --- /dev/null +++ b/ext/ohcount_native/glots/biglot.rb @@ -0,0 +1,22 @@ +require 'polyglot' + +module Ohcount + # Generic "two languages" polyglot + class Biglot < Polyglot + + # A Biglot is defined by its name, the first language, the second language, and an array of transitions + # Each transition is specified as an array of parameters to initialize a StitchTransition + def initialize(name, lang1, lang2, states, trans) + @name = name + + @states = (lang1.all_states rescue lang1.states) + (lang2.all_states rescue lang2.states) + @extra_states = [] + + @transitions = (lang1.all_transitions rescue lang1.transitions) + (lang2.all_transitions rescue lang2.transitions) + @extra_transitions = [] + + states.each { |ar| @extra_states << State.new(*ar) } + trans.each { |ar| @extra_transitions << StitchTransition.new(*ar) } + end + end +end -- 2.32.0.93.g670b81a890