Class: Racc::Rule
Instance Attribute Summary collapse
- 
  
    
      #action  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute action.
 - 
  
    
      #hash  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute hash.
 - 
  
    
      #ident  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute ident.
 - 
  
    
      #ptrs  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute ptrs.
 - 
  
    
      #specified_prec  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute specified_prec.
 - 
  
    
      #symbols  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute symbols.
 - 
  
    
      #target  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute target.
 
Instance Method Summary collapse
- #==(other) ⇒ Object
 - #[](idx) ⇒ Object
 - #accept? ⇒ Boolean
 - #each(&block) ⇒ Object
 - #each_rule {|_self| ... } ⇒ Object
 - #empty? ⇒ Boolean
 - 
  
    
      #initialize(target, syms, act)  ⇒ Rule 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Rule.
 - #inspect ⇒ Object
 - #null=(n) ⇒ Object
 - #nullable? ⇒ Boolean
 - #prec(sym, &block) ⇒ Object
 - #precedence ⇒ Object
 - #precedence=(sym) ⇒ Object
 - #replace(src, dest) ⇒ Object
 - #rule ⇒ Object
 - #size ⇒ Object
 - #to_s ⇒ Object
 - #useless=(u) ⇒ Object
 - #useless? ⇒ Boolean
 - #|(x) ⇒ Object
 
Constructor Details
#initialize(target, syms, act) ⇒ Rule
Returns a new instance of Rule.
      608 609 610 611 612 613 614 615 616 617 618 619 620 621  | 
    
      # File 'lib/racc/grammar.rb', line 608 def initialize(target, syms, act) @target = target @symbols = syms @action = act @alternatives = [] @ident = nil @hash = nil @ptrs = nil @precedence = nil @specified_prec = nil @null = nil @useless = nil end  | 
  
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
      625 626 627  | 
    
      # File 'lib/racc/grammar.rb', line 625 def action @action end  | 
  
#hash ⇒ Object
Returns the value of attribute hash.
      643 644 645  | 
    
      # File 'lib/racc/grammar.rb', line 643 def hash @hash end  | 
  
#ident ⇒ Object
Returns the value of attribute ident.
      641 642 643  | 
    
      # File 'lib/racc/grammar.rb', line 641 def ident @ident end  | 
  
#ptrs ⇒ Object (readonly)
Returns the value of attribute ptrs.
      644 645 646  | 
    
      # File 'lib/racc/grammar.rb', line 644 def ptrs @ptrs end  | 
  
#specified_prec ⇒ Object
Returns the value of attribute specified_prec.
      675 676 677  | 
    
      # File 'lib/racc/grammar.rb', line 675 def specified_prec @specified_prec end  | 
  
#symbols ⇒ Object (readonly)
Returns the value of attribute symbols.
      624 625 626  | 
    
      # File 'lib/racc/grammar.rb', line 624 def symbols @symbols end  | 
  
#target ⇒ Object
Returns the value of attribute target.
      623 624 625  | 
    
      # File 'lib/racc/grammar.rb', line 623 def target @target end  | 
  
Instance Method Details
#==(other) ⇒ Object
      687 688 689  | 
    
      # File 'lib/racc/grammar.rb', line 687 def ==(other) other.kind_of?(Rule) and @ident == other.ident end  | 
  
#[](idx) ⇒ Object
      691 692 693  | 
    
      # File 'lib/racc/grammar.rb', line 691 def [](idx) @symbols[idx] end  | 
  
#accept? ⇒ Boolean
      707 708 709 710 711 712 713  | 
    
      # File 'lib/racc/grammar.rb', line 707 def accept? if tok = @symbols[-1] tok.anchor? else false end end  | 
  
#each(&block) ⇒ Object
      715 716 717  | 
    
      # File 'lib/racc/grammar.rb', line 715 def each(&block) @symbols.each(&block) end  | 
  
#each_rule {|_self| ... } ⇒ Object
      636 637 638 639  | 
    
      # File 'lib/racc/grammar.rb', line 636 def each_rule(&block) yield self @alternatives.each(&block) end  | 
  
#empty? ⇒ Boolean
      699 700 701  | 
    
      # File 'lib/racc/grammar.rb', line 699 def empty? @symbols.empty? end  | 
  
#inspect ⇒ Object
      683 684 685  | 
    
      # File 'lib/racc/grammar.rb', line 683 def inspect "#<Racc::Rule id=#{@ident} (#{@target})>" end  | 
  
#null=(n) ⇒ Object
      678  | 
    
      # File 'lib/racc/grammar.rb', line 678 def null=(n) @null = n end  | 
  
#nullable? ⇒ Boolean
      677  | 
    
      # File 'lib/racc/grammar.rb', line 677 def nullable?() @null end  | 
  
#prec(sym, &block) ⇒ Object
      664 665 666 667 668 669 670 671 672 673  | 
    
      # File 'lib/racc/grammar.rb', line 664 def prec(sym, &block) @specified_prec = sym if block unless @action.empty? raise CompileError, 'both of rule action block and prec block given' end @action = UserAction.proc(block) end self end  | 
  
#precedence ⇒ Object
      656 657 658  | 
    
      # File 'lib/racc/grammar.rb', line 656 def precedence @specified_prec || @precedence end  | 
  
#precedence=(sym) ⇒ Object
      660 661 662  | 
    
      # File 'lib/racc/grammar.rb', line 660 def precedence=(sym) @precedence ||= sym end  | 
  
#replace(src, dest) ⇒ Object
      719 720 721 722  | 
    
      # File 'lib/racc/grammar.rb', line 719 def replace(src, dest) @target = dest @symbols = @symbols.map {|s| s == src ? dest : s } end  | 
  
#rule ⇒ Object
      632 633 634  | 
    
      # File 'lib/racc/grammar.rb', line 632 def rule self end  | 
  
#size ⇒ Object
      695 696 697  | 
    
      # File 'lib/racc/grammar.rb', line 695 def size @symbols.size end  | 
  
#to_s ⇒ Object
      703 704 705  | 
    
      # File 'lib/racc/grammar.rb', line 703 def to_s "#<rule#{@ident}>" end  | 
  
#useless=(u) ⇒ Object
      681  | 
    
      # File 'lib/racc/grammar.rb', line 681 def useless=(u) @useless = u end  | 
  
#useless? ⇒ Boolean
      680  | 
    
      # File 'lib/racc/grammar.rb', line 680 def useless?() @useless end  | 
  
#|(x) ⇒ Object
      627 628 629 630  | 
    
      # File 'lib/racc/grammar.rb', line 627 def |(x) @alternatives.push x.rule self end  |