start on vool, the virtual oo language

start with syntax tree, not linked into existing code until finished
This commit is contained in:
Torsten Ruger
2017-04-01 15:57:39 +03:00
parent b756d275e4
commit 295782d9e6
7 changed files with 63 additions and 1 deletions

View File

@ -0,0 +1,10 @@
module Vool
class ClassStatement
attr_reader :name, :super_class_name , :body
def initialize( name , supe , body)
@name , @super_class_name , @body = name , supe , body
end
end
end

23
lib/vool/compiler.rb Normal file
View File

@ -0,0 +1,23 @@
module Vool
class Compiler < ::Rubyx::Passes::TotalProcessor
def self.compile(input)
ast = Parser::Ruby22.parse( input )
self.new.process(ast)
end
def on_class( statement )
name , sup , body = *statement
ClassStatement.new( get_name(name) , get_name(sup) , body )
end
def get_name( statement )
return nil unless statement
raise "Not const #{statement}" unless statement.type == :const
name = statement.children[1]
raise "Not symbol #{name}" unless name.is_a? Symbol
name
end
end
end