From 7fd577f8c2959902c4eb79d3c20b70a274e41618 Mon Sep 17 00:00:00 2001 From: murphy Date: Fri, 26 Mar 2010 03:18:12 +0000 Subject: Cleanups for C, C++, CSS, Delphi, Groovy, Java, PHP, Python, RHTML, XML, and YAML scanners. --- lib/coderay/scanners/yaml.rb | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'lib/coderay/scanners/yaml.rb') diff --git a/lib/coderay/scanners/yaml.rb b/lib/coderay/scanners/yaml.rb index 52fca90..fa29701 100644 --- a/lib/coderay/scanners/yaml.rb +++ b/lib/coderay/scanners/yaml.rb @@ -1,7 +1,7 @@ module CodeRay module Scanners - # YAML Scanner + # Scanner for YAML. # # Based on the YAML scanner from Syntax by Jamis Buck. class YAML < Scanner @@ -11,6 +11,8 @@ module Scanners KINDS_NOT_LOC = :all + protected + def scan_tokens tokens, options value_expected = nil @@ -21,14 +23,7 @@ module Scanners kind = nil match = nil - - if bol? - key_indent = nil - if $DEBUG - indent = check(/ +/) ? matched.size : 0 - tokens << [indent.to_s, :debug] - end - end + key_indent = nil if bol? if match = scan(/ +[\t ]*/) kind = :space @@ -128,7 +123,10 @@ module Scanners match ||= matched - raise_inspect 'Error token %p in line %d' % [[match, kind], line], tokens if $DEBUG && !kind + if $CODERAY_DEBUG and not kind + raise_inspect 'Error token %p in line %d' % + [[match, kind], line], tokens + end raise_inspect 'Empty token', tokens unless match tokens << [match, kind] -- cgit v1.2.1