# File lib/racc/grammar.rb, line 870 870: def initialize 871: @symbols = [] # :: [Racc::Sym] 872: @cache = {} # :: {(String|Symbol) => Racc::Sym} 873: @dummy = intern(:$start, true) 874: @anchor = intern(false, true) # Symbol ID = 0 875: @error = intern(:error, false) # Symbol ID = 1 876: end
# File lib/racc/grammar.rb, line 882 882: def [](id) 883: @symbols[id] 884: end
# File lib/racc/grammar.rb, line 898 898: def delete(sym) 899: @symbols.delete sym 900: @cache.delete sym.value 901: end
# File lib/racc/grammar.rb, line 909 909: def each(&block) 910: @symbols.each(&block) 911: end
# File lib/racc/grammar.rb, line 925 925: def each_nonterminal(&block) 926: @nterms.each(&block) 927: end
# File lib/racc/grammar.rb, line 917 917: def each_terminal(&block) 918: @terms.each(&block) 919: end
# File lib/racc/grammar.rb, line 929 929: def fix 930: terms, nterms = @symbols.partition {|s| s.terminal? } 931: @symbols = terms + nterms 932: @terms = terms 933: @nterms = nterms 934: @nt_base = terms.size 935: fix_ident 936: check_terminals 937: end
# File lib/racc/grammar.rb, line 886 886: def intern(val, dummy = false) 887: @cache[val] ||= 888: begin 889: sym = Sym.new(val, dummy) 890: @symbols.push sym 891: sym 892: end 893: end
# File lib/racc/grammar.rb, line 921 921: def nonterminals 922: @symbols[@nt_base, @symbols.size - @nt_base] 923: end
# File lib/racc/grammar.rb, line 947 947: def check_terminals 948: return unless @symbols.any? {|s| s.should_terminal? } 949: @anchor.should_terminal 950: @error.should_terminal 951: each_terminal do |t| 952: t.should_terminal if t.string_symbol? 953: end 954: each do |s| 955: s.should_terminal if s.assoc 956: end 957: terminals().reject {|t| t.should_terminal? }.each do |t| 958: raise CompileError, "terminal #{t} not declared as terminal" 959: end 960: nonterminals().select {|n| n.should_terminal? }.each do |n| 961: raise CompileError, "symbol #{n} declared as terminal but is not terminal" 962: end 963: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.