Class: Racc::SymbolTable

### Home Classes Methods

### In Files

- lib/racc/grammar.rb

### Parent

Object

### Methods

- ::new
- #[]
- #delete
- #each
- #each_nonterminal
- #each_terminal
- #fix
- #intern
- #nonterminals
- #nt_max
- #terminals

### Included Modules

- Enumerable

### 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::SymbolTable

### Attributes

anchor[R]
dummy[R]
error[R]
nt_base[R]
symbols[R]
to_a[R]

### Public Class Methods

new() click to toggle source

    # File lib/racc/grammar.rb, line 870
    def initialize
      @symbols = []   # :: [Racc::Sym]
      @cache   = {}   # :: {(String|Symbol) => Racc::Sym}
      @dummy  = intern(:$start, true)
      @anchor = intern(false, true)     # Symbol ID = 0
      @error  = intern(:error, false)   # Symbol ID = 1
    end

### Public Instance Methods

[](id) click to toggle source

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

delete(sym) click to toggle source

    # File lib/racc/grammar.rb, line 898
    def delete(sym)
      @symbols.delete sym
      @cache.delete sym.value
    end

each(&block) click to toggle source

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

each_nonterminal(&block) click to toggle source

    # File lib/racc/grammar.rb, line 925
    def each_nonterminal(&block)
      @nterms.each(&block)
    end

each_terminal(&block) click to toggle source

    # File lib/racc/grammar.rb, line 917
    def each_terminal(&block)
      @terms.each(&block)
    end

fix() click to toggle source

    # File lib/racc/grammar.rb, line 929
    def fix
      terms, nterms = @symbols.partition {|s| s.terminal? }
      @symbols = terms + nterms
      @terms = terms
      @nterms = nterms
      @nt_base = terms.size
      fix_ident
      check_terminals
    end

intern(val, dummy = false) click to toggle source

    # File lib/racc/grammar.rb, line 886
    def intern(val, dummy = false)
      @cache[val] ||=
          begin
            sym = Sym.new(val, dummy)
            @symbols.push sym
            sym
          end
    end

nonterminals() click to toggle source

    # File lib/racc/grammar.rb, line 921
    def nonterminals
      @symbols[@nt_base, @symbols.size - @nt_base]
    end

nt_max() click to toggle source

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

terminals(&block) click to toggle source

    # File lib/racc/grammar.rb, line 913
    def terminals(&block)
      @symbols[0, @nt_base]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.