Parent

Racc::Rule

Attributes

target[RW]
symbols[R]
action[R]
ident[RW]
hash[R]
ptrs[R]
specified_prec[RW]

Public Class Methods

new(target, syms, act) click to toggle source
     # File lib/racc/grammar.rb, line 605
605:     def initialize(target, syms, act)
606:       @target = target
607:       @symbols = syms
608:       @action = act
609:       @alternatives = []
610: 
611:       @ident = nil
612:       @hash = nil
613:       @ptrs = nil
614:       @precedence = nil
615:       @specified_prec = nil
616:       @null = nil
617:       @useless = nil
618:     end

Public Instance Methods

==(other) click to toggle source
     # File lib/racc/grammar.rb, line 684
684:     def ==(other)
685:       other.kind_of?(Rule) and @ident == other.ident
686:     end
[](idx) click to toggle source
     # File lib/racc/grammar.rb, line 688
688:     def [](idx)
689:       @symbols[idx]
690:     end
accept?() click to toggle source
     # File lib/racc/grammar.rb, line 704
704:     def accept?
705:       if tok = @symbols[1]
706:         tok.anchor?
707:       else
708:         false
709:       end
710:     end
each(&block) click to toggle source
     # File lib/racc/grammar.rb, line 712
712:     def each(&block)
713:       @symbols.each(&block)
714:     end
each_rule(&block) click to toggle source
     # File lib/racc/grammar.rb, line 633
633:     def each_rule(&block)
634:       yield self
635:       @alternatives.each(&block)
636:     end
empty?() click to toggle source
     # File lib/racc/grammar.rb, line 696
696:     def empty?
697:       @symbols.empty?
698:     end
hash=(n) click to toggle source
     # File lib/racc/grammar.rb, line 643
643:     def hash=(n)
644:       @hash = n
645:       ptrs = []
646:       @symbols.each_with_index do |sym, idx|
647:         ptrs.push LocationPointer.new(self, idx, sym)
648:       end
649:       ptrs.push LocationPointer.new(self, @symbols.size, nil)
650:       @ptrs = ptrs
651:     end
inspect() click to toggle source
     # File lib/racc/grammar.rb, line 680
680:     def inspect
681:       "#<Racc::Rule id=#{@ident} (#{@target})>"
682:     end
null=(n) click to toggle source
     # File lib/racc/grammar.rb, line 675
675:     def null=(n)    @null = n end
nullable?() click to toggle source
     # File lib/racc/grammar.rb, line 674
674:     def nullable?() @null end
prec(sym, &block) click to toggle source
     # File lib/racc/grammar.rb, line 661
661:     def prec(sym, &block)
662:       @specified_prec = sym
663:       if block
664:         unless @action.empty?
665:           raise CompileError, 'both of rule action block and prec block given'
666:         end
667:         @action = UserAction.proc(block)
668:       end
669:       self
670:     end
precedence() click to toggle source
     # File lib/racc/grammar.rb, line 653
653:     def precedence
654:       @specified_prec || @precedence
655:     end
precedence=(sym) click to toggle source
     # File lib/racc/grammar.rb, line 657
657:     def precedence=(sym)
658:       @precedence ||= sym
659:     end
replace(src, dest) click to toggle source
     # File lib/racc/grammar.rb, line 716
716:     def replace(src, dest)
717:       @target = dest
718:       @symbols = @symbols.map {|s| s == src ? dest : s }
719:     end
rule() click to toggle source
     # File lib/racc/grammar.rb, line 629
629:     def rule
630:       self
631:     end
size() click to toggle source
     # File lib/racc/grammar.rb, line 692
692:     def size
693:       @symbols.size
694:     end
to_s() click to toggle source
     # File lib/racc/grammar.rb, line 700
700:     def to_s
701:       "#<rule#{@ident}>"
702:     end
useless=(u) click to toggle source
     # File lib/racc/grammar.rb, line 678
678:     def useless=(u) @useless = u end
useless?() click to toggle source
     # File lib/racc/grammar.rb, line 677
677:     def useless?()  @useless end
|(x) click to toggle source
     # File lib/racc/grammar.rb, line 624
624:     def |(x)
625:       @alternatives.push x.rule
626:       self
627:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.