Skip to content

Commit 4d45b79

Browse files
committed
Simplify sequential arrays to ranges
Prior to this commit, the lexer used arrays of sequential characters (0-9, a-z, A-Z) by explicitly naming each character in the array (e.g. "['0', '1', '2']"). This commit simplifies those arrays to use ranges (e.g. "('0'..'9')") instead.
1 parent 7275de4 commit 4d45b79

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/puppet/pops/parser/lexer2.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ def initialize()
495495

496496
[ ' ', "\t", "\r" ].each { |c| @selector[c] = lambda { @scanner.skip(PATTERN_WS); nil } }
497497

498-
[ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'].each do |c|
498+
('0'..'9').each do |c|
499499
@selector[c] = lambda do
500500
scn = @scanner
501501
before = scn.pos
@@ -529,8 +529,7 @@ def initialize()
529529
end
530530
end
531531
end
532-
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
533-
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '_'].each do |c|
532+
('a'..'z').to_a.push('_').each do |c|
534533
@selector[c] = lambda do
535534
scn = @scanner
536535
before = scn.pos
@@ -552,8 +551,7 @@ def initialize()
552551
end
553552
end
554553

555-
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
556-
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'].each do |c|
554+
('A'..'Z').each do |c|
557555
@selector[c] = lambda do
558556
scn = @scanner
559557
before = scn.pos

0 commit comments

Comments
 (0)