fancy 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +38 -86
- data/bin/fdoc +2 -22
- data/bin/fspec +8 -3
- data/bin/ifancy +1 -1
- data/boot/fancy_ext.rb +1 -0
- data/boot/fancy_ext/array.rb +19 -0
- data/boot/fancy_ext/class.rb +2 -4
- data/boot/fancy_ext/module.rb +2 -0
- data/boot/fancy_ext/object.rb +0 -17
- data/boot/rbx-compiler/compiler/ast/method_def.rb +0 -4
- data/boot/rbx-compiler/compiler/ast/singleton_method_def.rb +0 -7
- data/boot/rbx-compiler/parser/fancy_parser.bundle +0 -0
- data/boot/rbx-compiler/parser/fancy_parser.c +1 -0
- data/doc/api/fancy.css +10 -1
- data/doc/api/fancy.jsonp +1 -1
- data/doc/api/fdoc.js +22 -9
- data/doc/api/octocat.png +0 -0
- data/doc/features.md +1 -2
- data/examples/actors.fy +1 -2
- data/examples/armstrong_numbers.fy +7 -3
- data/examples/blocks.fy +3 -3
- data/examples/distributing_proxy.fy +31 -0
- data/examples/future_sends.fy +15 -0
- data/examples/person.fy +1 -2
- data/lib/argv.fy +1 -7
- data/lib/array.fy +7 -11
- data/lib/block.fy +15 -0
- data/lib/boot.fy +4 -3
- data/lib/class.fy +354 -10
- data/lib/compiler.fy +1 -1
- data/lib/compiler/ast/assign.fy +4 -8
- data/lib/compiler/ast/async_send.fy +1 -2
- data/lib/compiler/ast/block.fy +5 -0
- data/lib/compiler/ast/class_def.fy +2 -1
- data/lib/compiler/ast/expression_list.fy +1 -2
- data/lib/compiler/ast/future_send.fy +1 -2
- data/lib/compiler/ast/identifier.fy +34 -17
- data/lib/compiler/ast/literals.fy +31 -19
- data/lib/compiler/ast/match.fy +5 -4
- data/lib/compiler/ast/message_send.fy +3 -5
- data/lib/compiler/ast/method_def.fy +0 -3
- data/lib/compiler/ast/range.fy +2 -4
- data/lib/compiler/ast/return.fy +2 -4
- data/lib/compiler/ast/script.fy +2 -4
- data/lib/compiler/ast/singleton_method_def.fy +0 -3
- data/lib/compiler/ast/string_interpolation.fy +2 -2
- data/lib/compiler/ast/super.fy +2 -4
- data/lib/compiler/ast/try_catch.fy +13 -9
- data/lib/compiler/ast/tuple_literal.fy +1 -2
- data/lib/compiler/compiler.fy +2 -2
- data/lib/compiler/stages.fy +3 -6
- data/lib/contracts.fy +89 -57
- data/lib/dynamic_slot_object.fy +21 -3
- data/lib/enumerable.fy +140 -4
- data/lib/enumerator.fy +1 -1
- data/lib/eval.fy +23 -9
- data/lib/exception.fy +16 -0
- data/lib/false_class.fy +36 -5
- data/lib/fancy_spec.fy +64 -34
- data/lib/fdoc.fy +85 -24
- data/lib/file.fy +19 -0
- data/lib/future.fy +4 -46
- data/lib/hash.fy +113 -0
- data/lib/integer.fy +25 -6
- data/lib/iteration.fy +3 -3
- data/lib/main.fy +5 -0
- data/lib/matchers.fy +79 -0
- data/lib/nil_class.fy +8 -0
- data/lib/object.fy +109 -18
- data/lib/option_parser.fy +118 -0
- data/lib/package/dependency.fy +4 -8
- data/lib/package/dependency_installer.fy +1 -1
- data/lib/package/handler.fy +6 -0
- data/lib/package/installer.fy +43 -16
- data/lib/package/list.fy +1 -2
- data/lib/package/specification.fy +5 -5
- data/lib/package/uninstaller.fy +9 -2
- data/lib/parser.fy +1 -3
- data/lib/parser/ext/ext.c +1 -0
- data/lib/parser/ext/lexer.lex +5 -0
- data/lib/parser/methods.fy +48 -46
- data/lib/proxies.fy +151 -0
- data/lib/rbx.fy +1 -0
- data/lib/rbx/actor.fy +16 -18
- data/lib/rbx/array.fy +18 -3
- data/lib/rbx/block.fy +1 -7
- data/lib/rbx/class.fy +54 -9
- data/lib/rbx/code_loader.fy +2 -5
- data/lib/rbx/compiled_method.fy +31 -0
- data/lib/rbx/debugger.fy +66 -0
- data/lib/rbx/directory.fy +8 -3
- data/lib/rbx/documentation.fy +1 -1
- data/lib/rbx/file.fy +22 -0
- data/lib/rbx/integer.fy +1 -1
- data/lib/rbx/match_data.fy +2 -1
- data/lib/rbx/method.fy +26 -0
- data/lib/rbx/object.fy +8 -3
- data/lib/rbx/regexp.fy +6 -3
- data/lib/rbx/string.fy +9 -1
- data/lib/rbx/stringio.fy +12 -0
- data/lib/rbx/symbol.fy +4 -0
- data/lib/stack.fy +1 -1
- data/lib/string.fy +34 -0
- data/lib/stringio.fy +1 -1
- data/lib/symbol.fy +6 -2
- data/lib/system.fy +15 -1
- data/lib/tuple.fy +5 -2
- data/lib/version.fy +1 -1
- data/ruby_lib/fdoc +2 -22
- data/tests/array.fy +3 -17
- data/tests/class.fy +312 -10
- data/tests/contracts.fy +51 -0
- data/tests/distributing_proxy.fy +28 -0
- data/tests/enumerable.fy +104 -1
- data/tests/exception.fy +35 -0
- data/tests/fixnum.fy +1 -1
- data/tests/hash.fy +81 -1
- data/tests/integer.fy +9 -0
- data/tests/matchers.fy +18 -0
- data/tests/method.fy +8 -14
- data/tests/object.fy +76 -2
- data/tests/option_parser.fy +80 -0
- data/tests/string.fy +21 -0
- data/tests/stringio.fy +1 -1
- data/tests/tuple.fy +1 -1
- metadata +21 -44
- data/examples/arithmetic.fy +0 -7
- data/examples/array.fy +0 -50
- data/examples/boolean.fy +0 -24
- data/examples/class.fy +0 -68
- data/examples/constant_access.fy +0 -15
- data/examples/default_args.fy +0 -20
- data/examples/define_methods.fy +0 -15
- data/examples/dynamic_output.fy +0 -15
- data/examples/empty_catch.fy +0 -4
- data/examples/exception.fy +0 -9
- data/examples/files.fy +0 -23
- data/examples/finally.fy +0 -5
- data/examples/future.fy +0 -30
- data/examples/future_composition.fy +0 -20
- data/examples/futures.fy +0 -9
- data/examples/game_of_life.fy +0 -148
- data/examples/html_generator.fy +0 -84
- data/examples/implicit_return.fy +0 -3
- data/examples/matchers.fy +0 -6
- data/examples/nested_try.fy +0 -9
- data/examples/numbers.fy +0 -12
- data/examples/rbx/and_or.fy +0 -7
- data/examples/rbx/blocks.fy +0 -22
- data/examples/rbx/classes.fy +0 -32
- data/examples/rbx/hello.fy +0 -8
- data/examples/rbx/include.fy +0 -12
- data/examples/rbx/inherit.fy +0 -11
- data/examples/rbx/methods.fy +0 -15
- data/examples/rbx/nested_classes.fy +0 -9
- data/examples/rbx/require.fy +0 -3
- data/examples/rbx/strings.fy +0 -5
- data/examples/require.fy +0 -7
- data/examples/return.fy +0 -13
- data/examples/singleton_methods.fy +0 -21
- data/examples/threads.fy +0 -18
- data/examples/tuple.fy +0 -8
- data/examples/webserver/webserver.fy +0 -15
- data/lib/proxy.fy +0 -86
- data/lib/thread_pool.fy +0 -102
data/examples/constant_access.fy
DELETED
data/examples/default_args.fy
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# default_args.fy
|
|
2
|
-
# Example of fancy's default arguments
|
|
3
|
-
|
|
4
|
-
def arg1: arg1 ("default_arg1") arg2: arg2 ("default_arg2") arg3: arg3 ("default_arg3") {
|
|
5
|
-
"arguments are: " println
|
|
6
|
-
arg1 println
|
|
7
|
-
arg2 println
|
|
8
|
-
arg3 println
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
arg1: "hello" arg2: "world" arg3: "how are you?"
|
|
12
|
-
|
|
13
|
-
Console newline
|
|
14
|
-
arg1: "hello" arg2: "world"
|
|
15
|
-
|
|
16
|
-
Console newline
|
|
17
|
-
arg1: "hello"
|
|
18
|
-
|
|
19
|
-
Console newline
|
|
20
|
-
arg1
|
data/examples/define_methods.fy
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
arr = [1,2,3]
|
|
2
|
-
arr define_singleton_method: "foo" with: {
|
|
3
|
-
"in foo!" println
|
|
4
|
-
self inspect println
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
arr receive_message: 'foo
|
|
8
|
-
|
|
9
|
-
arr undefine_singleton_method: "foo"
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
arr receive_message: 'foo
|
|
13
|
-
} catch NoMethodError => e {
|
|
14
|
-
e println
|
|
15
|
-
}
|
data/examples/dynamic_output.fy
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# *stdout* refers to STDOUT
|
|
2
|
-
File open: "/tmp/foo.txt" modes: ['write] with: |f| {
|
|
3
|
-
let: '*stdout* be: f in: {
|
|
4
|
-
# *stdout* refers to f
|
|
5
|
-
# "foo" will be written to /tmp/foo.txt
|
|
6
|
-
# and not STDOUT
|
|
7
|
-
"foo" println
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
File open: "/tmp/foo.txt" modes: ['read] with: |f| {
|
|
11
|
-
let: '*stdin* be: f in: {
|
|
12
|
-
*stdin* readln println # => prints "foo" to *stdout*
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
# *stdout* refers to STDOUT
|
data/examples/empty_catch.fy
DELETED
data/examples/exception.fy
DELETED
data/examples/files.fy
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# files.fy
|
|
2
|
-
# File handling examples
|
|
3
|
-
|
|
4
|
-
{
|
|
5
|
-
Directory create: "tmp/"
|
|
6
|
-
} unless: $ Directory exists?: "tmp/"
|
|
7
|
-
|
|
8
|
-
File open: "tmp/Hello-World.txt" modes: ['write] with: |f| {
|
|
9
|
-
f writeln: "Hello, world"
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
File delete: "tmp/Hello-World.txt"
|
|
13
|
-
|
|
14
|
-
arr = [1,2,3,4]
|
|
15
|
-
File open: "tmp/Array-Test.txt" modes: ['write] with: |f| {
|
|
16
|
-
arr each: |x| {
|
|
17
|
-
f writeln: x
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
File delete: "tmp/Array-Test.txt"
|
|
22
|
-
|
|
23
|
-
Directory delete: "tmp/"
|
data/examples/finally.fy
DELETED
data/examples/future.fy
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
def foo {
|
|
2
|
-
Thread sleep: 3
|
|
3
|
-
"FOO"
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
def + other {
|
|
7
|
-
Thread sleep: 1.5
|
|
8
|
-
"PLUS"
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
def baz: num {
|
|
12
|
-
Thread sleep: (num * 0.5)
|
|
13
|
-
"BAZ"
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
"Start" println
|
|
17
|
-
|
|
18
|
-
f = self @ foo
|
|
19
|
-
f println # print future object
|
|
20
|
-
?f println # access and print the future's value
|
|
21
|
-
|
|
22
|
-
f = self @ + 10
|
|
23
|
-
f println
|
|
24
|
-
?f println
|
|
25
|
-
|
|
26
|
-
f = self @ baz: 10
|
|
27
|
-
f println
|
|
28
|
-
?f println
|
|
29
|
-
|
|
30
|
-
"End" println
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# example of composing futures:
|
|
2
|
-
|
|
3
|
-
def do_large_computation: x {
|
|
4
|
-
x upto: (x ** x)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
# FutureSend#&& takes a Block (or a Callable - something that implements 'call:)
|
|
8
|
-
# and creates a new FutureSend that executes the given Block with the value of the first FutureSend
|
|
9
|
-
# when it has finished its computation. This makes pipelining tasks easy.
|
|
10
|
-
|
|
11
|
-
f = self @ do_large_computation: 5 && @{select: 'even?} && @{inspect println}
|
|
12
|
-
"computing .. " println
|
|
13
|
-
f value
|
|
14
|
-
|
|
15
|
-
#the above is the same as:
|
|
16
|
-
# f = self @ do_large_computation: 5
|
|
17
|
-
# f = f when_done: @{select: 'even?}
|
|
18
|
-
# f = f when_done: @{inspect println}
|
|
19
|
-
# "computing .. " println
|
|
20
|
-
# f value
|
data/examples/futures.fy
DELETED
data/examples/game_of_life.fy
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
# game_of_life.fy
|
|
2
|
-
# Conway's Game of Life in Fancy :)
|
|
3
|
-
|
|
4
|
-
class World {
|
|
5
|
-
read_write_slots: ['matrix]
|
|
6
|
-
|
|
7
|
-
def World with_height: height and_width: width {
|
|
8
|
-
World new: [height, width]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
def initialize {
|
|
12
|
-
# the offsets are the positions to check for neighbors relative to
|
|
13
|
-
# each position (e.g. [-1,-1] points to the upper left neighbor of
|
|
14
|
-
# each cell)
|
|
15
|
-
@offsets = [[-1, -1], [-1, 0], [-1, 1],
|
|
16
|
-
[0, -1], [0, 1],
|
|
17
|
-
[1, -1], [1, 0], [1, 1]]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
def initialize: size {
|
|
21
|
-
"Initialize a World with a given size ([height, width])."
|
|
22
|
-
|
|
23
|
-
self initialize
|
|
24
|
-
height = size[0]
|
|
25
|
-
width = size[1]
|
|
26
|
-
@last_alive = []
|
|
27
|
-
@matrix = Array new: height
|
|
28
|
-
height times: |i| {
|
|
29
|
-
@matrix at: i put: (Array new: width with: 0)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
def [index] {
|
|
34
|
-
"Return the row for a given index."
|
|
35
|
-
@matrix[index]
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
def simulate: amount_generations {
|
|
39
|
-
"Simulate the World for a given amount of iterations (generations)."
|
|
40
|
-
|
|
41
|
-
display: 0
|
|
42
|
-
amount_generations times: |i| {
|
|
43
|
-
Thread sleep: 0.5 # sleep 500 ms
|
|
44
|
-
self simulate
|
|
45
|
-
display: (i + 1)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
def display {
|
|
50
|
-
"Display the World (print on Screen)."
|
|
51
|
-
|
|
52
|
-
@matrix each: |row| {
|
|
53
|
-
row each: |entry| {
|
|
54
|
-
if: (entry == 0) then: {
|
|
55
|
-
" " print
|
|
56
|
-
} else: {
|
|
57
|
-
". " print
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
"" println
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
def display: iteration {
|
|
65
|
-
"Display the World (print on Screen) with the current iteration count."
|
|
66
|
-
|
|
67
|
-
Console clear
|
|
68
|
-
"Generation: " ++ iteration println
|
|
69
|
-
self display
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
def was_alive?: pos {
|
|
73
|
-
"Indicates, if a cell ([row,column]) was alive in the last generation."
|
|
74
|
-
|
|
75
|
-
@last_alive[pos[0]] if_true: |row| {
|
|
76
|
-
row[pos[1]] == 1
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
def live: pos {
|
|
81
|
-
"Sets the given cell ([row,column]) alive."
|
|
82
|
-
(@matrix[pos[0]]) at: (pos[1]) put: 1
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
def die: pos {
|
|
86
|
-
"Sets the given cell ([row,column]) dead."
|
|
87
|
-
(@matrix[pos[0]]) at: (pos[1]) put: 0
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
def simulate {
|
|
91
|
-
"Simulates the world one iteration."
|
|
92
|
-
|
|
93
|
-
@last_alive = @matrix map: |row| { row select_with_index: |c| { c == 1 } }
|
|
94
|
-
@matrix each_with_index: |row i| {
|
|
95
|
-
row each_with_index: |column j| {
|
|
96
|
-
# check amount of neighbors
|
|
97
|
-
n_neighbors = neighbors_of: [i, j]
|
|
98
|
-
if: (was_alive?: [i,j]) then: {
|
|
99
|
-
if: ({n_neighbors <= 1} || {n_neighbors >= 4}) then: {
|
|
100
|
-
die: [i,j]
|
|
101
|
-
} else: {
|
|
102
|
-
live: [i,j]
|
|
103
|
-
}
|
|
104
|
-
} else: {
|
|
105
|
-
if: (n_neighbors == 3) then: {
|
|
106
|
-
live: [i,j]
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
def neighbors_of: pos {
|
|
114
|
-
row = pos[0]
|
|
115
|
-
column = pos[1]
|
|
116
|
-
|
|
117
|
-
neighbors = @offsets map: |o| {
|
|
118
|
-
@matrix[row + (o[0])] if_true: |r| {
|
|
119
|
-
r[column + (o[1])]
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
neighbors select: |x| { x != 0 } . size
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
X = 1
|
|
127
|
-
PULSAR = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
128
|
-
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
129
|
-
[0, 0, 0, 0, X, X, X, 0, 0, 0, X, X, X, 0, 0, 0],
|
|
130
|
-
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
131
|
-
[0, 0, X, 0, 0, 0, 0, X, 0, X, 0, 0, 0, 0, X, 0],
|
|
132
|
-
[0, 0, X, 0, 0, 0, 0, X, 0, X, 0, 0, 0, 0, X, 0],
|
|
133
|
-
[0, 0, X, 0, 0, 0, 0, X, 0, X, 0, 0, 0, 0, X, 0],
|
|
134
|
-
[0, 0, 0, 0, X, X, X, 0, 0, 0, X, X, X, 0, 0, 0],
|
|
135
|
-
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
136
|
-
[0, 0, 0, 0, X, X, X, 0, 0, 0, X, X, X, 0, 0, 0],
|
|
137
|
-
[0, 0, X, 0, 0, 0, 0, X, 0, X, 0, 0, 0, 0, X, 0],
|
|
138
|
-
[0, 0, X, 0, 0, 0, 0, X, 0, X, 0, 0, 0, 0, X, 0],
|
|
139
|
-
[0, 0, X, 0, 0, 0, 0, X, 0, X, 0, 0, 0, 0, X, 0],
|
|
140
|
-
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
141
|
-
[0, 0, 0, 0, X, X, X, 0, 0, 0, X, X, X, 0, 0, 0],
|
|
142
|
-
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
143
|
-
]
|
|
144
|
-
|
|
145
|
-
w = World new
|
|
146
|
-
w matrix: PULSAR
|
|
147
|
-
|
|
148
|
-
w simulate: 20
|
data/examples/html_generator.fy
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# html_generator.fy
|
|
2
|
-
# Simple HTML generator written in fancy
|
|
3
|
-
|
|
4
|
-
class String {
|
|
5
|
-
def but_last {
|
|
6
|
-
# same as: self from: 0 to: -2
|
|
7
|
-
# and: self from: 0 to: (self size - 2)
|
|
8
|
-
self[[0,-2]]
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
class HTML {
|
|
13
|
-
def initialize {
|
|
14
|
-
@buf = ""
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
def initialize: block {
|
|
18
|
-
initialize
|
|
19
|
-
block call_with_receiver: self
|
|
20
|
-
self
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
def open_tag: name attrs: attrs (<[]>) {
|
|
24
|
-
@buf << "<" << (name but_last)
|
|
25
|
-
unless: (attrs empty?) do: {
|
|
26
|
-
@buf << " "
|
|
27
|
-
attrs each: |k v| {
|
|
28
|
-
@buf << k << "=" << (v inspect)
|
|
29
|
-
} in_between: {
|
|
30
|
-
@buf << " "
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
@buf << ">"
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
def close_tag: name {
|
|
37
|
-
@buf << "</" << (name but_last) << ">"
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
def html_block: tag body: body attrs: attrs (<[]>) {
|
|
41
|
-
open_tag: tag attrs: attrs
|
|
42
|
-
match body first {
|
|
43
|
-
case Block -> @buf << (body first call)
|
|
44
|
-
case _ -> @buf << (body first)
|
|
45
|
-
}
|
|
46
|
-
close_tag: tag
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
def unknown_message: m with_params: p {
|
|
50
|
-
match m to_s {
|
|
51
|
-
case /with:$/ ->
|
|
52
|
-
tag = m to_s substitute: /with:$/ with: ""
|
|
53
|
-
html_block: tag body: (p rest) attrs: (p first)
|
|
54
|
-
case _ ->
|
|
55
|
-
html_block: (m to_s) body: p
|
|
56
|
-
}
|
|
57
|
-
nil
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
def to_s {
|
|
61
|
-
@buf
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
# lets generate some simple HTML output :)
|
|
66
|
-
HTML new: |h| {
|
|
67
|
-
html: {
|
|
68
|
-
body: <['id => "body id" ]> with: {
|
|
69
|
-
div: {
|
|
70
|
-
"hello, world!"
|
|
71
|
-
}
|
|
72
|
-
div: {
|
|
73
|
-
p: {
|
|
74
|
-
"OKIDOKI"
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
div: {
|
|
78
|
-
h3: {
|
|
79
|
-
"oh no!"
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
} . println
|
data/examples/implicit_return.fy
DELETED
data/examples/matchers.fy
DELETED
data/examples/nested_try.fy
DELETED
data/examples/numbers.fy
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# numbers.fy
|
|
2
|
-
# Examples of fancy's number objects
|
|
3
|
-
|
|
4
|
-
-10 abs println # prints: 10
|
|
5
|
-
10 abs println # prints: 10
|
|
6
|
-
0 abs println # prints: 0
|
|
7
|
-
|
|
8
|
-
"" println
|
|
9
|
-
|
|
10
|
-
-10 negate println # prints: 10
|
|
11
|
-
10 negate println # prints: -10
|
|
12
|
-
0 negate println # prints: 0
|