A transition in a Pushdown
automaton
The name of the transition; mostly for human consumption
Inheritance hook – enable instantiation.
# File lib/pushdown/transition.rb, line 28
def self::inherited( subclass )
super
subclass.public_class_method( :new )
if (( type_name = subclass.name&.sub( /.*::/, '' )&.downcase ))
Pushdown::State.register_transition( type_name )
end
end
Create a new Transition
with the given name
.
# File lib/pushdown/transition.rb, line 38
def initialize( name )
@name = name
end
Return a state stack
after the transition has been applied.
# File lib/pushdown/transition.rb, line 53
def apply( stack )
raise NotImplementedError, "%p doesn't implement required method #%p" %
[ self.class, __method__ ]
end
Return the transition's type as a lowercase Symbol, such as that specified in transition declarations.
# File lib/pushdown/transition.rb, line 61
def type_name
class_name = self.class.name or return :anonymous
return class_name.sub( /.*::/, '' ).downcase.to_sym
end