Permalink
Browse files

Consolidate whitespace cases that all return the same triple

  • Loading branch information...
sferik authored and kr committed Feb 17, 2013
1 parent cee24d7 commit 2ea7ee607b1fe5f6fc992174946cc2648392499f
Showing with 15 additions and 17 deletions.
  1. +14 −16 okjson.rb
  2. +1 −1 tested-on
View
@@ -28,7 +28,7 @@
# http://golang.org/src/pkg/json/decode.go and
# http://golang.org/src/pkg/utf8/utf8.go
module OkJson
- Upstream = '40'
+ Upstream = '41'
extend self
@@ -223,21 +223,19 @@ def lex(s)
# it is the lexeme.
def tok(s)
case s[0]
- when ?{ then ['{', s[0,1], s[0,1]]
- when ?} then ['}', s[0,1], s[0,1]]
- when ?: then [':', s[0,1], s[0,1]]
- when ?, then [',', s[0,1], s[0,1]]
- when ?[ then ['[', s[0,1], s[0,1]]
- when ?] then [']', s[0,1], s[0,1]]
- when ?n then nulltok(s)
- when ?t then truetok(s)
- when ?f then falsetok(s)
- when ?" then strtok(s)
- when Spc then [:space, s[0,1], s[0,1]]
- when ?\t then [:space, s[0,1], s[0,1]]
- when ?\n then [:space, s[0,1], s[0,1]]
- when ?\r then [:space, s[0,1], s[0,1]]
- else numtok(s)
+ when ?{ then ['{', s[0,1], s[0,1]]
+ when ?} then ['}', s[0,1], s[0,1]]
+ when ?: then [':', s[0,1], s[0,1]]
+ when ?, then [',', s[0,1], s[0,1]]
+ when ?[ then ['[', s[0,1], s[0,1]]
+ when ?] then [']', s[0,1], s[0,1]]
+ when ?n then nulltok(s)
+ when ?t then truetok(s)
+ when ?f then falsetok(s)
+ when ?" then strtok(s)
+ when Spc, ?\t, ?\n, ?\r then [:space, s[0,1], s[0,1]]
+ else
+ numtok(s)
end
end
View
@@ -1,4 +1,4 @@
-This commit was tested Tue Mar 19 23:54:47 PDT 2013
+This commit was tested Tue Mar 19 23:57:55 PDT 2013
using the following ruby interpreters:
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin11.3.0]
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.2.0]

0 comments on commit 2ea7ee6

Please sign in to comment.