Class: TDParser::ConditionParser
Instance Attribute Summary collapse
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
Instance Method Summary collapse
- #==(r) ⇒ Object
- #call(tokens, buff) ⇒ Object
-
#initialize(&condition) ⇒ ConditionParser
constructor
A new instance of ConditionParser.
- #same?(r) ⇒ Boolean
- #to_s ⇒ Object
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, #state, #token
Methods included from BufferUtils
Constructor Details
#initialize(&condition) ⇒ ConditionParser
Returns a new instance of ConditionParser.
746 747 748 |
# File 'lib/tdp.rb', line 746 def initialize(&condition) @condition = condition end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
744 745 746 |
# File 'lib/tdp.rb', line 744 def condition @condition end |
Instance Method Details
#==(r) ⇒ Object
762 763 764 765 |
# File 'lib/tdp.rb', line 762 def ==(r) super(r) && (@condition == r.condition) end |
#call(tokens, buff) ⇒ Object
750 751 752 753 754 755 756 |
# File 'lib/tdp.rb', line 750 def call(tokens, buff) if (res = @condition.call(buff.map)) Sequence[res] else nil end end |
#same?(r) ⇒ Boolean
767 768 769 |
# File 'lib/tdp.rb', line 767 def same?(r) false end |
#to_s ⇒ Object
758 759 760 |
# File 'lib/tdp.rb', line 758 def to_s() "<condition:#{@condition}>" end |