Class
Attributes
Read
No documentation available
Read
No documentation available
Read
No documentation available
Read
No documentation available
Read
No documentation available
Read
No documentation available
Class Methods
::
lib/racc/grammar.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/grammar.rb, line 873
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
No documentation available
Instance Methods
#
lib/racc/grammar.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/grammar.rb, line 885
def [](id)
@symbols[id]
end
No documentation available
lib/racc/grammar.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/grammar.rb, line 950
def check_terminals
return unless @symbols.any? {|s| s.should_terminal? }
@anchor.should_terminal
@error.should_terminal
each_terminal do |t|
t.should_terminal if t.string_symbol?
end
each do |s|
s.should_terminal if s.assoc
end
terminals().reject {|t| t.should_terminal? }.each do |t|
raise CompileError, "terminal #{t} not declared as terminal"
end
nonterminals().select {|n| n.should_terminal? }.each do |n|
raise CompileError, "symbol #{n} declared as terminal but is not terminal"
end
end
No documentation available
lib/racc/grammar.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/grammar.rb, line 901
def delete(sym)
@symbols.delete sym
@cache.delete sym.value
end
No documentation available
lib/racc/grammar.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/grammar.rb, line 912
def each(&block)
@symbols.each(&block)
end
No documentation available
lib/racc/grammar.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/grammar.rb, line 928
def each_nonterminal(&block)
@nterms.each(&block)
end
No documentation available
lib/racc/grammar.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/grammar.rb, line 920
def each_terminal(&block)
@terms.each(&block)
end
No documentation available
#
lib/racc/grammar.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/grammar.rb, line 932
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
No documentation available
lib/racc/grammar.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/grammar.rb, line 944
def fix_ident
@symbols.each_with_index do |t, i|
t.ident = i
end
end
No documentation available
lib/racc/grammar.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/grammar.rb, line 889
def intern(val, dummy = false)
@cache[val] ||=
begin
sym = Sym.new(val, dummy)
@symbols.push sym
sym
end
end
No documentation available
lib/racc/grammar.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/grammar.rb, line 924
def nonterminals
@symbols[@nt_base, @symbols.size - @nt_base]
end
No documentation available
#
lib/racc/grammar.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/grammar.rb, line 908
def nt_max
@symbols.size
end
No documentation available
lib/racc/grammar.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/grammar.rb, line 916
def terminals(&block)
@symbols[0, @nt_base]
end
No documentation available