Class: TDParser::ActionParser

Inherits:
CompositeParser show all
Defined in:
lib/tdp.rb

Instance Attribute Summary collapse

Attributes inherited from CompositeParser

#parsers

Instance Method Summary collapse

Methods inherited from CompositeParser

#optimize, #same?

Methods inherited from Parser

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

Methods included from TDParser

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

Methods included from BufferUtils

#prepare, #recover

Constructor Details

#initialize(parser, act) ⇒ ActionParser

Returns a new instance of ActionParser.



297
298
299
300
# File 'lib/tdp.rb', line 297

def initialize(parser, act)
  @action = act
  super(parser)
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



295
296
297
# File 'lib/tdp.rb', line 295

def action
  @action
end

Instance Method Details

#==(r) ⇒ Object



312
313
314
315
# File 'lib/tdp.rb', line 312

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

#call(tokens, buff) ⇒ Object



302
303
304
305
306
307
308
309
310
# File 'lib/tdp.rb', line 302

def call(tokens, buff)
  if( (x = @parsers[0].call(tokens, buff)).nil? )
    nil
  else
    x = TokenBuffer[*x]
    x.map = buff.map
    Sequence[@action[x]]
  end
end

#to_sObject



317
318
319
# File 'lib/tdp.rb', line 317

def to_s()
  "(#{@parsers[0].to_s()} <action>)"
end