Class: LXL::LittleLexer
- Inherits:
-
Object
- Object
- LXL::LittleLexer
- Defined in:
- lib/lxl.rb
Overview
John Carter’s LittleLexer
Defined Under Namespace
Classes: LexerJammed
Instance Method Summary collapse
-
#initialize(regex_to_char, skip_white_space = true) ⇒ LittleLexer
constructor
A new instance of LittleLexer.
- #scan(string, string_token_list = nil) ⇒ Object
Constructor Details
#initialize(regex_to_char, skip_white_space = true) ⇒ LittleLexer
Returns a new instance of LittleLexer.
239 240 241 242 |
# File 'lib/lxl.rb', line 239 def initialize(regex_to_char,skip_white_space = true) @skip_white_space = skip_white_space @regex_to_char = regex_to_char end |
Instance Method Details
#scan(string, string_token_list = nil) ⇒ Object
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/lxl.rb', line 244 def scan(string,string_token_list=nil) result_string = '' token_list = [] if string_token_list next_token(string) do |t,token, tail| result_string << t token_list << [string_token_list[0...tail], string[0...tail]] string = string[tail..-1] string_token_list = string_token_list[tail..-1] end else next_token(string) do |t,token, tail| result_string << t token_list << token end end return result_string, token_list end |