Skip to content
This repository has been archived by the owner on May 7, 2018. It is now read-only.

Commit

Permalink
Consolidate whitespace cases that all return the same triple
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik authored and kr committed Mar 20, 2013
1 parent cee24d7 commit 2ea7ee6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
30 changes: 14 additions & 16 deletions okjson.rb
Expand Up @@ -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


Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tested-on
@@ -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]
Expand Down

0 comments on commit 2ea7ee6

Please sign in to comment.