fancy 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/bin/fspec +3 -1
- data/boot/code_loader.rb +5 -1
- data/boot/compiler/parser/ext/fancy_parser.bundle +0 -0
- data/boot/fancy_ext.rb +2 -0
- data/boot/fancy_ext/bootstrap.rb +6 -0
- data/boot/fancy_ext/symbol.rb +9 -0
- data/boot/fancy_ext/thread.rb +22 -1
- data/boot/load.rb +1 -0
- data/boot/rbx-compiler/parser/Makefile +156 -0
- data/boot/rbx-compiler/parser/fancy_parser.bundle +0 -0
- data/boot/rbx-compiler/parser/lexer.c +2310 -0
- data/boot/rbx-compiler/parser/lexer.h +315 -0
- data/boot/rbx-compiler/parser/parser.c +2946 -0
- data/boot/rbx-compiler/parser/parser.h +151 -0
- data/doc/api/fancy.jsonp +1 -1
- data/doc/features.md +8 -0
- data/examples/actors.fy +5 -9
- data/examples/actors_primitive.fy +4 -3
- data/examples/actors_ring.fy +15 -14
- data/examples/dynamic.fy +8 -0
- data/examples/dynamic_output.fy +15 -0
- data/examples/parsing.fy +1 -0
- data/examples/person.fy +1 -2
- data/lib/array.fy +49 -11
- data/lib/block.fy +18 -24
- data/lib/boot.fy +1 -1
- data/lib/class.fy +6 -6
- data/lib/compiler/ast.fy +0 -1
- data/lib/compiler/ast/assign.fy +25 -0
- data/lib/compiler/ast/block.fy +1 -0
- data/lib/compiler/ast/identifier.fy +16 -0
- data/lib/compiler/ast/literals.fy +4 -0
- data/lib/compiler/ast/message_send.fy +16 -1
- data/lib/enumerable.fy +45 -18
- data/lib/enumerator.fy +15 -15
- data/lib/false_class.fy +8 -0
- data/lib/fancy_spec.fy +20 -20
- data/lib/future.fy +35 -18
- data/lib/hash.fy +2 -2
- data/lib/integer.fy +1 -17
- data/lib/iteration.fy +36 -36
- data/lib/object.fy +65 -30
- data/lib/package.fy +2 -2
- data/lib/package/installer.fy +6 -0
- data/lib/parser/ext/Makefile +156 -0
- data/lib/parser/ext/fancy_parser.bundle +0 -0
- data/lib/parser/ext/lexer.c +2392 -0
- data/lib/parser/ext/lexer.h +315 -0
- data/lib/parser/ext/lexer.lex +0 -10
- data/lib/parser/ext/parser.c +3251 -0
- data/lib/parser/ext/parser.h +161 -0
- data/lib/parser/ext/parser.y +0 -22
- data/lib/parser/methods.fy +1 -13
- data/lib/range.fy +3 -3
- data/lib/rbx.fy +1 -0
- data/lib/rbx/actor.fy +4 -4
- data/lib/rbx/alpha.fy +6 -0
- data/lib/rbx/array.fy +5 -44
- data/lib/rbx/bignum.fy +1 -12
- data/lib/rbx/block.fy +25 -0
- data/lib/rbx/class.fy +1 -7
- data/lib/rbx/date.fy +1 -5
- data/lib/rbx/file.fy +1 -4
- data/lib/rbx/fixnum.fy +4 -16
- data/lib/rbx/float.fy +1 -10
- data/lib/rbx/integer.fy +14 -2
- data/lib/rbx/io.fy +1 -5
- data/lib/rbx/mutex.fy +30 -0
- data/lib/rbx/object.fy +5 -11
- data/lib/rbx/process.fy +13 -0
- data/lib/rbx/range.fy +1 -5
- data/lib/rbx/string.fy +4 -11
- data/lib/rbx/thread.fy +9 -0
- data/lib/rbx/time.fy +1 -7
- data/lib/stack.fy +1 -1
- data/lib/string.fy +9 -9
- data/lib/symbol.fy +12 -7
- data/lib/tuple.fy +18 -3
- data/lib/vars.fy +3 -0
- data/ruby_lib/fspec +2 -2
- data/ruby_lib/fyi +2 -2
- data/ruby_lib/ifancy +2 -2
- data/tests/array.fy +25 -1
- data/tests/assignment.fy +55 -0
- data/tests/future.fy +28 -0
- data/tests/set.fy +20 -0
- data/tests/stack.fy +46 -0
- data/tests/string.fy +1 -1
- data/tests/tuple.fy +22 -0
- data/tools/fancy-mode.el +1 -1
- metadata +26 -8
- data/lib/compiler/ast/goto.fy +0 -46
- data/lib/message.fy +0 -6
data/tests/future.fy
CHANGED
@@ -25,6 +25,34 @@ FancySpec describe: FutureSend with: {
|
|
25
25
|
f is_a?: FutureSend . is: true
|
26
26
|
f value is_a?: Fixnum . is: true
|
27
27
|
}
|
28
|
+
|
29
|
+
it: "accesses the same future from multiple threads and blocks them until the value is computed" when: {
|
30
|
+
def another_method {
|
31
|
+
Thread sleep: 0.25
|
32
|
+
42
|
33
|
+
}
|
34
|
+
|
35
|
+
future = self @ another_method
|
36
|
+
|
37
|
+
threads = (0..10) map: {
|
38
|
+
Thread new: {
|
39
|
+
future completed? is: false
|
40
|
+
future value is: 42
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
threads each: 'join
|
45
|
+
}
|
46
|
+
|
47
|
+
it: "deals as expected with failures" when: {
|
48
|
+
def a_failing_method {
|
49
|
+
"error!" raise!
|
50
|
+
}
|
51
|
+
f = self @ a_failing_method
|
52
|
+
f failed? is: false
|
53
|
+
f failure message is: "error!"
|
54
|
+
f failed? is: true
|
55
|
+
}
|
28
56
|
}
|
29
57
|
|
30
58
|
FancySpec describe: FutureCollection with: {
|
data/tests/set.fy
CHANGED
@@ -1,4 +1,24 @@
|
|
1
1
|
FancySpec describe: Set with: {
|
2
|
+
it: "creates a new Set with a given list of values" with: 'initialize: when: {
|
3
|
+
s = Set new: [1,2,3]
|
4
|
+
s size is: 3
|
5
|
+
s values sort is: [1,2,3]
|
6
|
+
}
|
7
|
+
|
8
|
+
it: "creates a new empty Set" with: 'initialize when: {
|
9
|
+
s = Set new
|
10
|
+
s size is: 0
|
11
|
+
s values is: []
|
12
|
+
}
|
13
|
+
|
14
|
+
it: "returns the values as an Array" with: 'values when: {
|
15
|
+
s = Set new
|
16
|
+
s << "foo"
|
17
|
+
s << "bar"
|
18
|
+
s << "foo"
|
19
|
+
s values is: ["foo", "bar"]
|
20
|
+
}
|
21
|
+
|
2
22
|
it: "only keeps unique values" with: '[] when: {
|
3
23
|
s = Set new
|
4
24
|
s << 'foo
|
data/tests/stack.fy
CHANGED
@@ -1,4 +1,20 @@
|
|
1
1
|
FancySpec describe: Stack with: {
|
2
|
+
|
3
|
+
it: "creates an empty Stack" with: 'new when: {
|
4
|
+
s = Stack new
|
5
|
+
s size is: 0
|
6
|
+
s empty? is: true
|
7
|
+
}
|
8
|
+
|
9
|
+
it: "has a given amount of nil-initialized elements" with: 'new: when: {
|
10
|
+
s = Stack new: 5
|
11
|
+
s size is: 5
|
12
|
+
s each: |x| {
|
13
|
+
x nil? is: true
|
14
|
+
}
|
15
|
+
s empty? is: false
|
16
|
+
}
|
17
|
+
|
2
18
|
it: "is empty when created" with: '<< when: {
|
3
19
|
s = Stack new
|
4
20
|
s empty? is: true
|
@@ -19,6 +35,36 @@ FancySpec describe: Stack with: {
|
|
19
35
|
}
|
20
36
|
}
|
21
37
|
|
38
|
+
it: "returns the top of stack element" with: 'top when: {
|
39
|
+
s = Stack new
|
40
|
+
s top is: nil
|
41
|
+
s push: 1
|
42
|
+
s top is: 1
|
43
|
+
0 upto: 10 do: |x| {
|
44
|
+
s push: x
|
45
|
+
s top is: x
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
it: "returns the amount of elements in the Stack" with: 'size when: {
|
50
|
+
s = Stack new
|
51
|
+
s size is: 0
|
52
|
+
10 times: { s push: 'foo }
|
53
|
+
s size is: 10
|
54
|
+
}
|
55
|
+
|
56
|
+
it: "returns true if the Stack is empty" with: 'empty? when: {
|
57
|
+
s = Stack new
|
58
|
+
s empty? is: true
|
59
|
+
s push: 1
|
60
|
+
s empty? is: false
|
61
|
+
s pop
|
62
|
+
s empty? is: true
|
63
|
+
|
64
|
+
s = Stack new: 1
|
65
|
+
s empty? is: false
|
66
|
+
}
|
67
|
+
|
22
68
|
it: "calls a Block with each element, starting with the top of stack" with: 'each: when: {
|
23
69
|
s = Stack new
|
24
70
|
10 times: |i| { s << i }
|
data/tests/string.fy
CHANGED
@@ -126,7 +126,7 @@ FancySpec describe: String with: {
|
|
126
126
|
"foo bar baz" includes?: "foobarbaz" . is: false
|
127
127
|
}
|
128
128
|
|
129
|
-
it: "
|
129
|
+
it: "removes any leading indentation" with: 'skip_leading_indentation when: {
|
130
130
|
"""
|
131
131
|
hello, world!
|
132
132
|
how are you?
|
data/tests/tuple.fy
CHANGED
@@ -36,4 +36,26 @@ FancySpec describe: Tuple with: {
|
|
36
36
|
{ Tuple new: 1 } raises: ArgumentError
|
37
37
|
{ Tuple new: 2 } does_not raise: ArgumentError
|
38
38
|
}
|
39
|
+
|
40
|
+
it: "runs a Block for each element" with: 'each: when: {
|
41
|
+
sum = 0
|
42
|
+
vals = []
|
43
|
+
(1,2,3) each: |x| {
|
44
|
+
sum = sum + x
|
45
|
+
vals << x
|
46
|
+
}
|
47
|
+
sum is: 6
|
48
|
+
vals is: [1,2,3]
|
49
|
+
}
|
50
|
+
|
51
|
+
it: "runs a Block for each element in reverse order" with: 'reverse_each: when: {
|
52
|
+
sum = 0
|
53
|
+
vals = []
|
54
|
+
(1,2,3) reverse_each: |x| {
|
55
|
+
sum = sum + x
|
56
|
+
vals << x
|
57
|
+
}
|
58
|
+
sum is: 6
|
59
|
+
vals is: [3,2,1]
|
60
|
+
}
|
39
61
|
}
|
data/tools/fancy-mode.el
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
"match" "case" "->" "=>") ;; keywords
|
10
10
|
|
11
11
|
'(;; symbols
|
12
|
-
("\\('\\(\\([^\s\n\(\)\{\}]+\\|\\]+\\)\\)\\)" 1 font-lock-reference-face)
|
12
|
+
("\\('\\(\\([^\s\n\(\)\{\}\,]+\\|\\]+\\)\\)\\)" 1 font-lock-reference-face)
|
13
13
|
;; fixnums
|
14
14
|
("[0-9]+" . 'font-lock-variable-name-face)
|
15
15
|
;; floats
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fancy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1694540110752149318
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 5
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Christopher Bertels
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: ruby_lib
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-10-05 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -77,7 +77,6 @@ files:
|
|
77
77
|
- lib/integer.fy
|
78
78
|
- lib/iteration.fy
|
79
79
|
- lib/main.fy
|
80
|
-
- lib/message.fy
|
81
80
|
- lib/method.fy
|
82
81
|
- lib/nil_class.fy
|
83
82
|
- lib/number.fy
|
@@ -95,6 +94,7 @@ files:
|
|
95
94
|
- lib/thread_pool.fy
|
96
95
|
- lib/true_class.fy
|
97
96
|
- lib/tuple.fy
|
97
|
+
- lib/vars.fy
|
98
98
|
- lib/version.fy
|
99
99
|
- lib/compiler/ast.fy
|
100
100
|
- lib/compiler/command.fy
|
@@ -129,9 +129,11 @@ files:
|
|
129
129
|
- lib/rbx/io.fy
|
130
130
|
- lib/rbx/match_data.fy
|
131
131
|
- lib/rbx/method.fy
|
132
|
+
- lib/rbx/mutex.fy
|
132
133
|
- lib/rbx/name_error.fy
|
133
134
|
- lib/rbx/no_method_error.fy
|
134
135
|
- lib/rbx/object.fy
|
136
|
+
- lib/rbx/process.fy
|
135
137
|
- lib/rbx/range.fy
|
136
138
|
- lib/rbx/regexp.fy
|
137
139
|
- lib/rbx/string.fy
|
@@ -149,7 +151,6 @@ files:
|
|
149
151
|
- lib/compiler/ast/class_def.fy
|
150
152
|
- lib/compiler/ast/expression_list.fy
|
151
153
|
- lib/compiler/ast/future_send.fy
|
152
|
-
- lib/compiler/ast/goto.fy
|
153
154
|
- lib/compiler/ast/identifier.fy
|
154
155
|
- lib/compiler/ast/literals.fy
|
155
156
|
- lib/compiler/ast/match.fy
|
@@ -167,7 +168,13 @@ files:
|
|
167
168
|
- lib/parser/ext/ext.c
|
168
169
|
- lib/parser/ext/ext.h
|
169
170
|
- lib/parser/ext/extconf.rb
|
171
|
+
- lib/parser/ext/fancy_parser.bundle
|
172
|
+
- lib/parser/ext/lexer.c
|
173
|
+
- lib/parser/ext/lexer.h
|
170
174
|
- lib/parser/ext/lexer.lex
|
175
|
+
- lib/parser/ext/Makefile
|
176
|
+
- lib/parser/ext/parser.c
|
177
|
+
- lib/parser/ext/parser.h
|
171
178
|
- lib/parser/ext/parser.y
|
172
179
|
- lib/parser/ext/README
|
173
180
|
- tests/argv.fy
|
@@ -222,6 +229,8 @@ files:
|
|
222
229
|
- examples/define_methods.fy
|
223
230
|
- examples/documentation.fy
|
224
231
|
- examples/documentation_formatters.fy
|
232
|
+
- examples/dynamic.fy
|
233
|
+
- examples/dynamic_output.fy
|
225
234
|
- examples/echo.fy
|
226
235
|
- examples/empty_catch.fy
|
227
236
|
- examples/exception.fy
|
@@ -242,6 +251,7 @@ files:
|
|
242
251
|
- examples/nested_classes.fy
|
243
252
|
- examples/nested_try.fy
|
244
253
|
- examples/numbers.fy
|
254
|
+
- examples/parsing.fy
|
245
255
|
- examples/pattern_matching.fy
|
246
256
|
- examples/person.fy
|
247
257
|
- examples/regex.fy
|
@@ -285,6 +295,7 @@ files:
|
|
285
295
|
- boot/README
|
286
296
|
- boot/rsexp_pretty_printer.rb
|
287
297
|
- boot/fancy_ext/block_env.rb
|
298
|
+
- boot/fancy_ext/bootstrap.rb
|
288
299
|
- boot/fancy_ext/class.rb
|
289
300
|
- boot/fancy_ext/console.rb
|
290
301
|
- boot/fancy_ext/delegator.rb
|
@@ -292,6 +303,7 @@ files:
|
|
292
303
|
- boot/fancy_ext/module.rb
|
293
304
|
- boot/fancy_ext/object.rb
|
294
305
|
- boot/fancy_ext/string_helper.rb
|
306
|
+
- boot/fancy_ext/symbol.rb
|
295
307
|
- boot/fancy_ext/thread.rb
|
296
308
|
- boot/rbx-compiler/compiler.rb
|
297
309
|
- boot/rbx-compiler/parser.rb
|
@@ -304,7 +316,12 @@ files:
|
|
304
316
|
- boot/rbx-compiler/parser/fancy_parser.bundle
|
305
317
|
- boot/rbx-compiler/parser/fancy_parser.c
|
306
318
|
- boot/rbx-compiler/parser/fancy_parser.h
|
319
|
+
- boot/rbx-compiler/parser/lexer.c
|
320
|
+
- boot/rbx-compiler/parser/lexer.h
|
307
321
|
- boot/rbx-compiler/parser/lexer.lex
|
322
|
+
- boot/rbx-compiler/parser/Makefile
|
323
|
+
- boot/rbx-compiler/parser/parser.c
|
324
|
+
- boot/rbx-compiler/parser/parser.h
|
308
325
|
- boot/rbx-compiler/parser/parser.rb
|
309
326
|
- boot/rbx-compiler/parser/parser.y
|
310
327
|
- boot/rbx-compiler/parser/Rakefile
|
@@ -330,6 +347,7 @@ files:
|
|
330
347
|
- boot/rbx-compiler/compiler/ast/super.rb
|
331
348
|
- boot/rbx-compiler/compiler/ast/try_catch_block.rb
|
332
349
|
- boot/rbx-compiler/compiler/ast/tuple_literal.rb
|
350
|
+
- boot/compiler/parser/ext/fancy_parser.bundle
|
333
351
|
has_rdoc: true
|
334
352
|
homepage: http://www.fancy-lang.org
|
335
353
|
licenses:
|
@@ -344,7 +362,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
344
362
|
requirements:
|
345
363
|
- - ">="
|
346
364
|
- !ruby/object:Gem::Version
|
347
|
-
hash:
|
365
|
+
hash: 2002549777813010636
|
348
366
|
segments:
|
349
367
|
- 0
|
350
368
|
version: "0"
|
@@ -353,7 +371,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
353
371
|
requirements:
|
354
372
|
- - ">="
|
355
373
|
- !ruby/object:Gem::Version
|
356
|
-
hash:
|
374
|
+
hash: 2002549777813010636
|
357
375
|
segments:
|
358
376
|
- 0
|
359
377
|
version: "0"
|
data/lib/compiler/ast/goto.fy
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
class Rubinius Generator {
|
2
|
-
def ip: @ip
|
3
|
-
def ip {
|
4
|
-
@ip
|
5
|
-
}
|
6
|
-
}
|
7
|
-
|
8
|
-
class Fancy AST {
|
9
|
-
class Label : Node {
|
10
|
-
@@registry = <[]>
|
11
|
-
def Label [name] {
|
12
|
-
@@registry[name]
|
13
|
-
}
|
14
|
-
def Label [name]: label {
|
15
|
-
@@registry[name]: label
|
16
|
-
}
|
17
|
-
|
18
|
-
def initialize: @line name: @name
|
19
|
-
def bytecode: g {
|
20
|
-
pos(g)
|
21
|
-
label = Label[@name]
|
22
|
-
unless: label do: {
|
23
|
-
label = g new_label()
|
24
|
-
Label[@name]: label
|
25
|
-
}
|
26
|
-
tmp = g ip
|
27
|
-
g ip: (tmp + 2)
|
28
|
-
label set!()
|
29
|
-
g ip: tmp
|
30
|
-
g push_nil()
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
class Goto : Node {
|
35
|
-
def initialize: @line label_name: @label_name
|
36
|
-
def bytecode: g {
|
37
|
-
pos(g)
|
38
|
-
label = Label[@label_name]
|
39
|
-
unless: label do: {
|
40
|
-
label = g new_label()
|
41
|
-
Label[@label_name]: label
|
42
|
-
}
|
43
|
-
g goto(label)
|
44
|
-
}
|
45
|
-
}
|
46
|
-
}
|