2014-05-05 09:02:02 +02:00
|
|
|
# abstract syntax tree (ast)
|
|
|
|
# This Layer is semi automagically created by parslet using the transform
|
|
|
|
|
|
|
|
# It in turn is responsible for the transformation to the next layer, vm code
|
|
|
|
|
|
|
|
# This happens in the compile function which must return a Vm::Code derivative
|
|
|
|
|
|
|
|
# PS: compare is only for tests and should be factored out to there
|
|
|
|
|
2014-05-05 08:51:16 +02:00
|
|
|
module Ast
|
2014-04-24 16:38:06 +02:00
|
|
|
class Expression
|
2014-05-29 14:57:33 +02:00
|
|
|
def compile context , into
|
2014-05-05 09:02:02 +02:00
|
|
|
raise "abstract #{self}"
|
|
|
|
end
|
2014-05-13 15:24:19 +02:00
|
|
|
def compile context , into
|
2014-05-05 09:02:02 +02:00
|
|
|
raise "abstract #{self}"
|
2014-04-24 16:38:06 +02:00
|
|
|
end
|
2014-05-10 11:54:10 +02:00
|
|
|
def attributes
|
|
|
|
raise "abstract #{self}"
|
|
|
|
end
|
|
|
|
def == other
|
2014-04-29 15:22:12 +02:00
|
|
|
return false unless other.class == self.class
|
2014-04-28 15:07:34 +02:00
|
|
|
attributes.each do |a|
|
|
|
|
left = send(a)
|
2014-05-29 14:57:33 +02:00
|
|
|
right = other.send(a)
|
2014-04-28 15:07:34 +02:00
|
|
|
return false unless left.class == right.class
|
|
|
|
return false unless left == right
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
2014-04-24 16:38:06 +02:00
|
|
|
end
|
|
|
|
|
2014-04-24 14:43:20 +02:00
|
|
|
end
|
2014-05-05 09:02:02 +02:00
|
|
|
|
|
|
|
require_relative "basic_expressions"
|
2014-05-29 14:57:33 +02:00
|
|
|
require_relative "call_site_expression"
|
2014-05-12 20:36:38 +02:00
|
|
|
require_relative "compound_expressions"
|
2014-05-24 09:18:54 +02:00
|
|
|
require_relative "if_expression"
|
2014-05-05 09:02:02 +02:00
|
|
|
require_relative "function_expression"
|
2014-05-29 14:57:33 +02:00
|
|
|
require_relative "module_expression"
|
2014-05-10 18:02:51 +02:00
|
|
|
require_relative "operator_expressions"
|
2014-05-29 14:57:33 +02:00
|
|
|
require_relative "return_expression"
|
|
|
|
require_relative "while_expression"
|