Class: Racc::Rule

### Home Classes Methods

### In Files

- lib/racc/grammar.rb

### Parent

Object

### Methods

- ::new
- #==
- #[]
- #accept?
- #each
- #each_rule
- #empty?
- #hash=
- #inspect
- #null=
- #nullable?
- #prec
- #precedence
- #precedence=
- #replace
- #rule
- #size
- #to_s
- #useless=
- #useless?
- #|

### Files

- Manifest.txt
- README.rdoc
- pre-setup
- NEWS.en.rdoc
- grammar.en.rdoc

### Class/Module Index

Quicksearch

- Racc
- Racc::Accept
- Racc::ActionTable
- Racc::CompileError
- Racc::DebugFlags
- Racc::Error
- Racc::Goto
- Racc::Grammar
- Racc::Grammar::DefinitionEnv
- Racc::Grammar::PrecedenceDefinitionEnv
- Racc::GrammarFileParser
- Racc::GrammarFileParser::Result
- Racc::GrammarFileScanner
- Racc::ISet
- Racc::Item
- Racc::LocationPointer
- Racc::LogFileGenerator
- Racc::OrMark
- Racc::ParseError
- Racc::ParseError
- Racc::Parser
- Racc::ParserClassGenerator
- Racc::ParserFileGenerator
- Racc::ParserFileGenerator::Params
- Racc::Prec
- Racc::RRconflict
- Racc::Reduce
- Racc::Rule
- Racc::SRconflict
- Racc::Shift
- Racc::SourceText
- Racc::State
- Racc::StateTransitionTable
- Racc::StateTransitionTableGenerator
- Racc::States
- Racc::Sym
- Racc::SymbolTable
- Racc::UserAction
- Object
- Object::ParseError
- Array

No matching classes.

# Racc::Rule

### Attributes

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

### Public Class Methods

new(target, syms, act) click to toggle source

    # File lib/racc/grammar.rb, line 605
    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

### Public Instance Methods

==(other) click to toggle source

    # File lib/racc/grammar.rb, line 684
    def ==(other)
      other.kind_of?(Rule) and @ident == other.ident
    end

[](idx) click to toggle source

    # File lib/racc/grammar.rb, line 688
    def [](idx)
      @symbols[idx]
    end

accept?() click to toggle source

    # File lib/racc/grammar.rb, line 704
    def accept?
      if tok = @symbols[-1]
        tok.anchor?
      else
        false
      end
    end

each(&block) click to toggle source

    # File lib/racc/grammar.rb, line 712
    def each(&block)
      @symbols.each(&block)
    end

each_rule(&block) click to toggle source

    # File lib/racc/grammar.rb, line 633
    def each_rule(&block)
      yield self
      @alternatives.each(&block)
    end

empty?() click to toggle source

    # File lib/racc/grammar.rb, line 696
    def empty?
      @symbols.empty?
    end

hash=(n) click to toggle source

    # File lib/racc/grammar.rb, line 643
    def hash=(n)
      @hash = n
      ptrs = []
      @symbols.each_with_index do |sym, idx|
        ptrs.push LocationPointer.new(self, idx, sym)
      end
      ptrs.push LocationPointer.new(self, @symbols.size, nil)
      @ptrs = ptrs
    end

inspect() click to toggle source

    # File lib/racc/grammar.rb, line 680
    def inspect
      "#<Racc::Rule id=#{@ident} (#{@target})>"
    end

null=(n) click to toggle source

    # File lib/racc/grammar.rb, line 675
    def null=(n)    @null = n end

nullable?() click to toggle source

    # File lib/racc/grammar.rb, line 674
    def nullable?() @null end

prec(sym, &block) click to toggle source

    # File lib/racc/grammar.rb, line 661
    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() click to toggle source

    # File lib/racc/grammar.rb, line 653
    def precedence
      @specified_prec || @precedence
    end

precedence=(sym) click to toggle source

    # File lib/racc/grammar.rb, line 657
    def precedence=(sym)
      @precedence ||= sym
    end

replace(src, dest) click to toggle source

    # File lib/racc/grammar.rb, line 716
    def replace(src, dest)
      @target = dest
      @symbols = @symbols.map {|s| s == src ? dest : s }
    end

rule() click to toggle source

    # File lib/racc/grammar.rb, line 629
    def rule
      self
    end

size() click to toggle source

    # File lib/racc/grammar.rb, line 692
    def size
      @symbols.size
    end

to_s() click to toggle source

    # File lib/racc/grammar.rb, line 700
    def to_s
      "#<rule#{@ident}>"
    end

useless=(u) click to toggle source

    # File lib/racc/grammar.rb, line 678
    def useless=(u) @useless = u end

useless?() click to toggle source

    # File lib/racc/grammar.rb, line 677
    def useless?()  @useless end

|(x) click to toggle source

    # File lib/racc/grammar.rb, line 624
    def |(x)
      @alternatives.push x.rule
      self
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.