Class: KPeg::InvokeRule
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#rule_name ⇒ Object
readonly
Returns the value of attribute rule_name.
Attributes inherited from Operator
Instance Method Summary collapse
- #==(obj) ⇒ Object
-
#initialize(name, args = nil) ⇒ InvokeRule
constructor
A new instance of InvokeRule.
- #inspect ⇒ Object
- #match(x) ⇒ Object
Methods inherited from Operator
#detect_tags, #inspect_type, #prune_values, #set_action, #|
Constructor Details
#initialize(name, args = nil) ⇒ InvokeRule
Returns a new instance of InvokeRule.
432 433 434 435 436 |
# File 'lib/kpeg/grammar.rb', line 432 def initialize(name, args=nil) super() @rule_name = name @arguments = args end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
438 439 440 |
# File 'lib/kpeg/grammar.rb', line 438 def arguments @arguments end |
#rule_name ⇒ Object (readonly)
Returns the value of attribute rule_name.
438 439 440 |
# File 'lib/kpeg/grammar.rb', line 438 def rule_name @rule_name end |
Instance Method Details
#==(obj) ⇒ Object
446 447 448 449 450 451 452 453 |
# File 'lib/kpeg/grammar.rb', line 446 def ==(obj) case obj when InvokeRule @rule_name == obj.rule_name and @arguments == obj.arguments else super end end |
#inspect ⇒ Object
455 456 457 458 459 460 461 462 |
# File 'lib/kpeg/grammar.rb', line 455 def inspect if @arguments body = "#{@rule_name} #{@arguments}" else body = @rule_name end inspect_type "invoke", body end |
#match(x) ⇒ Object
440 441 442 443 444 |
# File 'lib/kpeg/grammar.rb', line 440 def match(x) rule = x.grammar.find(@rule_name) raise "Unknown rule: '#{@rule_name}'" unless rule x.invoke rule end |