Class: KPeg::ForeignInvokeRule
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#grammar_name ⇒ Object
readonly
Returns the value of attribute grammar_name.
-
#rule_name ⇒ Object
readonly
Returns the value of attribute rule_name.
Attributes inherited from Operator
Instance Method Summary collapse
- #==(obj) ⇒ Object
-
#initialize(grammar, name, args = nil) ⇒ ForeignInvokeRule
constructor
A new instance of ForeignInvokeRule.
- #inspect ⇒ Object
- #match(x) ⇒ Object
Methods inherited from Operator
#detect_tags, #inspect_type, #prune_values, #set_action, #|
Constructor Details
#initialize(grammar, name, args = nil) ⇒ ForeignInvokeRule
Returns a new instance of ForeignInvokeRule.
466 467 468 469 470 471 472 473 474 475 |
# File 'lib/kpeg/grammar.rb', line 466 def initialize(grammar, name, args=nil) super() @grammar_name = grammar @rule_name = name if !args or args.empty? @arguments = nil else @arguments = args end end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
477 478 479 |
# File 'lib/kpeg/grammar.rb', line 477 def arguments @arguments end |
#grammar_name ⇒ Object (readonly)
Returns the value of attribute grammar_name.
477 478 479 |
# File 'lib/kpeg/grammar.rb', line 477 def grammar_name @grammar_name end |
#rule_name ⇒ Object (readonly)
Returns the value of attribute rule_name.
477 478 479 |
# File 'lib/kpeg/grammar.rb', line 477 def rule_name @rule_name end |
Instance Method Details
#==(obj) ⇒ Object
485 486 487 488 489 490 491 492 493 |
# File 'lib/kpeg/grammar.rb', line 485 def ==(obj) case obj when ForeignInvokeRule @grammar_name == obj.grammar_name and \ @rule_name == obj.rule_name and @arguments == obj.arguments else super end end |
#inspect ⇒ Object
495 496 497 498 499 500 501 502 |
# File 'lib/kpeg/grammar.rb', line 495 def inspect if @arguments body = "%#{@grammar}.#{@rule_name} #{@arguments}" else body = "%#{@grammar}.#{@rule_name}" end inspect_type "invoke", body end |
#match(x) ⇒ Object
479 480 481 482 483 |
# File 'lib/kpeg/grammar.rb', line 479 def match(x) rule = x.grammar.find(@rule_name) raise "Unknown rule: '#{@rule_name}'" unless rule x.invoke rule end |