Renaming Vool exppressions rightly

Class, Method and Lambda (was block) are expressions.
Just making things clearer, especially for the blocks (ahem, lambdas) is matters.
wip
This commit is contained in:
2019-08-19 11:33:12 +03:00
parent ae16551ed0
commit f87526f86f
44 changed files with 162 additions and 92 deletions

View File

@ -2,7 +2,7 @@
# Object Oriented
# Language
#
# VOOL is the abstraction of ruby, ruby minus some of the fluff
# VOOL is the abstraction of ruby, ruby minusthe 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
@ -10,19 +10,17 @@
# 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
#
# Also Vool has expression and statements and simple syntax. So returns must be explicit
# not everthing is just assignable, ifs can only test simple expressions etc (wip)
#
# This allows us to write compilers or passes of the compiler(s) as functions on the
# classes.
#
# Also Vool has expression and statements, revealing that age old dichotomy of code and
# data. Statements represent code whereas Expressions resolve to data.
# (in ruby there are no pure statements, everthing resolves to data)
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.
#
# Basically Statements represent code, generally speaking code "does things".
# But Vool distinguishes Expressions (see below), that represent data, and as such
# don't do things themselves, rather passively participate in being pushed around
class Statement
def to_mom( _ )
@ -37,7 +35,13 @@ module Vool
end
class Expression
# An Expression is a Statement that represents data. ie variables constants
# (see basic_values) , but alos classes, methods and lambdas
class Expression < Statement
def each(&block)
block.call(self)
end
def ct_type
nil
@ -46,20 +50,13 @@ module Vool
def normalize
raise "should not be normalized #{self}"
end
def to_mom(compiler)
raise "should not be momed #{self}"
end
# for loading into a lot, return the "slot_definition" that can be passed to
# for loading into a slot, return the "slot_definition" that can be passed to
# SlotLoad.
def slot_definition(compiler)
def to_slot(compiler)
raise "not iplemented in #{self}"
end
def at_depth(depth , *strings)
prefix = " " * 2 * depth
strings.collect{|str| prefix + str}.join("\n")
end
end
end
@ -67,14 +64,14 @@ end
require_relative "assignment"
require_relative "basic_values"
require_relative "block_statement"
require_relative "call_statement"
require_relative "class_statement"
require_relative "class_expression"
require_relative "if_statement"
require_relative "ivar_assignment"
require_relative "lambda_expression"
require_relative "local_assignment"
require_relative "method_statement"
require_relative "class_method_statement"
require_relative "method_expression"
require_relative "class_method_expression"
require_relative "return_statement"
require_relative "statements"
require_relative "send_statement"