From 5daa248eb972fb6c1a07fdf74999cb40a51451aa Mon Sep 17 00:00:00 2001 From: murphy Date: Fri, 26 Mar 2010 03:00:18 +0000 Subject: Cleanup of JSON Scanner. --- lib/coderay/scanners/json.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lib/coderay/scanners/json.rb') diff --git a/lib/coderay/scanners/json.rb b/lib/coderay/scanners/json.rb index a9926b2..163ec46 100644 --- a/lib/coderay/scanners/json.rb +++ b/lib/coderay/scanners/json.rb @@ -1,6 +1,7 @@ module CodeRay module Scanners + # Scanner for JSON (JavaScript Object Notation). class JSON < Scanner include Streamable @@ -11,13 +12,15 @@ module Scanners KINDS_NOT_LOC = [ :float, :char, :content, :delimiter, :error, :integer, :operator, :value, - ] + ] # :nodoc: - CONSTANTS = %w( true false null ) - IDENT_KIND = WordList.new(:key).add(CONSTANTS, :value) + CONSTANTS = %w( true false null ) # :nodoc: + IDENT_KIND = WordList.new(:key).add(CONSTANTS, :value) # :nodoc: - ESCAPE = / [bfnrt\\"\/] /x - UNICODE_ESCAPE = / u[a-fA-F0-9]{4} /x + ESCAPE = / [bfnrt\\"\/] /x # :nodoc: + UNICODE_ESCAPE = / u[a-fA-F0-9]{4} /x # :nodoc: + + protected def scan_tokens tokens, options @@ -89,7 +92,7 @@ module Scanners end match ||= matched - if $DEBUG and not kind + if $CODERAY_DEBUG and not kind raise_inspect 'Error token %p in line %d' % [[match, kind], line], tokens end -- cgit v1.2.1