lib/tl1/ast.rb in tl1-0.1.0 vs lib/tl1/ast.rb in tl1-0.2.0

- old
+ new

@@ -1,6 +1,7 @@ # frozen_string_literal: true + require 'strscan' module TL1 # Namespace for AST Nodes in input and output formats module AST @@ -31,27 +32,27 @@ node.parse(source['fields']) end module_function def split(string, delimiter) scanner = StringScanner.new(string) - array = [String.new] + array = [+''] loop do return array if scanner.eos? char = scanner.getch case char when delimiter - array << String.new + array << +'' when '"' array.last << split_quoted(scanner) else array.last << char end end end module_function def split_quoted(scanner) - string = String.new('"') + string = +'"' loop do raise 'Unexpected end of quoted string' if scanner.eos? char = scanner.getch case char