# 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
# File lib/racc/grammar.rb, line 684
684: def ==(other)
685: other.kind_of?(Rule) and @ident == other.ident
686: end
# File lib/racc/grammar.rb, line 688
688: def [](idx)
689: @symbols[idx]
690: end
# 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
# File lib/racc/grammar.rb, line 712
712: def each(&block)
713: @symbols.each(&block)
714: end
# File lib/racc/grammar.rb, line 633
633: def each_rule(&block)
634: yield self
635: @alternatives.each(&block)
636: end
# File lib/racc/grammar.rb, line 696
696: def empty?
697: @symbols.empty?
698: end
# 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
# File lib/racc/grammar.rb, line 680
680: def inspect
681: "#<Racc::Rule id=#{@ident} (#{@target})>"
682: end
# File lib/racc/grammar.rb, line 675
675: def null=(n) @null = n end
# File lib/racc/grammar.rb, line 674
674: def nullable?() @null end
# 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
# File lib/racc/grammar.rb, line 653
653: def precedence
654: @specified_prec || @precedence
655: end
# File lib/racc/grammar.rb, line 657
657: def precedence=(sym)
658: @precedence ||= sym
659: end
# 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
# File lib/racc/grammar.rb, line 692
692: def size
693: @symbols.size
694: end
# File lib/racc/grammar.rb, line 700
700: def to_s
701: "#<rule#{@ident}>"
702: end
# File lib/racc/grammar.rb, line 678
678: def useless=(u) @useless = u end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.