summaryrefslogtreecommitdiff
path: root/lib/coderay/rule_based_scanner.rb
diff options
context:
space:
mode:
authorKornelius Kalnbach <murphy@rubychan.de>2016-02-14 15:08:30 +0100
committerKornelius Kalnbach <murphy@rubychan.de>2016-02-14 15:08:30 +0100
commit13ac3fdc6fa5330c9eacc6ac9be92a869ab8d3be (patch)
tree0cf34739e36f452fa9086455d052589d3ce075e6 /lib/coderay/rule_based_scanner.rb
parentf8cadd9fce43c48ed4b32685f62e99f8770b8963 (diff)
downloadcoderay-13ac3fdc6fa5330c9eacc6ac9be92a869ab8d3be.tar.gz
optional push state (return nil)
Diffstat (limited to 'lib/coderay/rule_based_scanner.rb')
-rw-r--r--lib/coderay/rule_based_scanner.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/coderay/rule_based_scanner.rb b/lib/coderay/rule_based_scanner.rb
index 35adad1..334c08c 100644
--- a/lib/coderay/rule_based_scanner.rb
+++ b/lib/coderay/rule_based_scanner.rb
@@ -120,15 +120,19 @@ module CodeRay
raise
@code << " p 'push %p' % [#{action.state}]\n" if $DEBUG
@code << " state = #{action.state}\n"
+ @code << " states << state\n"
when Symbol
@code << " p 'push %p' % [#{action.state.inspect}]\n" if $DEBUG
@code << " state = #{action.state.inspect}\n"
+ @code << " states << state\n"
when Proc
- @code << " state = #{make_callback(action.state)}\n"
+ @code << " if new_state = #{make_callback(action.state)}\n"
+ @code << " state = new_state\n"
+ @code << " states << new_state\n"
+ @code << " end\n"
else
raise "I don't know how to evaluate this push state: %p" % [action.state]
end
- @code << " states << state\n"
if action.is_a? Push
if action.state == action.group
@code << " encoder.begin_group state\n"