Permalink
Browse files

minor tweaks to generator and scanner edge cases

  • Loading branch information...
1 parent e18ebab commit 1cdf0e17af6c280dc12130a9200d8196b056bbe9 @korny korny committed Mar 11, 2013
@@ -148,7 +148,7 @@ def scan_tokens encoder, options
encoder.text_token match, :char
elsif match = scan(/ \\ | $ /x)
encoder.end_group :string
- encoder.text_token match, :error
+ encoder.text_token match, :error unless match.empty?
state = :initial
label_expected = false
else
@@ -160,7 +160,7 @@ def scan_tokens encoder, options
encoder.text_token match, :char
elsif match = scan(/ \\ | $ /x)
encoder.end_group :string
- encoder.text_token match, :error
+ encoder.text_token match, :error unless match.empty?
state = :initial
label_expected = false
else
@@ -147,7 +147,7 @@ def scan_tokens encoder, options
elsif match = scan(/ \\ | $ /x)
encoder.end_group state
state = :initial
- encoder.text_token match, :error
+ encoder.text_token match, :error unless match.empty?
else
raise_inspect "else case \" reached; %p not handled." % peek(1), encoder
end
@@ -175,11 +175,11 @@ def scan_tokens encoder, options
encoder.text_token match, :content
elsif match = scan(/ \\ | $ /x)
encoder.end_group state
- encoder.text_token match, :error
+ encoder.text_token match, :error unless match.empty?
key_expected = value_expected = false
state = :initial
else
- raise_inspect "else case \" reached; %p not handled." % peek(1), encoder
+ raise_inspect "else case #{string_delimiter} reached; %p not handled." % peek(1), encoder
end
else
@@ -70,7 +70,7 @@ def scan_tokens encoder, options
encoder.text_token match, :content
elsif match = scan(/ \\ | $ /x)
encoder.end_group state
- encoder.text_token match, :error
+ encoder.text_token match, :error unless match.empty?
state = :initial
else
raise_inspect "else case \" reached; %p not handled." % peek(1), encoder
@@ -133,7 +133,7 @@ def scan_tokens encoder, options
elsif match = scan(/ \\ | $ /x)
encoder.end_group string_type
string_type = nil
- encoder.text_token match, :error
+ encoder.text_token match, :error unless match.empty?
state = :initial
else
raise_inspect "else case \" reached; %p not handled." % peek(1), encoder, state
@@ -148,7 +148,7 @@ def scan_tokens encoder, options
encoder.text_token string_content, :content
string_content = ''
end
- encoder.text_token match, :error
+ encoder.text_token match, :error unless match.empty?
state = :initial
else
raise "else case \" reached; %p not handled." % peek(1), encoder
@@ -1,5 +1,5 @@
namespace :generate do
- desc 'generates a new scanner NAME=lang [ALT=alternative,plugin,ids] [EXT=file,extensions] [BASE=base lang] '
+ desc 'generates a new scanner NAME=lang [ALT=alternative,plugin,ids] [EXT=file,extensions] [BASE=base lang]'
task :scanner do
raise 'I need a scanner name; use NAME=lang' unless scanner_class_name = ENV['NAME']
raise "Invalid lang: #{scanner_class_name}; use NAME=lang." unless /\A\w+\z/ === scanner_class_name
@@ -52,7 +52,7 @@ namespace :generate do
end
end
- if alternative_ids = ENV['ALT']
+ if alternative_ids = ENV['ALT'] && alternative_ids != lang
map_file = File.join(LIB_ROOT, 'coderay', 'scanners', '_map.rb')
puts "Not automated. Remember to add your alternative plugin ids to #{map_file}:"
for id in alternative_ids.split(',')

0 comments on commit 1cdf0e1

Please sign in to comment.