bakkdoor-blocktalk 0.1.1 → 0.1.2

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.
Files changed (64) hide show
  1. data/LICENSE +165 -0
  2. data/README.markdown +114 -0
  3. data/TODO +9 -0
  4. data/benchmark.bt +18 -0
  5. data/evaluator.rb +19 -0
  6. data/examples/chained_method_call.bt +15 -0
  7. data/examples/classes_modules.bt +68 -0
  8. data/examples/exceptions.bt +28 -0
  9. data/examples/fac.bt +23 -0
  10. data/examples/inline_ruby.bt +20 -0
  11. data/examples/linecounter.bt +8 -0
  12. data/examples/multiple_methodcall.bt +1 -0
  13. data/examples/portscan.bt +39 -0
  14. data/examples/require.bt +8 -0
  15. data/examples/ruby_methods.bt +20 -0
  16. data/examples/string_interpol.bt +10 -0
  17. data/examples/string_test.bt +13 -0
  18. data/examples/test.bt +45 -0
  19. data/examples/test2.bt +125 -0
  20. data/examples/test3.bt +9 -0
  21. data/grammar/blocktalk.rb +5030 -0
  22. data/grammar/blocktalk.tt +463 -0
  23. data/language-spec/blocktalk-example.bt +38 -0
  24. data/language-spec/blocktalk-lang-spec.bt +232 -0
  25. data/lib/blocktalk/array.bt +60 -0
  26. data/lib/blocktalk/string.bt +9 -0
  27. data/lib/blocktalk.bt +3 -0
  28. data/lib/core.rb +12 -0
  29. data/lib/kernel/array.rb +9 -0
  30. data/lib/kernel/class.rb +46 -0
  31. data/lib/kernel/codeblock.rb +57 -0
  32. data/lib/kernel/console.rb +40 -0
  33. data/lib/kernel/error.rb +11 -0
  34. data/lib/kernel/module.rb +18 -0
  35. data/lib/kernel/object.rb +66 -0
  36. data/lib/kernel/string.rb +5 -0
  37. data/lib/kernel/system.rb +5 -0
  38. data/parser/helpers/method_definitions.rb +31 -0
  39. data/parser/helpers/methodcalls.rb +56 -0
  40. data/parser/nodes/block_literal.rb +42 -0
  41. data/parser/nodes/catch.rb +22 -0
  42. data/parser/nodes/class_method_definition.rb +15 -0
  43. data/parser/nodes/comment.rb +7 -0
  44. data/parser/nodes/ensure.rb +7 -0
  45. data/parser/nodes/expression.rb +7 -0
  46. data/parser/nodes/identifier.rb +7 -0
  47. data/parser/nodes/integer_literal.rb +7 -0
  48. data/parser/nodes/message_receiver.rb +7 -0
  49. data/parser/nodes/message_with_params.rb +8 -0
  50. data/parser/nodes/message_without_params.rb +10 -0
  51. data/parser/nodes/method_definition.rb +31 -0
  52. data/parser/nodes/methodcall.rb +37 -0
  53. data/parser/nodes/multiple_methodcall.rb +28 -0
  54. data/parser/nodes/operator_message.rb +8 -0
  55. data/parser/nodes/require.rb +25 -0
  56. data/parser/nodes/return.rb +7 -0
  57. data/parser/nodes/root.rb +15 -0
  58. data/parser/nodes/string.rb +7 -0
  59. data/parser/nodes/subexpression.rb +7 -0
  60. data/parser/nodes/super_call.rb +12 -0
  61. data/parser/nodes/try.rb +7 -0
  62. data/parser/nodes/yield.rb +18 -0
  63. data/parser/nodes.rb +29 -0
  64. 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 ;)"
data/examples/test3.bt ADDED
@@ -0,0 +1,9 @@
1
+ i = (Kernel gets)
2
+
3
+ Console puts: i
4
+
5
+ ((i to_i) < 10) if_true: {
6
+ Console puts: "i < 10!"
7
+ } if_false: {
8
+ Console puts: "i > 10!!"
9
+ }