Class: TDParser::ActionParser
- Inherits:
-
CompositeParser
- Object
- Parser
- CompositeParser
- TDParser::ActionParser
- Defined in:
- lib/tdp.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
Attributes inherited from CompositeParser
Instance Method Summary collapse
- #==(r) ⇒ Object
- #call(tokens, buff) ⇒ Object
-
#initialize(parser, act) ⇒ ActionParser
constructor
A new instance of ActionParser.
- #to_s ⇒ Object
Methods inherited from CompositeParser
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
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
#action ⇒ Object (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_s ⇒ Object
317 318 319 |
# File 'lib/tdp.rb', line 317 def to_s() "(#{@parsers[0].to_s()} <action>)" end |