makes own file for statement base class

adds some functionality to it
moves the requires from compiler there
This commit is contained in:
Torsten Ruger 2017-04-08 12:09:25 +03:00
parent db8f99409b
commit 0fe5685ad4
3 changed files with 59 additions and 21 deletions

View File

@ -1,6 +1 @@
module Vool
class Statement
end
end
require_relative "vool/ruby_compiler"
require_relative "vool/vool_compiler"

View File

@ -1,17 +1,4 @@
require_relative "statements/array_statement"
require_relative "statements/assignment_statement"
require_relative "statements/basic_values"
require_relative "statements/class_statement"
require_relative "statements/hash_statement"
require_relative "statements/if_statement"
require_relative "statements/logical_statement"
require_relative "statements/method_statement"
require_relative "statements/return_statement"
require_relative "statements/statements"
require_relative "statements/send_statement"
require_relative "statements/variables"
require_relative "statements/while_statement"
require_relative "statement"
module Vool
# This RubyCompiler compiles incoming ruby (string) into vools internal representation
@ -36,7 +23,8 @@ module Vool
def on_class( statement )
name , sup , body = *statement
ClassStatement.new( get_name(name) , get_name(sup) , process_all(body) )
puts "CLASS #{statement}"
ClassStatement.new( get_name(name) , get_name(sup) , process(body) )
end
def on_def( statement )

55
lib/vool/statement.rb Normal file
View File

@ -0,0 +1,55 @@
# Virtual
# Object Oriented
# Langiage
#
# VOOL is the abstraction of ruby, ruby minus some of the fluff
# fluff is generally what makes ruby nice to use, like 3 ways to achieve the same thing
# if/unless/ternary , reverse ifs (ie statement if condition), reverse whiles,
# implicit blocks, splats and multiple assigns etc
#
# Also, Vool is a typed tree, not abstract, so there is a base class Statement
# and all it's derivation that make up the syntax tree
#
# This allows us to write compilers or passes of the compiler(s) as functions on the
# classes.
module Vool
# Base class for all statements in the tree. Derived classes correspond to known language
# constructs
#
# Compilers or compiler passes are written by implementing methods.
#
class Statement
def collect(arr)
arr << self
end
# create corresponding parfait objects, ie classes, types, methods
# mainly implemented by class/method statement
def create_objects
end
# used to collect type information
def add_ivar( array )
end
# used to collect frame information
def add_local( array )
end
end
end
require_relative "statements/array_statement"
require_relative "statements/assignment_statement"
require_relative "statements/basic_values"
require_relative "statements/class_statement"
require_relative "statements/hash_statement"
require_relative "statements/if_statement"
require_relative "statements/logical_statement"
require_relative "statements/method_statement"
require_relative "statements/return_statement"
require_relative "statements/statements"
require_relative "statements/send_statement"
require_relative "statements/variables"
require_relative "statements/while_statement"