Class: Yadriggy::Eval
- Inherits:
-
Object
- Object
- Yadriggy::Eval
- Defined in:
- lib/yadriggy/eval.rb
Overview
abstract evaluator (using visitor pattern)
Direct Known Subclasses
Instance Method Summary collapse
- #array(expr) ⇒ Object
- #array_ref(expr) ⇒ Object
- #array_ref_field(expr) ⇒ Object
- #assign(expr) ⇒ Object
-
#astree(expr) ⇒ Object
A root.
- #being_end(expr) ⇒ Object
- #binary(expr) ⇒ Object
- #block(expr) ⇒ Object
- #break_out(expr) ⇒ Object
- #call(expr) ⇒ Object
- #class_def(expr) ⇒ Object
- #command(expr) ⇒ Object
- #conditional(expr) ⇒ Object
- #const(expr) ⇒ Object
- #const_path_field(expr) ⇒ Object
- #const_path_ref(expr) ⇒ Object
-
#define(expr) ⇒ Object
def.
- #dots(expr) ⇒ Object
- #evaluate(expr) ⇒ Object
-
#exprs(expr) ⇒ Object
expressions, or progn in Lisp.
- #for_loop(expr) ⇒ Object
- #global_variable(expr) ⇒ Object
- #hash(expr) ⇒ Object
- #identifier(expr) ⇒ Object
- #identifier_or_call(expr) ⇒ Object
- #instance_variable(expr) ⇒ Object
- #label(expr) ⇒ Object
- #lambda_expr(expr) ⇒ Object
- #loop(expr) ⇒ Object
- #module_def(expr) ⇒ Object
- #name(expr) ⇒ Object
- #nil_value(expr) ⇒ Object
- #number(expr) ⇒ Object
- #paren(expr) ⇒ Object
- #program(expr) ⇒ Object
- #rescue_end(expr) ⇒ Object
- #reserved(expr) ⇒ Object
- #return_values(expr) ⇒ Object
- #singular_class_def(expr) ⇒ Object
- #string_interpolation(expr) ⇒ Object
- #string_literal(expr) ⇒ Object
- #super_method(expr) ⇒ Object
- #symbol(expr) ⇒ Object
- #unary(expr) ⇒ Object
- #variable_call(expr) ⇒ Object
Instance Method Details
#array(expr) ⇒ Object
85 86 87 |
# File 'lib/yadriggy/eval.rb', line 85 def array(expr) raise NotImplementedError.new('array') end |
#array_ref(expr) ⇒ Object
125 126 127 |
# File 'lib/yadriggy/eval.rb', line 125 def array_ref(expr) raise NotImplementedError.new('array') end |
#array_ref_field(expr) ⇒ Object
129 130 131 |
# File 'lib/yadriggy/eval.rb', line 129 def array_ref_field(expr) array_ref(expr) end |
#assign(expr) ⇒ Object
117 118 119 120 121 122 123 |
# File 'lib/yadriggy/eval.rb', line 117 def assign(expr) if expr.left.is_a?(Array) || expr.right.is_a?(Array) raise NotImplementedError.new('multiple assignment') else binary(expr) end end |
#astree(expr) ⇒ Object
A root.
19 20 21 |
# File 'lib/yadriggy/eval.rb', line 19 def astree(expr) evaluate(expr.tree) end |
#being_end(expr) ⇒ Object
173 174 175 |
# File 'lib/yadriggy/eval.rb', line 173 def being_end(expr) raise NotImplementedError.new('begin_end') end |
#binary(expr) ⇒ Object
109 110 111 |
# File 'lib/yadriggy/eval.rb', line 109 def binary(expr) raise NotImplementedError.new('binary') end |
#block(expr) ⇒ Object
165 166 167 |
# File 'lib/yadriggy/eval.rb', line 165 def block(expr) raise NotImplementedError.new('block') end |
#break_out(expr) ⇒ Object
157 158 159 |
# File 'lib/yadriggy/eval.rb', line 157 def break_out(expr) raise NotImplementedError.new('break_out') end |
#call(expr) ⇒ Object
137 138 139 |
# File 'lib/yadriggy/eval.rb', line 137 def call(expr) raise NotImplementedError.new('call') end |
#class_def(expr) ⇒ Object
191 192 193 |
# File 'lib/yadriggy/eval.rb', line 191 def class_def(expr) raise NotImplementedError.new('class_def') end |
#command(expr) ⇒ Object
141 142 143 |
# File 'lib/yadriggy/eval.rb', line 141 def command(expr) call(expr) end |
#conditional(expr) ⇒ Object
145 146 147 |
# File 'lib/yadriggy/eval.rb', line 145 def conditional(expr) raise NotImplementedError.new('conditional') end |
#const(expr) ⇒ Object
43 44 45 |
# File 'lib/yadriggy/eval.rb', line 43 def const(expr) name(expr) end |
#const_path_field(expr) ⇒ Object
101 102 103 |
# File 'lib/yadriggy/eval.rb', line 101 def const_path_field(expr) const_path_ref(expr) end |
#const_path_ref(expr) ⇒ Object
97 98 99 |
# File 'lib/yadriggy/eval.rb', line 97 def const_path_ref(expr) raise NotImplementedError.new('const_path_ref') end |
#define(expr) ⇒ Object
def
179 180 181 |
# File 'lib/yadriggy/eval.rb', line 179 def define(expr) raise NotImplementedError.new('define') end |
#dots(expr) ⇒ Object
113 114 115 |
# File 'lib/yadriggy/eval.rb', line 113 def dots(expr) binary(expr) end |
#evaluate(expr) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/yadriggy/eval.rb', line 8 def evaluate(expr) if expr.nil? nil_value(nil) else expr.accept(self) end self end |
#exprs(expr) ⇒ Object
expressions, or progn in Lisp.
77 78 79 |
# File 'lib/yadriggy/eval.rb', line 77 def exprs(expr) raise NotImplementedError.new('exprs') end |
#for_loop(expr) ⇒ Object
153 154 155 |
# File 'lib/yadriggy/eval.rb', line 153 def for_loop(expr) raise NotImplementedError.new('for_loop') end |
#global_variable(expr) ⇒ Object
55 56 57 |
# File 'lib/yadriggy/eval.rb', line 55 def global_variable(expr) name(expr) end |
#hash(expr) ⇒ Object
133 134 135 |
# File 'lib/yadriggy/eval.rb', line 133 def hash(expr) raise NotImplementedError.new('hash') end |
#identifier(expr) ⇒ Object
35 36 37 |
# File 'lib/yadriggy/eval.rb', line 35 def identifier(expr) identifier_or_call(expr) end |
#identifier_or_call(expr) ⇒ Object
31 32 33 |
# File 'lib/yadriggy/eval.rb', line 31 def identifier_or_call(expr) name(expr) end |
#instance_variable(expr) ⇒ Object
59 60 61 |
# File 'lib/yadriggy/eval.rb', line 59 def instance_variable(expr) name(expr) end |
#label(expr) ⇒ Object
47 48 49 |
# File 'lib/yadriggy/eval.rb', line 47 def label(expr) name(expr) end |
#lambda_expr(expr) ⇒ Object
169 170 171 |
# File 'lib/yadriggy/eval.rb', line 169 def lambda_expr(expr) block(expr) end |
#loop(expr) ⇒ Object
149 150 151 |
# File 'lib/yadriggy/eval.rb', line 149 def loop(expr) raise NotImplementedError.new('loop') end |
#module_def(expr) ⇒ Object
187 188 189 |
# File 'lib/yadriggy/eval.rb', line 187 def module_def(expr) raise NotImplementedError.new('module_def') end |
#name(expr) ⇒ Object
27 28 29 |
# File 'lib/yadriggy/eval.rb', line 27 def name(expr) raise NotImplementedError.new('name') end |
#nil_value(expr) ⇒ Object
23 24 25 |
# File 'lib/yadriggy/eval.rb', line 23 def nil_value(expr) raise NotImplementedError.new('nil_value') end |
#number(expr) ⇒ Object
71 72 73 |
# File 'lib/yadriggy/eval.rb', line 71 def number(expr) raise NotImplementedError.new('number') end |
#paren(expr) ⇒ Object
81 82 83 |
# File 'lib/yadriggy/eval.rb', line 81 def paren(expr) raise NotImplementedError.new('paren') end |
#program(expr) ⇒ Object
199 200 201 |
# File 'lib/yadriggy/eval.rb', line 199 def program(expr) raise NotImplementedError.new('program') end |
#rescue_end(expr) ⇒ Object
183 184 185 |
# File 'lib/yadriggy/eval.rb', line 183 def rescue_end(expr) raise NotImplementedError.new('rescue_end') end |
#reserved(expr) ⇒ Object
39 40 41 |
# File 'lib/yadriggy/eval.rb', line 39 def reserved(expr) name(expr) end |
#return_values(expr) ⇒ Object
161 162 163 |
# File 'lib/yadriggy/eval.rb', line 161 def return_values(expr) raise NotImplementedError.new('return_values') end |
#singular_class_def(expr) ⇒ Object
195 196 197 |
# File 'lib/yadriggy/eval.rb', line 195 def singular_class_def(expr) raise NotImplementedError.new('singular_class_def') end |
#string_interpolation(expr) ⇒ Object
89 90 91 |
# File 'lib/yadriggy/eval.rb', line 89 def string_interpolation(expr) raise NotImplementedError.new('string_interpolation') end |
#string_literal(expr) ⇒ Object
93 94 95 |
# File 'lib/yadriggy/eval.rb', line 93 def string_literal(expr) raise NotImplementedError.new('string_literal') end |
#super_method(expr) ⇒ Object
67 68 69 |
# File 'lib/yadriggy/eval.rb', line 67 def super_method(expr) raise NotImplementedError.new('super_method') end |
#symbol(expr) ⇒ Object
51 52 53 |
# File 'lib/yadriggy/eval.rb', line 51 def symbol(expr) raise NotImplementedError.new('symbol') end |
#unary(expr) ⇒ Object
105 106 107 |
# File 'lib/yadriggy/eval.rb', line 105 def unary(expr) raise NotImplementedError.new('unary') end |
#variable_call(expr) ⇒ Object
63 64 65 |
# File 'lib/yadriggy/eval.rb', line 63 def variable_call(expr) identifier_or_call(expr) end |