start conditionals
This commit is contained in:
@ -59,9 +59,62 @@ module Ast
|
||||
end
|
||||
end
|
||||
|
||||
class TypedName < NameExpression
|
||||
attr_reader :type
|
||||
def initialize type , name
|
||||
super(name)
|
||||
@type = type.to_sym
|
||||
end
|
||||
def attributes
|
||||
[:type, :name]
|
||||
end
|
||||
def inspect
|
||||
"#{self.class.name}.new(#{type.inspect},#{name.inspect})"
|
||||
end
|
||||
def to_s
|
||||
inspect
|
||||
end
|
||||
end
|
||||
|
||||
class VariableDefinition < TypedName
|
||||
attr_reader :right
|
||||
|
||||
def initialize type , name , right
|
||||
super(type , name)
|
||||
@right = right
|
||||
end
|
||||
def attributes
|
||||
super + [:right]
|
||||
end
|
||||
def inspect
|
||||
self.class.name + ".new(" + type.inspect + "," + name.inspect + "," + right.inspect + ")"
|
||||
end
|
||||
def to_s
|
||||
inspect
|
||||
end
|
||||
end
|
||||
|
||||
class VariableExpression < NameExpression
|
||||
end
|
||||
|
||||
class AssignmentExpression < NameExpression
|
||||
attr_reader :right
|
||||
|
||||
def initialize name, right
|
||||
super(name)
|
||||
@right = right
|
||||
end
|
||||
def attributes
|
||||
super + [:right]
|
||||
end
|
||||
def inspect
|
||||
self.class.name + ".new(" + name.inspect + "," + right.inspect + ")"
|
||||
end
|
||||
def to_s
|
||||
"#{left} = #{right}"
|
||||
end
|
||||
end
|
||||
|
||||
class ModuleName < NameExpression
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
module Ast
|
||||
|
||||
|
||||
class OperatorExpression < Expression
|
||||
attr_reader :operator, :left, :right
|
||||
|
||||
@ -10,28 +10,11 @@ module Ast
|
||||
[:operator, :left, :right]
|
||||
end
|
||||
def inspect
|
||||
self.class.name + ".new(" + operator.inspect + ", " + left.inspect + "," + right.inspect + ")"
|
||||
self.class.name + ".new(" + operator.inspect + ", " + left.inspect + "," + right.inspect + ")"
|
||||
end
|
||||
def to_s
|
||||
"#{left} #{operator} #{right}"
|
||||
end
|
||||
end
|
||||
|
||||
class AssignmentExpression < Expression
|
||||
attr_reader :left, :right
|
||||
|
||||
def initialize left, right
|
||||
@left, @right = left, right
|
||||
end
|
||||
def attributes
|
||||
[:left, :right]
|
||||
end
|
||||
def inspect
|
||||
self.class.name + ".new(" + left.inspect + "," + right.inspect + ")"
|
||||
end
|
||||
def to_s
|
||||
"#{left} = #{right}"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user