Methods
- clear_current
- current_begins
- current_ends
- current_info
- current_match
- current_token
- end_trigger
- mock
- new
- next_end
- next_offset
- next_start
- trigger
- trigger_finish
- trigger_flush
Included Modules
Attributes
[R] | machine | |
[RW] | mode | |
[RW] | offset | |
[R] | stack | |
[R] | text | |
[R] | tkstack |
Public Class methods
[ show source ]
# File lib/facets/more/stateparser.rb, line 222 def initialize( text, machine ) @text = text.dup.freeze @machine = machine @offset = 0 @stack = [] @tkstack = [] @current = {} @mode = nil #@info = OpenStruct.new end
Public Instance methods
[ show source ]
# File lib/facets/more/stateparser.rb, line 272 def clear_current @mode = nil @current = {} end
[ show source ]
# File lib/facets/more/stateparser.rb, line 278 def current_begins ; @current[:begins] ; end
[ show source ]
# File lib/facets/more/stateparser.rb, line 279 def current_ends ; @current[:ends] ; end
[ show source ]
# File lib/facets/more/stateparser.rb, line 281 def current_info ; @current[:info] ; end
[ show source ]
# File lib/facets/more/stateparser.rb, line 280 def current_match ; @current[:match] ; end
[ show source ]
# File lib/facets/more/stateparser.rb, line 277 def current_token ; @current[:token] ; end
[ show source ]
# File lib/facets/more/stateparser.rb, line 303 def end_trigger machine.send("#{current_token}_#{ENDCALLBACK}", current_match, self) end
[ show source ]
# File lib/facets/more/stateparser.rb, line 283 def mock( current ) mock = StateParser::Marker.new mock.token = current_token mock.begins = current_begins mock.ends = current_ends mock.match = current_match mock.info = current_info mock.parent = current mock end
[ show source ]
# File lib/facets/more/stateparser.rb, line 253 def next_end( index ) token = @stack.last.token match = @stack.last.match re = machine.send( "#{token}_#{ENDMATCH}", match, self ) #machine.tokens[token].stop(match,self) i = text.index( re, offset ) m = $~ if i e = m.end(0) if i if i and i < index # what comes first? @mode = :END @current[:token] = token @current[:begins] = i @current[:ends] = e @current[:match] = m #@current[:info] = f return i end return index end
increment the offset
[ show source ]
# File lib/facets/more/stateparser.rb, line 295 def next_offset @offset = current_ends end
[ show source ]
# File lib/facets/more/stateparser.rb, line 234 def next_start( token, index ) re = machine.send( "#{token}_#{MATCH}", self ) i = text.index( re, offset ) if i m = $~ e = m.end(0) if i < index # what comes first? @mode = machine.tokenIsUnit?[token] ? :UNIT : :START @current[:token] = token @current[:begins] = i @current[:ends] = e @current[:match] = m #@current[:info] = f return i end end return index end
[ show source ]
# File lib/facets/more/stateparser.rb, line 299 def trigger machine.send("#{current_token}_#{CALLBACK}", current_match, self) end
[ show source ]
# File lib/facets/more/stateparser.rb, line 311 def trigger_finish machine.send("finish", self) #if machine.respond_to?(:finish) end
[ show source ]
# File lib/facets/more/stateparser.rb, line 307 def trigger_flush( text ) machine.send("flush", text, self) #if machine.respond_to?(:flush) end