summaryrefslogtreecommitdiff
path: root/lib/coderay/scanner.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/coderay/scanner.rb')
-rw-r--r--lib/coderay/scanner.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/coderay/scanner.rb b/lib/coderay/scanner.rb
index 33bcb09..5ff07a0 100644
--- a/lib/coderay/scanner.rb
+++ b/lib/coderay/scanner.rb
@@ -115,6 +115,16 @@ module CodeRay
# More mnemonic accessor name for the input string.
alias code string
+ def reset
+ super
+ reset_tokens
+ end
+
+ def string= str
+ super
+ reset_tokens
+ end
+
# Scans the code and returns all tokens in a Tokens object.
def tokenize options = {}
options = @options.merge({}) #options
@@ -158,6 +168,11 @@ module CodeRay
"#{self.class}#scan_tokens not implemented."
end
+ def reset_tokens
+ @tokens.clear
+ @cached_tokens = nil
+ end
+
# Scanner error with additional status information
def raise_inspect msg, tokens, ambit = 30
raise ScanError, <<-EOE % [