This module holds the Scanner class and its subclasses. For example, the Ruby scanner is named CodeRay::Scanners::Ruby can be found in coderay/scanners/ruby.
Scanner also provides methods and constants for the register mechanism and the [] method that returns the Scanner class belonging to the given lang.
See PluginHost.
# File lib/coderay/scanners/nitro_xhtml.rb, line 80
80: def reset_instance
81: super
82: @html_scanner.reset
83: end
# File lib/coderay/scanners/nitro_xhtml.rb, line 85
85: def scan_tokens tokens, options
86:
87: until eos?
88:
89: if (match = scan_until(/(?=#{START_OF_RUBY})/o) || scan_until(/\z/)) and not match.empty?
90: @html_scanner.tokenize match
91:
92: elsif match = scan(/#{NITRO_VALUE_BLOCK}/o)
93: start_tag = match[0,2]
94: delimiter = CLOSING_PAREN[start_tag[1,1]]
95: end_tag = match[-1,1] == delimiter ? delimiter : ''
96: tokens << [:open, :inline]
97: tokens << [start_tag, :inline_delimiter]
98: code = match[start_tag.size .. -1 - end_tag.size]
99: @ruby_scanner.tokenize code
100: tokens << [end_tag, :inline_delimiter] unless end_tag.empty?
101: tokens << [:close, :inline]
102:
103: elsif match = scan(/#{NITRO_RUBY_BLOCK}/o)
104: start_tag = '<?r'
105: end_tag = match[-2,2] == '?>' ? '?>' : ''
106: tokens << [:open, :inline]
107: tokens << [start_tag, :inline_delimiter]
108: code = match[start_tag.size .. -(end_tag.size)-1]
109: @ruby_scanner.tokenize code
110: tokens << [end_tag, :inline_delimiter] unless end_tag.empty?
111: tokens << [:close, :inline]
112:
113: elsif entity = scan(/#{NITRO_ENTITY}/o)
114: tokens << [entity, :entity]
115:
116: elsif scan(/%/)
117: tokens << [matched, :error]
118:
119: else
120: raise_inspect 'else-case reached!', tokens
121: end
122:
123: end
124:
125: tokens
126:
127: end