diff options
author | Kornelius Kalnbach <murphy@rubychan.de> | 2013-06-23 14:35:17 +0200 |
---|---|---|
committer | Kornelius Kalnbach <murphy@rubychan.de> | 2013-06-23 14:35:17 +0200 |
commit | 9651f0b464b6540a1427ea8320abaa01caf197b3 (patch) | |
tree | 184c42f0fe01ddce26b7d4cc42c124b695a20b3e /lib/coderay/scanners/groovy.rb | |
parent | 14f3a4f28341237503a51bfa0764c922bb02bdfa (diff) | |
parent | d7f1669cdf1d48204f3e1b0078d467da448c31d2 (diff) | |
download | coderay-9651f0b464b6540a1427ea8320abaa01caf197b3.tar.gz |
Merge branch 'master' into upstream
Diffstat (limited to 'lib/coderay/scanners/groovy.rb')
-rw-r--r-- | lib/coderay/scanners/groovy.rb | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/coderay/scanners/groovy.rb b/lib/coderay/scanners/groovy.rb index cf55daf..c64454f 100644 --- a/lib/coderay/scanners/groovy.rb +++ b/lib/coderay/scanners/groovy.rb @@ -36,9 +36,12 @@ module Scanners protected + def setup + @state = :initial + end + def scan_tokens encoder, options - - state = :initial + state = options[:state] || @state inline_block_stack = [] inline_block_paren_depth = nil string_delimiter = nil @@ -223,7 +226,7 @@ module Scanners encoder.text_token match, :content # TODO: Shouldn't this be :error? elsif match = scan(/ \\ | \n /x) - encoder.end_group state + encoder.end_group state == :regexp ? :regexp : :string encoder.text_token match, :error after_def = value_expected = false state = :initial @@ -243,7 +246,17 @@ module Scanners end if [:multiline_string, :string, :regexp].include? state - encoder.end_group state + encoder.end_group state == :regexp ? :regexp : :string + end + + if options[:keep_state] + @state = state + end + + until inline_block_stack.empty? + state, = *inline_block_stack.pop + encoder.end_group :inline + encoder.end_group state == :regexp ? :regexp : :string end encoder |