rubic 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rubic +20 -0
- data/lib/rubic.rb +4 -0
- data/lib/rubic/environment.rb +2 -4
- data/lib/rubic/interpreter.rb +19 -2
- data/lib/rubic/parser.rb +161 -93
- data/lib/rubic/parser.y +31 -2
- data/lib/rubic/version.rb +1 -1
- data/rubic.gemspec +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2bade99b079979ddaf7b42551451939fef2ada1
|
4
|
+
data.tar.gz: d9a0095e5552d69ca3a9dfade6de63c50f268642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36af5fb982d96dc3b615587cddf10509071e3a339468a00dd05a325069bd04bfb46189f4a644f52bce1722d0271144998c760c9255e6db8d609bc9a40f139191
|
7
|
+
data.tar.gz: 77c4ab92c10839778e319241a8b7921a3ba1d1fc4dd8554ddd8ed3dbe8c1351e1ebe3ab80b38062ddda7258ffa107b47da1398e373896b67be718387cd83f029
|
data/bin/rubic
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubic'
|
4
|
+
require 'readline'
|
5
|
+
|
6
|
+
# TODO: read the code from file when argument passed
|
7
|
+
|
8
|
+
puts "Welcome to interactive Rubic (v#{Rubic::VERSION})"
|
9
|
+
puts 'Hit ^D to exit'
|
10
|
+
|
11
|
+
rubic = Rubic::Interpreter.new
|
12
|
+
|
13
|
+
while input = Readline.readline(">> ", true)
|
14
|
+
next if input.empty?
|
15
|
+
begin
|
16
|
+
puts '=> ' + rubic.evaluate(input).inspect
|
17
|
+
rescue Rubic::RubicError => e
|
18
|
+
puts "#{e.class}: #{e.message}"
|
19
|
+
end
|
20
|
+
end
|
data/lib/rubic.rb
CHANGED
data/lib/rubic/environment.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
module Rubic
|
2
|
-
class RubicRuntimeError < StandardError; end
|
3
|
-
|
4
2
|
class Environment
|
5
3
|
def initialize(outer=nil)
|
6
4
|
@outer = outer
|
@@ -17,13 +15,13 @@ module Rubic
|
|
17
15
|
elsif @outer
|
18
16
|
@outer.refvar(name)
|
19
17
|
else
|
20
|
-
raise
|
18
|
+
raise Rubic::NameError, "undefined variable `#{name}'"
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
24
22
|
def bind(params, args)
|
25
23
|
if params.size != args.size
|
26
|
-
raise
|
24
|
+
raise Rubic::ArgumentError, "wrong number of arguments (#{args.size} for #{params.size})"
|
27
25
|
end
|
28
26
|
|
29
27
|
params.each.with_index do |name, i|
|
data/lib/rubic/interpreter.rb
CHANGED
@@ -51,7 +51,7 @@ module Rubic
|
|
51
51
|
env[name] = -> (*args) do
|
52
52
|
local = Environment.new(env)
|
53
53
|
local.bind(params, args)
|
54
|
-
body
|
54
|
+
execute_sequence(body, local)
|
55
55
|
end
|
56
56
|
return
|
57
57
|
when :cond
|
@@ -77,13 +77,30 @@ module Rubic
|
|
77
77
|
return true if execute(expr, env)
|
78
78
|
end
|
79
79
|
return false
|
80
|
+
when :lambda
|
81
|
+
_, (*params), *body = list
|
82
|
+
return -> (*args) do
|
83
|
+
local = Environment.new(env)
|
84
|
+
local.bind(params, args)
|
85
|
+
execute_sequence(body, local)
|
86
|
+
end
|
87
|
+
when :let
|
88
|
+
_, (*defs), *body = list
|
89
|
+
local = Environment.new(env)
|
90
|
+
defs.each {|name, expr| local[name] = execute(expr, env) }
|
91
|
+
return execute_sequence(body, local)
|
80
92
|
else
|
81
93
|
# fallthrough
|
82
94
|
end
|
83
95
|
|
84
|
-
#
|
96
|
+
# Procedure call
|
85
97
|
op, *args = list.map {|e| execute(e, env) }
|
86
98
|
op.call(*args)
|
87
99
|
end
|
100
|
+
|
101
|
+
def execute_sequence(seq, env)
|
102
|
+
# execute expressions sequentially and returns the last result
|
103
|
+
seq.reduce(nil) {|res, expr| res = execute(expr, env) }
|
104
|
+
end
|
88
105
|
end
|
89
106
|
end
|
data/lib/rubic/parser.rb
CHANGED
@@ -9,11 +9,10 @@ require 'racc/parser.rb'
|
|
9
9
|
require 'strscan'
|
10
10
|
|
11
11
|
module Rubic
|
12
|
-
class UnknownCharacterError < StandardError; end
|
13
12
|
|
14
13
|
class Parser < Racc::Parser
|
15
14
|
|
16
|
-
module_eval(<<'...end parser.y/module_eval...', 'parser.y',
|
15
|
+
module_eval(<<'...end parser.y/module_eval...', 'parser.y', 113)
|
17
16
|
EOT = [false, nil] # end of token
|
18
17
|
SYM_CHARS = Regexp.escape("+-*/<>=?")
|
19
18
|
|
@@ -45,98 +44,128 @@ def next_token
|
|
45
44
|
[:KW_AND, nil]
|
46
45
|
when 'or'
|
47
46
|
[:KW_OR, nil]
|
47
|
+
when 'lambda'
|
48
|
+
[:KW_LAMBDA, nil]
|
49
|
+
when 'let'
|
50
|
+
[:KW_LET, nil]
|
48
51
|
else
|
49
52
|
[:IDENT, @s[0]]
|
50
53
|
end
|
51
54
|
else
|
52
|
-
raise
|
55
|
+
raise Rubic::ParseError, "unknown character #{@s.getch}"
|
53
56
|
end
|
54
57
|
end
|
55
58
|
|
59
|
+
def on_error(t, val, vstack)
|
60
|
+
raise Rubic::ParseError, "parse error near #{token_to_str(t)}"
|
61
|
+
end
|
62
|
+
|
56
63
|
...end parser.y/module_eval...
|
57
64
|
##### State transition tables begin ###
|
58
65
|
|
59
66
|
racc_action_table = [
|
60
|
-
2,
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
4,
|
67
|
+
2, 12, 38, 13, 3, 4, 15, 16, 2, 17,
|
68
|
+
18, 19, 3, 4, 2, 57, 42, 2, 3, 4,
|
69
|
+
2, 3, 4, 2, 3, 4, 2, 3, 4, 26,
|
70
|
+
3, 4, 2, 25, 64, 58, 3, 4, 2, 56,
|
71
|
+
63, 2, 3, 4, 2, 3, 4, 2, 3, 4,
|
72
|
+
32, 3, 4, 2, 52, 33, 51, 3, 4, 2,
|
73
|
+
29, 35, 39, 3, 4, 2, 61, 36, 2, 3,
|
74
|
+
4, 2, 3, 4, 2, 3, 4, 31, 3, 4,
|
75
|
+
2, 29, 66, 2, 3, 4, 2, 3, 4, 2,
|
76
|
+
3, 4, 46, 3, 4, 54, 55, 53, 51, 20,
|
77
|
+
11, 67 ]
|
68
78
|
|
69
79
|
racc_action_check = [
|
70
|
-
2, 2,
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
80
|
+
2, 2, 26, 2, 2, 2, 2, 2, 29, 2,
|
81
|
+
2, 2, 29, 29, 55, 49, 29, 61, 55, 55,
|
82
|
+
12, 61, 61, 13, 12, 12, 14, 13, 13, 15,
|
83
|
+
14, 14, 60, 15, 60, 50, 60, 60, 59, 48,
|
84
|
+
59, 17, 59, 59, 0, 17, 17, 53, 0, 0,
|
85
|
+
19, 53, 53, 21, 44, 21, 44, 21, 21, 23,
|
86
|
+
27, 23, 27, 23, 23, 24, 54, 24, 25, 24,
|
87
|
+
24, 52, 25, 25, 43, 52, 52, 18, 43, 43,
|
88
|
+
62, 16, 62, 41, 62, 62, 42, 41, 41, 30,
|
89
|
+
42, 42, 37, 30, 30, 45, 47, 45, 47, 11,
|
90
|
+
1, 65 ]
|
78
91
|
|
79
92
|
racc_action_pointer = [
|
80
|
-
|
81
|
-
|
82
|
-
57,
|
83
|
-
nil,
|
84
|
-
|
93
|
+
42, 100, -2, nil, nil, nil, nil, nil, nil, nil,
|
94
|
+
nil, 99, 18, 21, 24, 27, 79, 39, 75, 48,
|
95
|
+
nil, 51, nil, 57, 63, 66, -4, 58, nil, 6,
|
96
|
+
87, nil, nil, nil, nil, nil, nil, 88, nil, nil,
|
97
|
+
nil, 81, 84, 72, 50, 93, nil, 92, 35, 11,
|
98
|
+
31, nil, 69, 45, 60, 12, nil, nil, nil, 36,
|
99
|
+
30, 15, 78, nil, nil, 97, nil, nil ]
|
85
100
|
|
86
101
|
racc_action_default = [
|
87
|
-
-
|
88
|
-
-
|
89
|
-
-
|
90
|
-
|
91
|
-
-
|
102
|
+
-28, -28, -28, -4, -5, -6, -7, -8, -9, -10,
|
103
|
+
-11, -28, -28, -28, -28, -28, -28, -28, -28, -28,
|
104
|
+
68, -28, -12, -28, -28, -28, -28, -28, -19, -28,
|
105
|
+
-28, -16, -26, -1, -13, -2, -3, -28, -16, -18,
|
106
|
+
-20, -28, -28, -28, -28, -28, -14, -28, -28, -28,
|
107
|
+
-28, -17, -28, -28, -28, -28, -21, -22, -23, -28,
|
108
|
+
-28, -28, -28, -24, -25, -28, -15, -27 ]
|
92
109
|
|
93
110
|
racc_goto_table = [
|
94
|
-
1,
|
95
|
-
|
96
|
-
|
97
|
-
nil, nil, nil, nil, nil,
|
98
|
-
nil,
|
111
|
+
1, 28, 14, 44, 21, 23, 24, 27, 45, nil,
|
112
|
+
47, nil, 40, nil, nil, nil, nil, 30, nil, nil,
|
113
|
+
nil, 34, nil, 34, 34, 37, nil, nil, nil, 41,
|
114
|
+
43, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
115
|
+
nil, 48, 49, 50, 59, 60, nil, 62, nil, nil,
|
116
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, 34,
|
117
|
+
34, 65, 34 ]
|
99
118
|
|
100
119
|
racc_goto_check = [
|
101
|
-
1,
|
102
|
-
9, nil, nil, nil, nil,
|
103
|
-
|
104
|
-
nil, nil, nil, nil, nil,
|
105
|
-
nil,
|
120
|
+
1, 11, 1, 9, 2, 2, 2, 10, 12, nil,
|
121
|
+
9, nil, 11, nil, nil, nil, nil, 1, nil, nil,
|
122
|
+
nil, 1, nil, 1, 1, 1, nil, nil, nil, 1,
|
123
|
+
1, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
124
|
+
nil, 1, 1, 1, 2, 2, nil, 2, nil, nil,
|
125
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, 1,
|
126
|
+
1, 1, 1 ]
|
106
127
|
|
107
128
|
racc_goto_pointer = [
|
108
|
-
nil, 0, -
|
129
|
+
nil, 0, -8, nil, nil, nil, nil, nil, nil, -28,
|
130
|
+
-9, -15, -24 ]
|
109
131
|
|
110
132
|
racc_goto_default = [
|
111
|
-
nil,
|
133
|
+
nil, 22, nil, 5, 6, 7, 8, 9, 10, nil,
|
134
|
+
nil, nil, nil ]
|
112
135
|
|
113
136
|
racc_reduce_table = [
|
114
137
|
0, 0, :racc_error,
|
115
|
-
4,
|
116
|
-
4,
|
117
|
-
4,
|
118
|
-
1,
|
119
|
-
1,
|
120
|
-
1,
|
121
|
-
1,
|
122
|
-
1,
|
123
|
-
1,
|
124
|
-
1,
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
138
|
+
4, 15, :_reduce_1,
|
139
|
+
4, 15, :_reduce_2,
|
140
|
+
4, 15, :_reduce_3,
|
141
|
+
1, 15, :_reduce_none,
|
142
|
+
1, 15, :_reduce_none,
|
143
|
+
1, 15, :_reduce_none,
|
144
|
+
1, 15, :_reduce_none,
|
145
|
+
1, 15, :_reduce_none,
|
146
|
+
1, 15, :_reduce_none,
|
147
|
+
1, 15, :_reduce_none,
|
148
|
+
1, 15, :_reduce_none,
|
149
|
+
1, 16, :_reduce_12,
|
150
|
+
2, 16, :_reduce_13,
|
151
|
+
5, 17, :_reduce_14,
|
152
|
+
8, 18, :_reduce_15,
|
153
|
+
0, 23, :_reduce_16,
|
154
|
+
2, 23, :_reduce_17,
|
155
|
+
4, 19, :_reduce_18,
|
156
|
+
1, 24, :_reduce_19,
|
157
|
+
2, 24, :_reduce_20,
|
158
|
+
4, 25, :_reduce_21,
|
159
|
+
4, 25, :_reduce_22,
|
160
|
+
6, 20, :_reduce_23,
|
161
|
+
7, 21, :_reduce_24,
|
162
|
+
7, 22, :_reduce_25,
|
163
|
+
0, 26, :_reduce_26,
|
164
|
+
5, 26, :_reduce_27 ]
|
165
|
+
|
166
|
+
racc_reduce_n = 28
|
167
|
+
|
168
|
+
racc_shift_n = 68
|
140
169
|
|
141
170
|
racc_token_table = {
|
142
171
|
false => 0,
|
@@ -150,9 +179,11 @@ racc_token_table = {
|
|
150
179
|
:KW_DEFINE => 8,
|
151
180
|
:KW_COND => 9,
|
152
181
|
:KW_ELSE => 10,
|
153
|
-
:KW_IF => 11
|
182
|
+
:KW_IF => 11,
|
183
|
+
:KW_LAMBDA => 12,
|
184
|
+
:KW_LET => 13 }
|
154
185
|
|
155
|
-
racc_nt_base =
|
186
|
+
racc_nt_base = 14
|
156
187
|
|
157
188
|
racc_use_result_var = false
|
158
189
|
|
@@ -185,6 +216,8 @@ Racc_token_to_s_table = [
|
|
185
216
|
"KW_COND",
|
186
217
|
"KW_ELSE",
|
187
218
|
"KW_IF",
|
219
|
+
"KW_LAMBDA",
|
220
|
+
"KW_LET",
|
188
221
|
"$start",
|
189
222
|
"expr",
|
190
223
|
"seq",
|
@@ -192,9 +225,12 @@ Racc_token_to_s_table = [
|
|
192
225
|
"define_proc",
|
193
226
|
"cond",
|
194
227
|
"if",
|
228
|
+
"lambda",
|
229
|
+
"let",
|
195
230
|
"params",
|
196
231
|
"clauses",
|
197
|
-
"clause"
|
232
|
+
"clause",
|
233
|
+
"defs" ]
|
198
234
|
|
199
235
|
Racc_debug_parser = false
|
200
236
|
|
@@ -235,90 +271,122 @@ module_eval(<<'.,.,', 'parser.y', 14)
|
|
235
271
|
|
236
272
|
# reduce 9 omitted
|
237
273
|
|
238
|
-
|
239
|
-
|
274
|
+
# reduce 10 omitted
|
275
|
+
|
276
|
+
# reduce 11 omitted
|
277
|
+
|
278
|
+
module_eval(<<'.,.,', 'parser.y', 27)
|
279
|
+
def _reduce_12(val, _values)
|
240
280
|
[val[0]]
|
241
281
|
|
242
282
|
end
|
243
283
|
.,.,
|
244
284
|
|
245
|
-
module_eval(<<'.,.,', 'parser.y',
|
246
|
-
def
|
285
|
+
module_eval(<<'.,.,', 'parser.y', 31)
|
286
|
+
def _reduce_13(val, _values)
|
247
287
|
val[0].push(val[1])
|
248
288
|
|
249
289
|
end
|
250
290
|
.,.,
|
251
291
|
|
252
|
-
module_eval(<<'.,.,', 'parser.y',
|
253
|
-
def
|
292
|
+
module_eval(<<'.,.,', 'parser.y', 37)
|
293
|
+
def _reduce_14(val, _values)
|
254
294
|
[:define, val[2], val[3]]
|
255
295
|
|
256
296
|
end
|
257
297
|
.,.,
|
258
298
|
|
259
|
-
module_eval(<<'.,.,', 'parser.y',
|
260
|
-
def
|
299
|
+
module_eval(<<'.,.,', 'parser.y', 43)
|
300
|
+
def _reduce_15(val, _values)
|
261
301
|
[:define_proc, [val[3], *val[4]], *val[6]]
|
262
302
|
|
263
303
|
end
|
264
304
|
.,.,
|
265
305
|
|
266
|
-
module_eval(<<'.,.,', 'parser.y',
|
267
|
-
def
|
306
|
+
module_eval(<<'.,.,', 'parser.y', 48)
|
307
|
+
def _reduce_16(val, _values)
|
268
308
|
[]
|
269
309
|
|
270
310
|
end
|
271
311
|
.,.,
|
272
312
|
|
273
|
-
module_eval(<<'.,.,', 'parser.y',
|
274
|
-
def
|
313
|
+
module_eval(<<'.,.,', 'parser.y', 52)
|
314
|
+
def _reduce_17(val, _values)
|
275
315
|
val[0].push(val[1])
|
276
316
|
|
277
317
|
end
|
278
318
|
.,.,
|
279
319
|
|
280
|
-
module_eval(<<'.,.,', 'parser.y',
|
281
|
-
def
|
320
|
+
module_eval(<<'.,.,', 'parser.y', 58)
|
321
|
+
def _reduce_18(val, _values)
|
282
322
|
[:cond, *val[2]]
|
283
323
|
|
284
324
|
end
|
285
325
|
.,.,
|
286
326
|
|
287
|
-
module_eval(<<'.,.,', 'parser.y',
|
288
|
-
def
|
327
|
+
module_eval(<<'.,.,', 'parser.y', 63)
|
328
|
+
def _reduce_19(val, _values)
|
289
329
|
[val[0]]
|
290
330
|
|
291
331
|
end
|
292
332
|
.,.,
|
293
333
|
|
294
|
-
module_eval(<<'.,.,', 'parser.y',
|
295
|
-
def
|
334
|
+
module_eval(<<'.,.,', 'parser.y', 67)
|
335
|
+
def _reduce_20(val, _values)
|
296
336
|
val[0].push(val[1])
|
297
337
|
|
298
338
|
end
|
299
339
|
.,.,
|
300
340
|
|
301
|
-
module_eval(<<'.,.,', 'parser.y',
|
302
|
-
def
|
341
|
+
module_eval(<<'.,.,', 'parser.y', 72)
|
342
|
+
def _reduce_21(val, _values)
|
303
343
|
[val[1], val[2]]
|
304
344
|
|
305
345
|
end
|
306
346
|
.,.,
|
307
347
|
|
308
|
-
module_eval(<<'.,.,', 'parser.y',
|
309
|
-
def
|
348
|
+
module_eval(<<'.,.,', 'parser.y', 76)
|
349
|
+
def _reduce_22(val, _values)
|
310
350
|
[:else, val[2]]
|
311
351
|
|
312
352
|
end
|
313
353
|
.,.,
|
314
354
|
|
315
|
-
module_eval(<<'.,.,', 'parser.y',
|
316
|
-
def
|
355
|
+
module_eval(<<'.,.,', 'parser.y', 82)
|
356
|
+
def _reduce_23(val, _values)
|
317
357
|
[:if, val[2], val[3], val[4]]
|
318
358
|
|
319
359
|
end
|
320
360
|
.,.,
|
321
361
|
|
362
|
+
module_eval(<<'.,.,', 'parser.y', 88)
|
363
|
+
def _reduce_24(val, _values)
|
364
|
+
[:lambda, val[3], *val[5]]
|
365
|
+
|
366
|
+
end
|
367
|
+
.,.,
|
368
|
+
|
369
|
+
module_eval(<<'.,.,', 'parser.y', 94)
|
370
|
+
def _reduce_25(val, _values)
|
371
|
+
[:let, val[3], *val[5]]
|
372
|
+
|
373
|
+
end
|
374
|
+
.,.,
|
375
|
+
|
376
|
+
module_eval(<<'.,.,', 'parser.y', 98)
|
377
|
+
def _reduce_26(val, _values)
|
378
|
+
[]
|
379
|
+
|
380
|
+
end
|
381
|
+
.,.,
|
382
|
+
|
383
|
+
module_eval(<<'.,.,', 'parser.y', 102)
|
384
|
+
def _reduce_27(val, _values)
|
385
|
+
val[0].push([val[2], val[3]])
|
386
|
+
|
387
|
+
end
|
388
|
+
.,.,
|
389
|
+
|
322
390
|
def _reduce_none(val, _values)
|
323
391
|
val[0]
|
324
392
|
end
|
data/lib/rubic/parser.y
CHANGED
@@ -20,6 +20,8 @@ rule
|
|
20
20
|
| define_proc
|
21
21
|
| cond
|
22
22
|
| if
|
23
|
+
| lambda
|
24
|
+
| let
|
23
25
|
|
24
26
|
seq : expr
|
25
27
|
{
|
@@ -80,13 +82,32 @@ rule
|
|
80
82
|
{
|
81
83
|
[:if, val[2], val[3], val[4]]
|
82
84
|
}
|
85
|
+
|
86
|
+
/* lambda expression */
|
87
|
+
lambda : '(' KW_LAMBDA '(' params ')' seq ')'
|
88
|
+
{
|
89
|
+
[:lambda, val[3], *val[5]]
|
90
|
+
}
|
91
|
+
|
92
|
+
/* let expression */
|
93
|
+
let : '(' KW_LET '(' defs ')' seq ')'
|
94
|
+
{
|
95
|
+
[:let, val[3], *val[5]]
|
96
|
+
}
|
97
|
+
defs : /* empty */
|
98
|
+
{
|
99
|
+
[]
|
100
|
+
}
|
101
|
+
| defs '(' IDENT expr ')'
|
102
|
+
{
|
103
|
+
val[0].push([val[2], val[3]])
|
104
|
+
}
|
83
105
|
end
|
84
106
|
|
85
107
|
---- header
|
86
108
|
require 'strscan'
|
87
109
|
|
88
110
|
module Rubic
|
89
|
-
class UnknownCharacterError < StandardError; end
|
90
111
|
|
91
112
|
---- inner
|
92
113
|
EOT = [false, nil] # end of token
|
@@ -120,13 +141,21 @@ def next_token
|
|
120
141
|
[:KW_AND, nil]
|
121
142
|
when 'or'
|
122
143
|
[:KW_OR, nil]
|
144
|
+
when 'lambda'
|
145
|
+
[:KW_LAMBDA, nil]
|
146
|
+
when 'let'
|
147
|
+
[:KW_LET, nil]
|
123
148
|
else
|
124
149
|
[:IDENT, @s[0]]
|
125
150
|
end
|
126
151
|
else
|
127
|
-
raise
|
152
|
+
raise Rubic::ParseError, "unknown character #{@s.getch}"
|
128
153
|
end
|
129
154
|
end
|
130
155
|
|
156
|
+
def on_error(t, val, vstack)
|
157
|
+
raise Rubic::ParseError, "parse error near #{token_to_str(t)}"
|
158
|
+
end
|
159
|
+
|
131
160
|
---- footer
|
132
161
|
end # of module Rubic
|
data/lib/rubic/version.rb
CHANGED
data/rubic.gemspec
CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
18
|
spec.require_paths = ["lib"]
|
19
|
+
spec.executables = ['rubic']
|
19
20
|
|
20
21
|
spec.add_development_dependency "bundler", "~> 1.9"
|
21
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- notozeki
|
@@ -69,7 +69,8 @@ dependencies:
|
|
69
69
|
description: Rubic is a very simple Scheme interpreter written in Ruby.
|
70
70
|
email:
|
71
71
|
- notozeki@gmail.com
|
72
|
-
executables:
|
72
|
+
executables:
|
73
|
+
- rubic
|
73
74
|
extensions: []
|
74
75
|
extra_rdoc_files: []
|
75
76
|
files:
|
@@ -80,6 +81,7 @@ files:
|
|
80
81
|
- README.md
|
81
82
|
- Rakefile
|
82
83
|
- bin/console
|
84
|
+
- bin/rubic
|
83
85
|
- bin/setup
|
84
86
|
- lib/rubic.rb
|
85
87
|
- lib/rubic/environment.rb
|