Skip to content

Commit 41175fb

Browse files
committed
wip
1 parent e273505 commit 41175fb

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

lib/wirb/tokenizer.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,25 @@ def self.run(str)
191191
@token << c
192192
end
193193

194+
when :symbol_string_suffix
195+
## TODO
196+
if c == '"' && ( !( @token =~ /\\+$/; $& ) || $&.size % 2 == 0 ) # see string
197+
pass[:open_symbol_string, '"']
198+
pass_state[:remove]
199+
pass[:close_symbol_string, '"']
200+
else
201+
@token << c
202+
end
203+
194204
when :string
195205
if c == '"' && ( !( @token =~ /\\+$/; $& ) || $&.size % 2 == 0 ) # allow escaping of " and
196-
pass[:open_string, '"'] # work around \\
197-
pass_state[:remove]
198-
pass[:close_string, '"']
206+
if nc != ':'
207+
pass[:open_string, '"'] # work around \\
208+
pass_state[:remove]
209+
pass[:close_string, '"']
210+
else
211+
set_state[:symbol_string_suffix, :repeat]
212+
end
199213
else
200214
@token << c
201215
end

spec/tokenizer_symbol_spec.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,30 @@
163163
[:close_array, "]"],
164164
]
165165
end
166+
167+
please do check({symbol: :style})
168+
tokens.should == [
169+
[:open_hash, "{"],
170+
[:word, "symbol"],
171+
[:symbol_prefix, ":"],
172+
[:whitespace, " "],
173+
[:symbol_prefix, ":"],
174+
[:symbol, "style"],
175+
[:close_hash, "}"],
176+
]
177+
end
178+
179+
please do check({"string symbol": :style})
180+
tokens.should == [
181+
[:open_hash, "{"],
182+
[:open_symbol_string, "\""],
183+
[:symbol_string_suffix, "string symbol"],
184+
[:close_symbol_string, "\""],
185+
[:symbol_prefix, ":"],
186+
[:whitespace, " "],
187+
[:symbol_prefix, ":"],
188+
[:symbol, "style"],
189+
[:close_hash, "}"],
190+
]
191+
end
166192
end

0 commit comments

Comments
 (0)