small fixes, wown parse for class test
This commit is contained in:
parent
83d4ce55ca
commit
1cff296ab5
@ -27,7 +27,7 @@ module Ast
|
|||||||
#puts "compiled expression #{expression_value.inspect}"
|
#puts "compiled expression #{expression_value.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return clazz
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ module Fragments
|
|||||||
expr = part.compile( @object_space.context , @object_space.main )
|
expr = part.compile( @object_space.context , @object_space.main )
|
||||||
else
|
else
|
||||||
expr = part.compile( @object_space.context , nil )
|
expr = part.compile( @object_space.context , nil )
|
||||||
raise "should be function definition for now" unless expr.is_a? Vm::Function
|
raise "should be function definition for now, not #{part.inspect}#{expr.inspect}" unless expr.is_a? Vm::Function
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -20,10 +20,13 @@ class String
|
|||||||
def length()
|
def length()
|
||||||
return @length
|
return @length
|
||||||
end
|
end
|
||||||
|
def self.new_string( len )
|
||||||
|
4
|
||||||
|
end
|
||||||
def plus(str)
|
def plus(str)
|
||||||
my_length = @length
|
my_length = @length
|
||||||
str_len = str.length()
|
str_len = str.length()
|
||||||
new_string = String.new(my_length + str_len)
|
new_string = String.new_string(my_length + str_len)
|
||||||
i = 0
|
i = 0
|
||||||
while( i < my_length) do
|
while( i < my_length) do
|
||||||
char = self.get(i)
|
char = self.get(i)
|
||||||
@ -45,5 +48,22 @@ HERE
|
|||||||
parse
|
parse
|
||||||
write "class"
|
write "class"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def parse
|
||||||
|
parser = Parser::Crystal.new
|
||||||
|
syntax = parser.parse_with_debug(@string_input)
|
||||||
|
parts = Parser::Transform.new.apply(syntax)
|
||||||
|
# file is a list of expressions, all but the last must be a function
|
||||||
|
# and the last is wrapped as a main
|
||||||
|
parts.each_with_index do |part,index|
|
||||||
|
if index == (parts.length - 1)
|
||||||
|
expr = part.compile( @object_space.context , @object_space.main )
|
||||||
|
else
|
||||||
|
expr = part.compile( @object_space.context , nil )
|
||||||
|
raise "should be function definition for now, not #{part.inspect}#{expr.inspect}" unless expr.is_a? Vm::BootClass
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user