rubyx/lib/mom/statement.rb

27 lines
522 B
Ruby
Raw Normal View History

module Mom
class Statement
# flattening will change the structure from a tree to a linked list (and use
2017-09-08 12:12:24 +02:00
# nekst to do so)
def flatten
raise "not implemented for #{self}"
end
end
class Statements < Statement
include Common::Statements
2017-09-08 12:12:24 +02:00
def flatten( options = {} )
flat = @statements.pop.flatten
while( nekst = @statements.pop )
flat.append nekst.flatten()
end
flat
end
2017-09-08 12:12:24 +02:00
end
end
require_relative "if_statement"
require_relative "while_statement"