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