alphalang 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nodes/basenodes.rb +19 -2
- data/lib/nodes/stmtnodes.rb +7 -1
- data/lib/tester/fibonacci.alpha +1 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab47be57b758b60ecfd23d623f079f39cad75aff9e55d44abbcb848bf981892f
|
4
|
+
data.tar.gz: 722308d6394542dc4afc4cf6ea88b6403e0ed7db5a3ccf39e891b14eb6505526
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cfd7fabcd48b1b5b50e12c9f24c42e6e25bd464a36d47954af1c9401de63b5832cb3ca063b6dde1bd3fe575ae761c8da9507b6eb185ef1ae3a1e593436b8add
|
7
|
+
data.tar.gz: d4b0aa62aac244dad17fe2898fc4e21a1dbc0fa54a0bb51e980a80d15f2491dd42fdf6e6ed17574e4761a4e1e7b5a491565048610acfa4a43f1dffc73fd81055
|
data/lib/nodes/basenodes.rb
CHANGED
@@ -131,6 +131,12 @@ class BinaryOperationNode < Node
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def evaluate
|
134
|
+
if @rhs.evaluate.is_a?(ArrayNode) && @op == '+'
|
135
|
+
return @value = @rhs.evaluate + @lhs.evaluate
|
136
|
+
elsif @lhs.evaluate.is_a?(Array) && @op == '+'
|
137
|
+
return @value = @lhs.evaluate.append(@rhs.evaluate)
|
138
|
+
end
|
139
|
+
|
134
140
|
if @op == '/'
|
135
141
|
@value = @lhs.evaluate.to_f.send(@op, @rhs.evaluate)
|
136
142
|
else
|
@@ -155,7 +161,6 @@ end
|
|
155
161
|
|
156
162
|
####################################################
|
157
163
|
|
158
|
-
#Arraynoden är ofärdig, används inte korrekt
|
159
164
|
class ArrayNode < Node
|
160
165
|
attr_accessor :lhs, :rhs
|
161
166
|
|
@@ -173,6 +178,18 @@ class ArrayNode < Node
|
|
173
178
|
end
|
174
179
|
end
|
175
180
|
|
181
|
+
def display_on_new_line
|
182
|
+
puts @value
|
183
|
+
end
|
184
|
+
|
185
|
+
def display_on_one_line
|
186
|
+
puts @value.join(', ')
|
187
|
+
end
|
188
|
+
|
189
|
+
def +(index)
|
190
|
+
@value.append(index)
|
191
|
+
end
|
192
|
+
|
176
193
|
def [](index)
|
177
194
|
@value[index]
|
178
195
|
end
|
@@ -192,6 +209,6 @@ class ArrayNode < Node
|
|
192
209
|
end
|
193
210
|
|
194
211
|
def evaluate
|
195
|
-
|
212
|
+
self
|
196
213
|
end
|
197
214
|
end
|
data/lib/nodes/stmtnodes.rb
CHANGED
@@ -187,7 +187,13 @@ class PrintNode
|
|
187
187
|
end
|
188
188
|
|
189
189
|
def evaluate
|
190
|
-
|
190
|
+
if @value.evaluate.is_a?(ArrayNode)
|
191
|
+
@value.evaluate.display_on_one_line
|
192
|
+
elsif @value.evaluate.is_a?(Array)
|
193
|
+
puts @value.evaluate.join(', ')
|
194
|
+
else
|
195
|
+
puts @value.evaluate
|
196
|
+
end
|
191
197
|
self.class
|
192
198
|
end
|
193
199
|
end
|
data/lib/tester/fibonacci.alpha
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alphalang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mattias, victor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logger
|