Skip to content

Commit 15adb9b

Browse files
author
Ben Miller
committed
let unicode characters through the pure ruby lexer
ruby isn't going to mishandle these so we might as well allow them
1 parent 9776d87 commit 15adb9b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/ios_parser/lexer.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ def word?
287287
('A'..'Z').cover?(char) ||
288288
['-', '+', '$', ':', '/', ',', '(', ')', '|', '*', '#', '=', '<', '>',
289289
'!', '"', '&', '@', ';', '%', '~', '{', '}', "'", '?', '[', ']', '_',
290-
'^', '\\', '`'].include?(char)
290+
'^', '\\', '`'].include?(char) ||
291+
/[[:graph:]]/.match(char)
291292
end
292293

293294
def space

spec/lib/ios_parser/pure_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require_relative '../../spec_helper'
2+
require 'ios_parser'
3+
require 'ios_parser/lexer'
4+
5+
module IOSParser
6+
describe PureLexer do
7+
describe '#call' do
8+
it 'accepts non-whitespace printable characters as words' do
9+
input = "before emdash – after emdash"
10+
tokens = PureLexer.new.call(input)
11+
expect(tokens.map(&:value)).to eq %w[before emdash after emdash]
12+
expect(tokens.map(&:col)).to eq [1, 8, 15, 17, 23]
13+
end
14+
end
15+
end
16+
end

0 commit comments

Comments
 (0)