lib/dentaku/tokenizer.rb in dentaku-2.0.8 vs lib/dentaku/tokenizer.rb in dentaku-2.0.9

- old
+ new

@@ -11,17 +11,17 @@ @nesting = 0 @tokens = [] input = strip_comments(string.to_s.dup) until input.empty? - raise "parse error at: '#{ input }'" unless TokenScanner.scanners.any? do |scanner| + fail TokenizerError, "parse error at: '#{ input }'" unless TokenScanner.scanners.any? do |scanner| scanned, input = scan(input, scanner) scanned end end - raise "too many opening parentheses" if @nesting > 0 + fail TokenizerError, "too many opening parentheses" if @nesting > 0 @tokens end def last_token @@ -29,14 +29,14 @@ end def scan(string, scanner) if tokens = scanner.scan(string, last_token) tokens.each do |token| - raise "unexpected zero-width match (:#{ token.category }) at '#{ string }'" if token.length == 0 + fail TokenizerError, "unexpected zero-width match (:#{ token.category }) at '#{ string }'" if token.length == 0 @nesting += 1 if LPAREN == token @nesting -= 1 if RPAREN == token - raise "too many closing parentheses" if @nesting < 0 + fail TokenizerError, "too many closing parentheses" if @nesting < 0 @tokens << token unless token.is?(:whitespace) end match_length = tokens.map(&:length).reduce(:+)