Class: TDParser::StateParser

Inherits:
Parser
  • Object
show all
Defined in:
lib/tdp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Parser

#%, #*, #+, #-, #/, #>, #>>, #do, #optimize, #parse, #peek, #to_proc, #|, #~@

Methods included from TDParser

#any_rule, #backref, #chainl, #chainr, #condition_rule, define, #empty_rule, #fail_rule, #leftrec, #none_rule, #rightrec, #rule, #stackref, #token

Methods included from BufferUtils

#prepare, #recover

Constructor Details

#initialize(s) ⇒ StateParser

Returns a new instance of StateParser.



775
776
777
# File 'lib/tdp.rb', line 775

def initialize(s)
  @state = s
end

Instance Attribute Details

#stateObject (readonly)

Returns the value of attribute state.



773
774
775
# File 'lib/tdp.rb', line 773

def state
  @state
end

Instance Method Details

#==(r) ⇒ Object



791
792
793
794
# File 'lib/tdp.rb', line 791

def ==(r)
  super(r) &&
  (@state == r.state)
end

#call(tokens, buff) ⇒ Object



779
780
781
782
783
784
785
# File 'lib/tdp.rb', line 779

def call(tokens, buff)
  if (buff.map[:state] == @state)
    Sequence[@state]
  else
    nil
  end
end

#same?(r) ⇒ Boolean

Returns:

  • (Boolean)


796
797
798
# File 'lib/tdp.rb', line 796

def same?(r)
  false
end

#to_sObject



787
788
789
# File 'lib/tdp.rb', line 787

def to_s()
  "<state:#{@state}>"
end