bakkdoor-blocktalk 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +165 -0
- data/README.markdown +114 -0
- data/TODO +9 -0
- data/benchmark.bt +18 -0
- data/evaluator.rb +19 -0
- data/examples/chained_method_call.bt +15 -0
- data/examples/classes_modules.bt +68 -0
- data/examples/exceptions.bt +28 -0
- data/examples/fac.bt +23 -0
- data/examples/inline_ruby.bt +20 -0
- data/examples/linecounter.bt +8 -0
- data/examples/multiple_methodcall.bt +1 -0
- data/examples/portscan.bt +39 -0
- data/examples/require.bt +8 -0
- data/examples/ruby_methods.bt +20 -0
- data/examples/string_interpol.bt +10 -0
- data/examples/string_test.bt +13 -0
- data/examples/test.bt +45 -0
- data/examples/test2.bt +125 -0
- data/examples/test3.bt +9 -0
- data/grammar/blocktalk.rb +5030 -0
- data/grammar/blocktalk.tt +463 -0
- data/language-spec/blocktalk-example.bt +38 -0
- data/language-spec/blocktalk-lang-spec.bt +232 -0
- data/lib/blocktalk/array.bt +60 -0
- data/lib/blocktalk/string.bt +9 -0
- data/lib/blocktalk.bt +3 -0
- data/lib/core.rb +12 -0
- data/lib/kernel/array.rb +9 -0
- data/lib/kernel/class.rb +46 -0
- data/lib/kernel/codeblock.rb +57 -0
- data/lib/kernel/console.rb +40 -0
- data/lib/kernel/error.rb +11 -0
- data/lib/kernel/module.rb +18 -0
- data/lib/kernel/object.rb +66 -0
- data/lib/kernel/string.rb +5 -0
- data/lib/kernel/system.rb +5 -0
- data/parser/helpers/method_definitions.rb +31 -0
- data/parser/helpers/methodcalls.rb +56 -0
- data/parser/nodes/block_literal.rb +42 -0
- data/parser/nodes/catch.rb +22 -0
- data/parser/nodes/class_method_definition.rb +15 -0
- data/parser/nodes/comment.rb +7 -0
- data/parser/nodes/ensure.rb +7 -0
- data/parser/nodes/expression.rb +7 -0
- data/parser/nodes/identifier.rb +7 -0
- data/parser/nodes/integer_literal.rb +7 -0
- data/parser/nodes/message_receiver.rb +7 -0
- data/parser/nodes/message_with_params.rb +8 -0
- data/parser/nodes/message_without_params.rb +10 -0
- data/parser/nodes/method_definition.rb +31 -0
- data/parser/nodes/methodcall.rb +37 -0
- data/parser/nodes/multiple_methodcall.rb +28 -0
- data/parser/nodes/operator_message.rb +8 -0
- data/parser/nodes/require.rb +25 -0
- data/parser/nodes/return.rb +7 -0
- data/parser/nodes/root.rb +15 -0
- data/parser/nodes/string.rb +7 -0
- data/parser/nodes/subexpression.rb +7 -0
- data/parser/nodes/super_call.rb +12 -0
- data/parser/nodes/try.rb +7 -0
- data/parser/nodes/yield.rb +18 -0
- data/parser/nodes.rb +29 -0
- metadata +70 -3
data/examples/test2.bt
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
foo = do |x|
|
2
|
+
Console puts ("bkzubb: " + (x to_s))
|
3
|
+
end
|
4
|
+
|
5
|
+
bar = do
|
6
|
+
100
|
7
|
+
end
|
8
|
+
|
9
|
+
Console puts: (foo call: 10)
|
10
|
+
|
11
|
+
|
12
|
+
[1,2,3] each { |x|
|
13
|
+
Console puts: x
|
14
|
+
}
|
15
|
+
|
16
|
+
# anonymous class
|
17
|
+
c = Class new {
|
18
|
+
def foo = do |x|
|
19
|
+
Console puts: ("in foo: " + x)
|
20
|
+
end
|
21
|
+
}
|
22
|
+
|
23
|
+
obj = c new
|
24
|
+
|
25
|
+
obj foo: (10 to_s)
|
26
|
+
|
27
|
+
# new class Foo
|
28
|
+
Class >> :Foo do
|
29
|
+
def bar = do |x|
|
30
|
+
Console puts: ("in Foo#bar: " + (x to_s))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
foo = Foo new
|
35
|
+
foo bar: "hello, world"
|
36
|
+
|
37
|
+
# extending Foo class
|
38
|
+
#Class in: :Foo do
|
39
|
+
Foo extend do
|
40
|
+
def bazz = do
|
41
|
+
Console puts: "in Foo#bazz!°!!"
|
42
|
+
self bar: "so cool!!"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
foo bazz
|
47
|
+
|
48
|
+
|
49
|
+
# define new class called MyArray, derived from Array
|
50
|
+
# this is equivalent to:
|
51
|
+
# Class in: MyArray deriving: Array ...
|
52
|
+
# just less typing :)
|
53
|
+
|
54
|
+
Class >> {:MyArray => Array} do
|
55
|
+
def crazy_ouput = do
|
56
|
+
self each { |x|
|
57
|
+
Console puts: ("craaaaaazy: " + (x to_s))
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
def take_n = do |amount|
|
62
|
+
i = 0
|
63
|
+
arr = []
|
64
|
+
{i < amount} while_true {
|
65
|
+
arr << (self at: i)
|
66
|
+
i = (i + 1)
|
67
|
+
}
|
68
|
+
|
69
|
+
return: arr
|
70
|
+
end
|
71
|
+
|
72
|
+
# my_each takes a codeblock as an explicit argument
|
73
|
+
def my_each = do |block|
|
74
|
+
i = 0
|
75
|
+
{i < (self size)} while_true {
|
76
|
+
curr_item = (self at: i)
|
77
|
+
block call: curr_item
|
78
|
+
i = (i + 1)
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
myarr = MyArray new
|
84
|
+
myarr << 10
|
85
|
+
myarr << 100
|
86
|
+
myarr << 1000
|
87
|
+
myarr << 10000
|
88
|
+
myarr << 100000
|
89
|
+
|
90
|
+
myarr crazy_ouput
|
91
|
+
|
92
|
+
Console puts: (myarr class)
|
93
|
+
|
94
|
+
Console puts: ((myarr take_n: 3) inspect)
|
95
|
+
|
96
|
+
|
97
|
+
myarr my_each: { |elem|
|
98
|
+
Console puts: ("my_each: " + (elem to_s))
|
99
|
+
}
|
100
|
+
|
101
|
+
# File open: "grammar/test2.blk" mode: "r" do |f|
|
102
|
+
# Console puts: (f readlines)
|
103
|
+
# end
|
104
|
+
|
105
|
+
Class >> :MyClass do
|
106
|
+
def funky = do |name|
|
107
|
+
Console puts: ("in MyClass#funky with name=" + name)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
(MyClass new) funky: "christopher"
|
112
|
+
|
113
|
+
|
114
|
+
Module >> :MyModule {
|
115
|
+
def test = do |bar|
|
116
|
+
Console puts: ("in MyModule#test with bar = " + (bar to_s))
|
117
|
+
end
|
118
|
+
}
|
119
|
+
|
120
|
+
Class >> :MyClass do
|
121
|
+
self mixin: [MyModule]
|
122
|
+
end
|
123
|
+
|
124
|
+
mc = MyClass new
|
125
|
+
mc test: "mixin-test ;)"
|