eye-of-newt 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/eye_of_newt.gemspec +2 -2
- data/lib/eye_of_newt/parser.rb +65 -59
- data/lib/eye_of_newt/parser.y +2 -0
- data/lib/eye_of_newt/version.rb +1 -1
- data/test/examples.txt +6 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de4710dcb531ffd8b1874697da048da3b8c86692
|
4
|
+
data.tar.gz: e13c944fe7319f5487d03d1f16fd7c16640684cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83f7233696d639af0a6c1396f2b39962a6eec892b1eea04d7dff864b96aef26042d8abade4e096654cf4bf38719bd7b1fcbd2218628c617224dbc58fa39c6a74
|
7
|
+
data.tar.gz: 227d72db1af79cb8557c8dab469d07bbdd06c34ff2ca50f867f885c884194e5684d6e9ebd6ad2d426e6024f5ea6cb2e78154ad83205314bbfa4ef4314a793ce1
|
data/eye_of_newt.gemspec
CHANGED
@@ -24,6 +24,6 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "rake", "~> 10"
|
25
25
|
spec.add_development_dependency "racc", "~> 1"
|
26
26
|
spec.add_development_dependency "pry", "~> 0"
|
27
|
-
spec.add_development_dependency "pry-byebug", "~>
|
28
|
-
spec.add_development_dependency "pry-rescue", "~>
|
27
|
+
spec.add_development_dependency "pry-byebug", "~> 1"
|
28
|
+
spec.add_development_dependency "pry-rescue", "~> 1"
|
29
29
|
end
|
data/lib/eye_of_newt/parser.rb
CHANGED
@@ -37,50 +37,50 @@ module EyeOfNewt
|
|
37
37
|
##### State transition tables begin ###
|
38
38
|
|
39
39
|
racc_action_table = [
|
40
|
-
-
|
41
|
-
-
|
42
|
-
|
43
|
-
|
40
|
+
-32, 12, 22, 23, 24, 13, 18, 12, -32, -32,
|
41
|
+
-32, 13, 18, 12, 15, 14, 29, 13, 10, 14,
|
42
|
+
33, 26, 23, 24, 31, 32, 23, 24, 27, 16,
|
43
|
+
24, 40, 40, 42, 31, 43, 44, 24, 24, 47 ]
|
44
44
|
|
45
45
|
racc_action_check = [
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
10, 11, 3, 3, 3, 11, 11, 2, 10, 10,
|
47
|
+
10, 2, 2, 0, 0, 0, 7, 0, 0, 5,
|
48
|
+
16, 5, 19, 19, 15, 15, 17, 17, 6, 1,
|
49
|
+
20, 23, 24, 25, 29, 31, 32, 34, 36, 41 ]
|
50
50
|
|
51
51
|
racc_action_pointer = [
|
52
|
-
|
53
|
-
|
54
|
-
nil,
|
55
|
-
|
56
|
-
nil, nil, nil, nil, nil, nil ]
|
52
|
+
11, 29, 5, -6, nil, 15, 22, 13, nil, nil,
|
53
|
+
0, -1, nil, nil, nil, 12, 20, 17, nil, 13,
|
54
|
+
20, nil, nil, 26, 27, 27, nil, nil, nil, 22,
|
55
|
+
nil, 32, 33, nil, 27, nil, 28, nil, nil, nil,
|
56
|
+
nil, 28, nil, nil, nil, nil, nil, nil ]
|
57
57
|
|
58
58
|
racc_action_default = [
|
59
|
-
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
-
|
63
|
-
-14, -
|
59
|
+
-38, -38, -38, -12, -13, -17, -19, -20, -22, -23,
|
60
|
+
-24, -29, -31, -33, -34, -35, -38, -8, -32, -10,
|
61
|
+
-11, -6, -25, -38, -38, -15, -16, -18, -21, -38,
|
62
|
+
-28, -38, -38, 48, -7, -2, -9, -4, -5, -26,
|
63
|
+
-30, -38, -14, -36, -37, -1, -3, -27 ]
|
64
64
|
|
65
65
|
racc_goto_table = [
|
66
|
-
|
67
|
-
5,
|
68
|
-
1, nil, nil, nil, nil, nil, nil, nil, nil,
|
69
|
-
nil,
|
66
|
+
21, 8, 6, 3, 20, 17, 30, 25, 28, 39,
|
67
|
+
41, 5, 19, 7, 35, 2, 37, 38, 34, 9,
|
68
|
+
36, 1, nil, nil, nil, nil, nil, nil, nil, nil,
|
69
|
+
nil, 45, nil, 46 ]
|
70
70
|
|
71
71
|
racc_goto_check = [
|
72
|
-
5, 11,
|
73
|
-
8,
|
74
|
-
1, nil, nil, nil, nil, nil, nil, nil, nil,
|
75
|
-
nil, 5 ]
|
72
|
+
5, 11, 9, 3, 4, 3, 7, 9, 11, 13,
|
73
|
+
13, 8, 6, 10, 5, 2, 5, 5, 4, 12,
|
74
|
+
4, 1, nil, nil, nil, nil, nil, nil, nil, nil,
|
75
|
+
nil, 5, nil, 5 ]
|
76
76
|
|
77
77
|
racc_goto_pointer = [
|
78
|
-
nil,
|
79
|
-
13, 1, 19, -
|
78
|
+
nil, 21, 15, 3, 1, -3, 9, -5, 11, 2,
|
79
|
+
13, 1, 19, -14, nil ]
|
80
80
|
|
81
81
|
racc_goto_default = [
|
82
82
|
nil, nil, nil, nil, nil, nil, nil, 4, nil, nil,
|
83
|
-
nil, nil, nil, nil,
|
83
|
+
nil, nil, nil, nil, 11 ]
|
84
84
|
|
85
85
|
racc_reduce_table = [
|
86
86
|
0, 0, :racc_error,
|
@@ -101,28 +101,30 @@ racc_reduce_table = [
|
|
101
101
|
2, 16, :_reduce_none,
|
102
102
|
2, 16, :_reduce_none,
|
103
103
|
1, 16, :_reduce_none,
|
104
|
-
|
105
|
-
|
104
|
+
2, 16, :_reduce_none,
|
105
|
+
1, 16, :_reduce_none,
|
106
106
|
1, 22, :_reduce_20,
|
107
|
-
|
107
|
+
2, 22, :_reduce_21,
|
108
108
|
1, 22, :_reduce_22,
|
109
|
-
1,
|
110
|
-
|
111
|
-
|
112
|
-
2,
|
109
|
+
1, 22, :_reduce_23,
|
110
|
+
1, 22, :_reduce_24,
|
111
|
+
1, 20, :_reduce_25,
|
112
|
+
2, 18, :_reduce_26,
|
113
|
+
3, 19, :_reduce_27,
|
114
|
+
2, 21, :_reduce_28,
|
113
115
|
1, 21, :_reduce_none,
|
114
116
|
1, 27, :_reduce_none,
|
115
117
|
1, 28, :_reduce_none,
|
116
118
|
1, 28, :_reduce_none,
|
117
119
|
1, 28, :_reduce_none,
|
118
|
-
1, 23, :
|
119
|
-
1, 24, :
|
120
|
-
3, 25, :
|
121
|
-
3, 26, :
|
120
|
+
1, 23, :_reduce_34,
|
121
|
+
1, 24, :_reduce_35,
|
122
|
+
3, 25, :_reduce_36,
|
123
|
+
3, 26, :_reduce_37 ]
|
122
124
|
|
123
|
-
racc_reduce_n =
|
125
|
+
racc_reduce_n = 38
|
124
126
|
|
125
|
-
racc_shift_n =
|
127
|
+
racc_shift_n = 48
|
126
128
|
|
127
129
|
racc_token_table = {
|
128
130
|
false => 0,
|
@@ -234,77 +236,81 @@ end
|
|
234
236
|
|
235
237
|
# reduce 17 omitted
|
236
238
|
|
237
|
-
|
239
|
+
# reduce 18 omitted
|
240
|
+
|
241
|
+
# reduce 19 omitted
|
242
|
+
|
243
|
+
def _reduce_20(val, _values, result)
|
238
244
|
@ingredient.amount = result
|
239
245
|
result
|
240
246
|
end
|
241
247
|
|
242
|
-
def
|
248
|
+
def _reduce_21(val, _values, result)
|
243
249
|
@ingredient.amount = val[0] + val[1]
|
244
250
|
result
|
245
251
|
end
|
246
252
|
|
247
|
-
def
|
253
|
+
def _reduce_22(val, _values, result)
|
248
254
|
@ingredient.amount = result
|
249
255
|
result
|
250
256
|
end
|
251
257
|
|
252
|
-
def
|
258
|
+
def _reduce_23(val, _values, result)
|
253
259
|
@ingredient.amount = result
|
254
260
|
result
|
255
261
|
end
|
256
262
|
|
257
|
-
def
|
263
|
+
def _reduce_24(val, _values, result)
|
258
264
|
@ingredient.amount = 1
|
259
265
|
result
|
260
266
|
end
|
261
267
|
|
262
|
-
def
|
268
|
+
def _reduce_25(val, _values, result)
|
263
269
|
@ingredient.unit = to_unit(result)
|
264
270
|
result
|
265
271
|
end
|
266
272
|
|
267
|
-
def
|
273
|
+
def _reduce_26(val, _values, result)
|
268
274
|
@ingredient.style = val[1]
|
269
275
|
result
|
270
276
|
end
|
271
277
|
|
272
|
-
def
|
278
|
+
def _reduce_27(val, _values, result)
|
273
279
|
@ingredient.note = val[1]
|
274
280
|
result
|
275
281
|
end
|
276
282
|
|
277
|
-
def
|
283
|
+
def _reduce_28(val, _values, result)
|
278
284
|
result = val.join(' ')
|
279
285
|
result
|
280
286
|
end
|
281
287
|
|
282
|
-
# reduce 27 omitted
|
283
|
-
|
284
|
-
# reduce 28 omitted
|
285
|
-
|
286
288
|
# reduce 29 omitted
|
287
289
|
|
288
290
|
# reduce 30 omitted
|
289
291
|
|
290
292
|
# reduce 31 omitted
|
291
293
|
|
292
|
-
|
294
|
+
# reduce 32 omitted
|
295
|
+
|
296
|
+
# reduce 33 omitted
|
297
|
+
|
298
|
+
def _reduce_34(val, _values, result)
|
293
299
|
@ingredient.unit = to_unit(result)
|
294
300
|
result
|
295
301
|
end
|
296
302
|
|
297
|
-
def
|
303
|
+
def _reduce_35(val, _values, result)
|
298
304
|
result = val[0].to_i
|
299
305
|
result
|
300
306
|
end
|
301
307
|
|
302
|
-
def
|
308
|
+
def _reduce_36(val, _values, result)
|
303
309
|
result = val[0].to_f / val[2].to_f
|
304
310
|
result
|
305
311
|
end
|
306
312
|
|
307
|
-
def
|
313
|
+
def _reduce_37(val, _values, result)
|
308
314
|
result = val.join.to_f
|
309
315
|
result
|
310
316
|
end
|
data/lib/eye_of_newt/parser.y
CHANGED
data/lib/eye_of_newt/version.rb
CHANGED
data/test/examples.txt
CHANGED
@@ -12,11 +12,16 @@ tomatoes | tomatoes | 1 | units
|
|
12
12
|
1 cup of flour | flour | 1 | cups
|
13
13
|
1 teaspoon of cream of tartar | cream of tartar | 1 | tsp
|
14
14
|
a pinch of salt | salt | 1 | pinches
|
15
|
+
pinch of salt | salt | 1 | pinches
|
15
16
|
4 large leeks, trimmed & thinly sliced | large leeks | 4 | units | trimmed & thinly sliced
|
16
17
|
3 pounds potatoes, washed and cut into 2-inch chunks | potatoes | 3 | lb | washed and cut into 2-inch chunks
|
17
18
|
salt to taste | salt | 1 | to taste
|
18
19
|
an apple, sliced (I like Fuji, but any variety will do) | apple | 1 | units | sliced | I like Fuji, but any variety will do
|
19
|
-
#4-5 handfuls of spinach, very roughly chopped
|
20
|
+
#4-5 handfuls of spinach, very roughly chopped | spinach | 4-5 | handfuls | very roughly chopped
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
20
25
|
#3 tablespoons sunflower oil, ghee, or clarified butter
|
21
26
|
#1/2 cup crumbled feta, fresh ricotta, or fresh paneer
|
22
27
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eye-of-newt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter McCracken
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -86,28 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '1'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '1'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: pry-rescue
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '1'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '1'
|
111
111
|
description: Parses natural ingredients (e.g. "1 1/2 pounds of potatoes, peeled")
|
112
112
|
into usable parts.
|
113
113
|
email:
|