wirb 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +4 -0
- data/lib/wirb.rb +1 -1
- data/lib/wirb/tokenizer.rb +11 -4
- metadata +3 -3
data/CHANGELOG.rdoc
CHANGED
data/lib/wirb.rb
CHANGED
data/lib/wirb/tokenizer.rb
CHANGED
@@ -8,11 +8,12 @@ class << Wirb
|
|
8
8
|
|
9
9
|
chars = str.split(//)
|
10
10
|
|
11
|
-
@state, @token, i
|
11
|
+
@state, @token, @passed, i = [], '', '', 0
|
12
12
|
|
13
13
|
# helpers
|
14
14
|
pass_custom_state = lambda{ |kind, *options|
|
15
15
|
yield kind, @token unless @token.empty?
|
16
|
+
@passed << @token
|
16
17
|
@state.pop if options.include?(:remove)
|
17
18
|
@token = '' unless options.include?(:keep_token)
|
18
19
|
@repeat = true if options.include?(:repeat)
|
@@ -20,7 +21,7 @@ class << Wirb
|
|
20
21
|
|
21
22
|
pass_state = lambda{ |*options| pass_custom_state[ @state[-1], *options ] }
|
22
23
|
|
23
|
-
pass = lambda{ |kind, string| yield kind, string }
|
24
|
+
pass = lambda{ |kind, string| @passed << string; yield kind, string }
|
24
25
|
|
25
26
|
set_state = lambda{ |state| @state[-1] = state }
|
26
27
|
|
@@ -174,6 +175,9 @@ class << Wirb
|
|
174
175
|
when :number
|
175
176
|
if c =~ /[0-9e+.-]/ && !(c == '.' && nc == '.')
|
176
177
|
@token << c
|
178
|
+
elsif c == '/' # ruby 1.8 mathn
|
179
|
+
pass_state[]
|
180
|
+
pass[:rational_separator, '/']
|
177
181
|
else
|
178
182
|
pass_state[:remove, :repeat]
|
179
183
|
end
|
@@ -189,7 +193,7 @@ class << Wirb
|
|
189
193
|
case c
|
190
194
|
when '('
|
191
195
|
pass[:open_rational, '(']
|
192
|
-
when /[0-
|
196
|
+
when /[0-9-]/
|
193
197
|
push_state[:number, :repeat]
|
194
198
|
when '/', ','
|
195
199
|
pass[:rational_separator, c]
|
@@ -296,11 +300,14 @@ class << Wirb
|
|
296
300
|
# raise "unknown state #{@state[-1]} #{@state.inspect}"
|
297
301
|
end
|
298
302
|
|
299
|
-
# TODO infinite recursion detection
|
303
|
+
# TODO infinite recursion detection
|
300
304
|
|
301
305
|
# next round :)
|
302
306
|
i += 1 unless @repeat
|
303
307
|
end
|
308
|
+
rescue
|
309
|
+
# p$!
|
310
|
+
pass[:default, str.gsub(/^#{@passed}/, '')]
|
304
311
|
end
|
305
312
|
end
|
306
313
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jan Lelis
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-28 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|