Class: KPeg::ForeignInvokeRule
Instance Attribute Summary (collapse)
-
- (Object) arguments
readonly
Returns the value of attribute arguments.
-
- (Object) grammar_name
readonly
Returns the value of attribute grammar_name.
-
- (Object) rule_name
readonly
Returns the value of attribute rule_name.
Attributes inherited from Operator
Instance Method Summary (collapse)
- - (Object) ==(obj)
-
- (ForeignInvokeRule) initialize(grammar, name, args = nil)
constructor
A new instance of ForeignInvokeRule.
- - (Object) inspect
- - (Object) match(x)
Methods inherited from Operator
#detect_tags, #inspect_type, #prune_values, #set_action, #|
Constructor Details
- (ForeignInvokeRule) initialize(grammar, name, args = nil)
A new instance of ForeignInvokeRule
463 464 465 466 467 468 469 470 471 472 |
# File 'lib/kpeg/grammar.rb', line 463 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
- (Object) arguments (readonly)
Returns the value of attribute arguments
474 475 476 |
# File 'lib/kpeg/grammar.rb', line 474 def arguments @arguments end |
- (Object) grammar_name (readonly)
Returns the value of attribute grammar_name
474 475 476 |
# File 'lib/kpeg/grammar.rb', line 474 def grammar_name @grammar_name end |
- (Object) rule_name (readonly)
Returns the value of attribute rule_name
474 475 476 |
# File 'lib/kpeg/grammar.rb', line 474 def rule_name @rule_name end |
Instance Method Details
- (Object) ==(obj)
482 483 484 485 486 487 488 489 490 |
# File 'lib/kpeg/grammar.rb', line 482 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 |
- (Object) inspect
492 493 494 495 496 497 498 499 |
# File 'lib/kpeg/grammar.rb', line 492 def inspect if @arguments body = "%#{@grammar}.#{@rule_name} #{@arguments}" else body = "%#{@grammar}.#{@rule_name}" end inspect_type "invoke", body end |
- (Object) match(x)
476 477 478 479 480 |
# File 'lib/kpeg/grammar.rb', line 476 def match(x) rule = x.grammar.find(@rule_name) raise "Unknown rule: '#{@rule_name}'" unless rule x.invoke rule end |