rubylisp 1.0.7 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubylisp/tokenizer.rb +14 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19a21b82aeba5d0b46584080bf3625d60fb3b49d
|
4
|
+
data.tar.gz: 009daa5e7fef562898b0bbbe8c06816887c12fb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd899d823e85dd7d9a812aca7e8b75b94550c4ee4abc193e881dc17d80a4a410e22cead3a62ec286c4ff4aee28e84ea5bf6633893b52fd8a3ca30f324e4d9cc9
|
7
|
+
data.tar.gz: 821ddee478d4b52f13435e29dbb40705401dfaeb7788ad62fc2fd463a29eb4ad9a2a7db8d9213a523f12175b3e530b0033da9bc622b161edae2cde1946ae928a
|
data/lib/rubylisp/tokenizer.rb
CHANGED
@@ -4,15 +4,16 @@ module Lisp
|
|
4
4
|
|
5
5
|
attr_reader :line_number
|
6
6
|
|
7
|
-
def self.from_string(str)
|
8
|
-
self.new(StringIO.new(str, "r"))
|
7
|
+
def self.from_string(str, absorb_space=true)
|
8
|
+
self.new(StringIO.new(str, "r"), absorb_space)
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.from_file(f)
|
12
12
|
self.new(f)
|
13
13
|
end
|
14
14
|
|
15
|
-
def initialize(src)
|
15
|
+
def initialize(src, absorb_space=true)
|
16
|
+
@absorb_whitespace = absorb_space
|
16
17
|
@source = src
|
17
18
|
@lookahead_token = nil
|
18
19
|
@lookahead_literal = ''
|
@@ -209,13 +210,16 @@ module Lisp
|
|
209
210
|
def read_next_token
|
210
211
|
return :EOF, '' if eof?
|
211
212
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
213
|
+
if @absorb_whitespace
|
214
|
+
while space?(@current_ch)
|
215
|
+
@line_number += 1 if @current_ch == "\n"
|
216
|
+
advance
|
217
|
+
return :EOF, '' if eof?
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
if !@absorb_whitespace && space?(@current_ch)
|
222
|
+
@line_number += 1 if @current_ch == "\n"
|
219
223
|
advance
|
220
224
|
return :WHITESPACE, " "
|
221
225
|
elsif number?(@current_ch)
|