halunke 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b782ee6ddb661b1ab07e7beadc086c692572ed3e2aa3a80a33b9c598ed70a93
4
- data.tar.gz: f6aa3c8e8984a15ae7593f388354b69b8d9915a544acce6f1911aeebb171c40f
3
+ metadata.gz: dc3b88ba0756907b466c614c950ea5d9f623ed95ce536afbf714a25c488e982a
4
+ data.tar.gz: f5132e70c123842d85892d87152fc37a54819c4eca26035ac16bcbac87ee8e9b
5
5
  SHA512:
6
- metadata.gz: 61e527ced02be4c0a7b182d9838539148be73683c9fe7421c4e55753a882052551f9e5c16a3ee5e7a75b2224ebcaaeb87e19c1eb51a041dd75dffdf93b331791
7
- data.tar.gz: 05dc2c4b8f27b6c4a7bae7cf0bd18fbaac19eee8b85bb1c90d0db107ffcc6169eed686c7c3e74e66c3f2f7a0ebd1059200f8740b6e0cadd2ee82e88d77b8687b
6
+ metadata.gz: 15e3f8586f02ccb75af4f3086e9c044d0ff0e56dd1b4c5a9f700e868f8472feaa8a6f043f303652559b3c592d03dc4eeba922a772e9675d2e46732a9440a8b3f
7
+ data.tar.gz: bdbbb12cd46e08ce6760d64bc163b0da73b52ee6cbc2aa73d3d0c0b30fa5e99b9e1ce929a05f5128a8ed00b203aaa8873108f20abba2ca6d3b42b05e4a495c82
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- halunke (0.9.0)
4
+ halunke (0.10.0)
5
5
  rack (~> 2.0.4)
6
6
 
7
7
  GEM
@@ -70,10 +70,10 @@ the value is `["Ha" "Spe"]`.
70
70
  If you want to find out more about the types of objects in Halunke
71
71
  and the messages you can send to them, explore the navigation bar
72
72
  at the top. If you want to learn more about conditionals, check out
73
- the section about [True & False](/halunke/true-false). If you want
73
+ the section about [True & False](/true-false). If you want
74
74
  to write your own functions, check out
75
- [Function](/halunke/function) and if you want to define your own
76
- classes, check out [Class](/halunke/class).
75
+ [Function](/function) and if you want to define your own
76
+ classes, check out [Class](/class).
77
77
 
78
78
  If you want to store an object in a variable, you can do it like this:
79
79
 
@@ -27,15 +27,19 @@ rule
27
27
  | Expression Expressions { Nodes.new([val[0]].concat(val[1].nodes)) }
28
28
  ;
29
29
 
30
+ Arguments:
31
+ /* empty */ { ArrayNode.new([]) }
32
+ | BAR Expressions BAR { ArrayNode.new(val[1].nodes, val[0][1], val[2][2]) }
33
+ ;
34
+
30
35
  Expression:
31
36
  NUMBER { NumberNode.new(*val[0]) }
32
37
  | STRING { StringNode.new(*val[0]) }
33
38
  | BAREWORD { BarewordNode.new(*val[0]) }
34
39
  | UNASSIGNED_BAREWORD { UnassignedNode.new(BarewordNode.new(*val[0]), val[0][1], val[0][2]) }
35
40
  | START_COMMENT Expressions END_COMMENT { Nodes.new([]) }
36
- | OPEN_CURLY Expressions CLOSE_CURLY { FunctionNode.new(ArrayNode.new([]), val[1], val[0][1], val[2][2]) }
37
- | OPEN_CURLY BAR Expressions BAR Expressions CLOSE_CURLY { FunctionNode.new(ArrayNode.new(val[2].nodes), val[4], val[0][1], val[5][2]) }
38
- | OPEN_PAREN Expression Expressions CLOSE_PAREN { MessageSendNode.new(val[1], MessageNode.new(val[2].nodes), val[0][1], val[3][2]) }
41
+ | OPEN_CURLY Arguments Expressions CLOSE_CURLY { FunctionNode.new(val[1], val[2], val[0][1], val[3][2]) }
42
+ | OPEN_PAREN Expressions CLOSE_PAREN { MessageSendNode.new(val[1].nodes, val[0][1], val[2][2]) }
39
43
  | OPEN_BRACKET Expressions CLOSE_BRACKET { ArrayNode.new(val[1].nodes, val[0][1], val[2][2]) }
40
44
  | OPEN_DICT_BRACKET Expressions CLOSE_BRACKET { DictionaryNode.new(val[1].nodes, val[0][1], val[2][2]) }
41
45
  ;
@@ -48,4 +48,13 @@ module Halunke
48
48
 
49
49
  class HUnknownAttribute < HError
50
50
  end
51
+
52
+ class HInvalidMessage < HError
53
+ end
54
+
55
+ class HInvalidDictionary < HError
56
+ end
57
+
58
+ class HInvalidMessageName < HError
59
+ end
51
60
  end
@@ -11,31 +11,40 @@ module Halunke
11
11
 
12
12
  NumberNode = Struct.new(:value, :ts, :te) do
13
13
  def eval(context)
14
- context["Number"].create_instance(value)
14
+ context["Number"].create_instance(value,
15
+ source_code_position: source_code_position)
15
16
  end
16
17
 
17
18
  def ==(other)
18
19
  other.is_a?(NumberNode) &&
19
20
  value == other.value
20
21
  end
22
+
23
+ def source_code_position
24
+ SourceCodePosition.new(ts, te)
25
+ end
21
26
  end
22
27
 
23
28
  StringNode = Struct.new(:value, :ts, :te) do
24
29
  def eval(context)
25
- context["String"].create_instance(value)
30
+ context["String"].create_instance(value,
31
+ source_code_position: source_code_position)
26
32
  end
27
33
 
28
34
  def ==(other)
29
35
  other.is_a?(StringNode) &&
30
36
  value == other.value
31
37
  end
38
+
39
+ def source_code_position
40
+ SourceCodePosition.new(ts, te)
41
+ end
32
42
  end
33
43
 
34
44
  BarewordNode = Struct.new(:value, :ts, :te) do
35
45
  def eval(context)
36
46
  context[value]
37
47
  rescue KeyError
38
- source_code_position = SourceCodePosition.new(ts, te)
39
48
  raise HUnassignedBareword.new("Bareword '#{value} is unassigned", source_code_position)
40
49
  end
41
50
 
@@ -43,22 +52,30 @@ module Halunke
43
52
  other.is_a?(BarewordNode) &&
44
53
  value == other.value
45
54
  end
55
+
56
+ def source_code_position
57
+ SourceCodePosition.new(ts, te)
58
+ end
46
59
  end
47
60
 
48
61
  UnassignedNode = Struct.new(:node, :ts, :te) do
49
62
  def eval(context)
50
- context["UnassignedBareword"].create_instance(node.value, source_code_position: SourceCodePosition.new(ts, te))
63
+ context["UnassignedBareword"].create_instance(node.value, source_code_position: source_code_position)
51
64
  end
52
65
 
53
66
  def ==(other)
54
67
  other.is_a?(UnassignedNode) &&
55
68
  node == other.node
56
69
  end
70
+
71
+ def source_code_position
72
+ SourceCodePosition.new(ts, te)
73
+ end
57
74
  end
58
75
 
59
76
  FunctionNode = Struct.new(:params, :body, :ts, :te) do
60
77
  def eval(context)
61
- raise HEmptyFunction.new("This function would not return anything, in Halunke every function needs to return something.", SourceCodePosition.new(ts, te)) if body.empty?
78
+ raise HEmptyFunction.new("This function would not return anything, in Halunke every function needs to return something.", source_code_position) if body.empty?
62
79
  signature = params.nodes.map(&:node).map(&:value)
63
80
 
64
81
  context["Function"].new(signature, lambda { |call_context|
@@ -71,6 +88,10 @@ module Halunke
71
88
  params == other.params &&
72
89
  body == other.body
73
90
  end
91
+
92
+ def source_code_position
93
+ SourceCodePosition.new(ts, te)
94
+ end
74
95
  end
75
96
 
76
97
  ArrayNode = Struct.new(:nodes, :ts, :te) do
@@ -82,56 +103,79 @@ module Halunke
82
103
  other.is_a?(ArrayNode) &&
83
104
  nodes == other.nodes
84
105
  end
106
+
107
+ def source_code_position
108
+ SourceCodePosition.new(ts, te)
109
+ end
85
110
  end
86
111
 
87
112
  DictionaryNode = Struct.new(:nodes, :ts, :te) do
88
113
  def eval(context)
89
114
  hash = {}
90
115
  nodes.each_slice(2) do |key, value|
116
+ raise HInvalidDictionary.new("This key has no value", key.source_code_position) if value.nil?
91
117
  hash[key.eval(context)] = value.eval(context)
92
118
  end
93
- context["Dictionary"].create_instance(hash)
119
+ context["Dictionary"].create_instance(hash,
120
+ source_code_position: source_code_position)
94
121
  end
95
122
 
96
123
  def ==(other)
97
124
  other.is_a?(DictionaryNode) &&
98
125
  nodes == other.nodes
99
126
  end
127
+
128
+ def source_code_position
129
+ SourceCodePosition.new(ts, te)
130
+ end
100
131
  end
101
132
 
102
- MessageSendNode = Struct.new(:receiver, :message, :ts, :te) do
133
+ MessageSendNode = Struct.new(:nodes, :ts, :te) do
103
134
  def eval(context)
104
- receiver.eval(context).receive_message(context, *message.eval(context),
105
- source_code_position: SourceCodePosition.new(ts, te))
135
+ message_name, message_value = parse_message(context)
136
+ receiver.eval(context).receive_message(context, message_name, message_value,
137
+ source_code_position: source_code_position)
106
138
  end
107
139
 
108
140
  def ==(other)
109
141
  other.is_a?(MessageSendNode) &&
110
- receiver == other.receiver &&
111
- message == other.message
142
+ nodes == other.nodes
112
143
  end
113
- end
114
144
 
115
- MessageNode = Struct.new(:nodes) do
116
- def eval(context)
117
- if nodes.length == 1
118
- if nodes[0].is_a? NumberNode
119
- # hack to allow expressions like (1+5)
120
- ["+", [nodes[0].eval(context)]]
121
- else
122
- [nodes[0].value, []]
123
- end
124
- elsif nodes.length.even?
125
- name = []
126
- message = []
127
- nodes.each_slice(2) do |name_part, value|
128
- name.push(name_part.value)
129
- message.push(value.eval(context))
130
- end
131
- [name.join(" "), message]
132
- else
133
- raise "Parse Error"
145
+ def source_code_position
146
+ SourceCodePosition.new(ts, te)
147
+ end
148
+
149
+ private
150
+
151
+ def receiver
152
+ raise HInvalidMessage.new("This message has no receiver", source_code_position) if nodes.length == 0
153
+ @receiver ||= nodes[0]
154
+ end
155
+
156
+ def parse_message(context)
157
+ if message_nodes.length == 1
158
+ # hack to allow expressions like (1+5)
159
+ return ["+", [message_nodes[0].eval(context)]] if message_nodes[0].is_a? NumberNode
160
+ return [message_nodes[0].value, []] if message_nodes[0].is_a? BarewordNode
161
+
162
+ raise HInvalidMessage.new("This is not a bareword", message_nodes[0].source_code_position)
163
+ end
164
+
165
+ name = []
166
+ message = []
167
+ message_nodes.each_slice(2) do |name_part, value|
168
+ raise HInvalidMessage.new("This is not a bareword", name_part.source_code_position) unless name_part.is_a? BarewordNode
169
+ raise HInvalidMessage.new("This bareword has no according argument", name_part.source_code_position) if value.nil?
170
+ name << name_part
171
+ message << value
134
172
  end
173
+ [name.map(&:value).join(" "), message.map { |node| node.eval(context) }]
174
+ end
175
+
176
+ def message_nodes
177
+ raise HInvalidMessage.new("You are sending an empty message", source_code_position) if nodes.length == 1
178
+ @message_nodes ||= nodes.drop(1)
135
179
  end
136
180
  end
137
181
  end
@@ -13,7 +13,7 @@ require "halunke/nodes"
13
13
  module Halunke
14
14
  class Parser < Racc::Parser
15
15
 
16
- module_eval(<<'...end grammar.y/module_eval...', 'grammar.y', 50)
16
+ module_eval(<<'...end grammar.y/module_eval...', 'grammar.y', 54)
17
17
 
18
18
  def parse(code)
19
19
  @tokens = Tokenizer.new.tokenize(code)
@@ -27,82 +27,75 @@ end
27
27
  ##### State transition tables begin ###
28
28
 
29
29
  racc_action_table = [
30
- 4, 5, 6, 10, 13, 9, 21, 7, 11, 22,
31
- 12, 23, 8, 4, 5, 6, 10, 26, 9, 27,
32
- 7, 11, 28, 12, 29, 8, 4, 5, 6, 10,
33
- 31, 9, nil, 7, 11, nil, 12, nil, 8, 4,
30
+ 4, 5, 6, 10, 13, 9, 16, 7, 11, 21,
31
+ 12, 22, 8, 4, 5, 6, 10, 25, 9, 26,
32
+ 7, 11, 27, 12, 28, 8, 4, 5, 6, 10,
33
+ 29, 9, nil, 7, 11, nil, 12, nil, 8, 4,
34
34
  5, 6, 10, nil, 9, nil, 7, 11, nil, 12,
35
- 17, 8, 4, 5, 6, 10, nil, 9, nil, 7,
35
+ nil, 8, 4, 5, 6, 10, nil, 9, nil, 7,
36
36
  11, nil, 12, nil, 8, 4, 5, 6, 10, nil,
37
37
  9, nil, 7, 11, nil, 12, nil, 8, 4, 5,
38
38
  6, 10, nil, 9, nil, 7, 11, nil, 12, nil,
39
39
  8, 4, 5, 6, 10, nil, 9, nil, 7, 11,
40
- nil, 12, nil, 8, 4, 5, 6, 10, nil, 9,
41
- nil, 7, 11, nil, 12, nil, 8, 4, 5, 6,
42
- 10, nil, 9, nil, 7, 11, nil, 12, nil, 8 ]
40
+ nil, 12, nil, 8 ]
43
41
 
44
42
  racc_action_check = [
45
- 0, 0, 0, 0, 1, 0, 13, 0, 0, 15,
46
- 0, 16, 0, 3, 3, 3, 3, 19, 3, 20,
47
- 3, 3, 24, 3, 25, 3, 8, 8, 8, 8,
48
- 30, 8, nil, 8, 8, nil, 8, nil, 8, 9,
49
- 9, 9, 9, nil, 9, nil, 9, 9, nil, 9,
50
- 9, 9, 10, 10, 10, 10, nil, 10, nil, 10,
51
- 10, nil, 10, nil, 10, 11, 11, 11, 11, nil,
52
- 11, nil, 11, 11, nil, 11, nil, 11, 12, 12,
53
- 12, 12, nil, 12, nil, 12, 12, nil, 12, nil,
54
- 12, 17, 17, 17, 17, nil, 17, nil, 17, 17,
55
- nil, 17, nil, 17, 18, 18, 18, 18, nil, 18,
56
- nil, 18, 18, nil, 18, nil, 18, 28, 28, 28,
57
- 28, nil, 28, nil, 28, 28, nil, 28, nil, 28 ]
43
+ 0, 0, 0, 0, 1, 0, 9, 0, 0, 13,
44
+ 0, 15, 0, 3, 3, 3, 3, 18, 3, 19,
45
+ 3, 3, 20, 3, 23, 3, 8, 8, 8, 8,
46
+ 24, 8, nil, 8, 8, nil, 8, nil, 8, 10,
47
+ 10, 10, 10, nil, 10, nil, 10, 10, nil, 10,
48
+ nil, 10, 11, 11, 11, 11, nil, 11, nil, 11,
49
+ 11, nil, 11, nil, 11, 12, 12, 12, 12, nil,
50
+ 12, nil, 12, 12, nil, 12, nil, 12, 16, 16,
51
+ 16, 16, nil, 16, nil, 16, 16, nil, 16, nil,
52
+ 16, 17, 17, 17, 17, nil, 17, nil, 17, 17,
53
+ nil, 17, nil, 17 ]
58
54
 
59
55
  racc_action_pointer = [
60
- -2, 4, nil, 11, nil, nil, nil, nil, 24, 37,
61
- 50, 63, 76, 6, nil, -6, 3, 89, 102, 6,
62
- 8, nil, nil, nil, 9, 18, nil, nil, 115, nil,
63
- 22, nil ]
56
+ -2, 4, nil, 11, nil, nil, nil, nil, 24, -7,
57
+ 37, 50, 63, 9, nil, -4, 76, 89, 11, 8,
58
+ 11, nil, nil, 11, 22, nil, nil, nil, nil, nil ]
64
59
 
65
60
  racc_action_default = [
66
- -2, -14, -1, -2, -4, -5, -6, -7, -2, -2,
67
- -14, -2, -2, -14, -3, -14, -14, -2, -2, -14,
68
- -14, 32, -8, -9, -14, -14, -12, -13, -2, -11,
69
- -14, -10 ]
61
+ -2, -15, -1, -2, -6, -7, -8, -9, -2, -4,
62
+ -2, -2, -2, -15, -3, -15, -2, -2, -15, -15,
63
+ -15, 30, -10, -15, -15, -12, -13, -14, -5, -11 ]
70
64
 
71
65
  racc_goto_table = [
72
- 2, 1, 18, 14, nil, nil, nil, nil, 15, 16,
73
- nil, 19, 20, nil, nil, nil, nil, 24, 25, nil,
74
- nil, nil, nil, nil, nil, nil, nil, nil, 30 ]
66
+ 2, 1, 17, 14, nil, nil, nil, nil, 15, nil,
67
+ 18, 19, 20, nil, nil, nil, 23, 24 ]
75
68
 
76
69
  racc_goto_check = [
77
- 2, 1, 3, 2, nil, nil, nil, nil, 2, 2,
78
- nil, 2, 2, nil, nil, nil, nil, 2, 2, nil,
79
- nil, nil, nil, nil, nil, nil, nil, nil, 2 ]
70
+ 2, 1, 4, 2, nil, nil, nil, nil, 2, nil,
71
+ 2, 2, 2, nil, nil, nil, 2, 2 ]
80
72
 
81
73
  racc_goto_pointer = [
82
- nil, 1, 0, -8 ]
74
+ nil, 1, 0, nil, -7 ]
83
75
 
84
76
  racc_goto_default = [
85
- nil, nil, nil, 3 ]
77
+ nil, nil, nil, 3, nil ]
86
78
 
87
79
  racc_reduce_table = [
88
80
  0, 0, :racc_error,
89
81
  1, 17, :_reduce_1,
90
82
  0, 18, :_reduce_2,
91
83
  2, 18, :_reduce_3,
92
- 1, 19, :_reduce_4,
93
- 1, 19, :_reduce_5,
84
+ 0, 20, :_reduce_4,
85
+ 3, 20, :_reduce_5,
94
86
  1, 19, :_reduce_6,
95
87
  1, 19, :_reduce_7,
96
- 3, 19, :_reduce_8,
97
- 3, 19, :_reduce_9,
98
- 6, 19, :_reduce_10,
88
+ 1, 19, :_reduce_8,
89
+ 1, 19, :_reduce_9,
90
+ 3, 19, :_reduce_10,
99
91
  4, 19, :_reduce_11,
100
92
  3, 19, :_reduce_12,
101
- 3, 19, :_reduce_13 ]
93
+ 3, 19, :_reduce_13,
94
+ 3, 19, :_reduce_14 ]
102
95
 
103
- racc_reduce_n = 14
96
+ racc_reduce_n = 15
104
97
 
105
- racc_shift_n = 32
98
+ racc_shift_n = 30
106
99
 
107
100
  racc_token_table = {
108
101
  false => 0,
@@ -162,7 +155,8 @@ Racc_token_to_s_table = [
162
155
  "$start",
163
156
  "Program",
164
157
  "Expressions",
165
- "Expression" ]
158
+ "Expression",
159
+ "Arguments" ]
166
160
 
167
161
  Racc_debug_parser = false
168
162
 
@@ -190,60 +184,66 @@ module_eval(<<'.,.,', 'grammar.y', 26)
190
184
 
191
185
  module_eval(<<'.,.,', 'grammar.y', 30)
192
186
  def _reduce_4(val, _values)
193
- NumberNode.new(*val[0])
187
+ ArrayNode.new([])
194
188
  end
195
189
  .,.,
196
190
 
197
191
  module_eval(<<'.,.,', 'grammar.y', 31)
198
192
  def _reduce_5(val, _values)
199
- StringNode.new(*val[0])
193
+ ArrayNode.new(val[1].nodes, val[0][1], val[2][2])
200
194
  end
201
195
  .,.,
202
196
 
203
- module_eval(<<'.,.,', 'grammar.y', 32)
197
+ module_eval(<<'.,.,', 'grammar.y', 35)
204
198
  def _reduce_6(val, _values)
205
- BarewordNode.new(*val[0])
199
+ NumberNode.new(*val[0])
206
200
  end
207
201
  .,.,
208
202
 
209
- module_eval(<<'.,.,', 'grammar.y', 33)
203
+ module_eval(<<'.,.,', 'grammar.y', 36)
210
204
  def _reduce_7(val, _values)
211
- UnassignedNode.new(BarewordNode.new(*val[0]), val[0][1], val[0][2])
205
+ StringNode.new(*val[0])
212
206
  end
213
207
  .,.,
214
208
 
215
- module_eval(<<'.,.,', 'grammar.y', 34)
209
+ module_eval(<<'.,.,', 'grammar.y', 37)
216
210
  def _reduce_8(val, _values)
217
- Nodes.new([])
211
+ BarewordNode.new(*val[0])
218
212
  end
219
213
  .,.,
220
214
 
221
- module_eval(<<'.,.,', 'grammar.y', 35)
215
+ module_eval(<<'.,.,', 'grammar.y', 38)
222
216
  def _reduce_9(val, _values)
223
- FunctionNode.new(ArrayNode.new([]), val[1], val[0][1], val[2][2])
217
+ UnassignedNode.new(BarewordNode.new(*val[0]), val[0][1], val[0][2])
224
218
  end
225
219
  .,.,
226
220
 
227
- module_eval(<<'.,.,', 'grammar.y', 36)
221
+ module_eval(<<'.,.,', 'grammar.y', 39)
228
222
  def _reduce_10(val, _values)
229
- FunctionNode.new(ArrayNode.new(val[2].nodes), val[4], val[0][1], val[5][2])
223
+ Nodes.new([])
230
224
  end
231
225
  .,.,
232
226
 
233
- module_eval(<<'.,.,', 'grammar.y', 37)
227
+ module_eval(<<'.,.,', 'grammar.y', 40)
234
228
  def _reduce_11(val, _values)
235
- MessageSendNode.new(val[1], MessageNode.new(val[2].nodes), val[0][1], val[3][2])
229
+ FunctionNode.new(val[1], val[2], val[0][1], val[3][2])
236
230
  end
237
231
  .,.,
238
232
 
239
- module_eval(<<'.,.,', 'grammar.y', 38)
233
+ module_eval(<<'.,.,', 'grammar.y', 41)
240
234
  def _reduce_12(val, _values)
241
- ArrayNode.new(val[1].nodes, val[0][1], val[2][2])
235
+ MessageSendNode.new(val[1].nodes, val[0][1], val[2][2])
242
236
  end
243
237
  .,.,
244
238
 
245
- module_eval(<<'.,.,', 'grammar.y', 39)
239
+ module_eval(<<'.,.,', 'grammar.y', 42)
246
240
  def _reduce_13(val, _values)
241
+ ArrayNode.new(val[1].nodes, val[0][1], val[2][2])
242
+ end
243
+ .,.,
244
+
245
+ module_eval(<<'.,.,', 'grammar.y', 43)
246
+ def _reduce_14(val, _values)
247
247
  DictionaryNode.new(val[1].nodes, val[0][1], val[2][2])
248
248
  end
249
249
  .,.,
@@ -39,12 +39,15 @@ module Halunke
39
39
  end
40
40
 
41
41
  context[name] = HClass.new(name, allowed_attributes, instance_methods, class_methods, false)
42
+ rescue FrozenError
43
+ assigned_value = context[name].inspect(context)
44
+ raise HBarewordAlreadyAssigned.new("Bareword '#{name} is already assigned to #{assigned_value}. In Halunke, you can only assign once.", message_value[0].source_code_position)
42
45
  end
43
46
 
44
47
  private
45
48
 
46
- def determine_name(hstring)
47
- hstring.ruby_value
49
+ def determine_name(unassigned_bareword)
50
+ unassigned_bareword.ruby_value
48
51
  end
49
52
 
50
53
  def determine_allowed_attributes(harray)
@@ -64,6 +67,12 @@ module Halunke
64
67
  })
65
68
  }
66
69
  hdictionary.ruby_value.each_pair do |method_name, fn|
70
+ raise HInvalidMessageName.new("Message name must be a String", method_name.source_code_position) unless method_name.runtime_class.name == "String"
71
+ raise HInvalidMessageName.new("An empty String is not a valid message", method_name.source_code_position) if method_name.ruby_value == ""
72
+ raise HInvalidMessageName.new("A message can't start with a space", method_name.source_code_position) if method_name.ruby_value.start_with? " "
73
+ raise HInvalidMessageName.new("A message can't stop with a space", method_name.source_code_position) if method_name.ruby_value.end_with? " "
74
+ raise HInvalidMessageName.new("The parts of the message need to be separated by a single space", method_name.source_code_position) if method_name.ruby_value.match(/ {2,}/)
75
+
67
76
  instance_methods[method_name.ruby_value] = fn
68
77
  end
69
78
  instance_methods
@@ -1,3 +1,3 @@
1
1
  module Halunke
2
- VERSION = "0.9.0"
2
+ VERSION = "0.10.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: halunke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Dohmen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-05 00:00:00.000000000 Z
11
+ date: 2019-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack