2017-09-06 11:33:46 +02:00
|
|
|
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)
|
2017-09-06 11:33:46 +02:00
|
|
|
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
|
2017-09-06 11:33:46 +02:00
|
|
|
end
|
2017-09-08 12:12:24 +02:00
|
|
|
|
2017-09-06 11:33:46 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
require_relative "if_statement"
|
|
|
|
require_relative "while_statement"
|