Class
A LALR state.
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
Read
No documentation available
Read
No documentation available
Read
No documentation available
Read
No documentation available
Read
No documentation available
Read & Write
No documentation available
Read
No documentation available
Read
No documentation available
Class Methods
lib/racc/state.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/state.rb, line 609
def initialize(ident, core)
@ident = ident
@core = core
@goto_table = {}
@gotos = {}
@stokens = nil
@ritems = nil
@action = {}
@defact = nil
@rrconf = nil
@srconf = nil
@closure = make_closure(@core)
end
No documentation available
Instance Methods
#
lib/racc/state.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/state.rb, line 650
def ==(oth)
@ident == oth.ident
end
No documentation available
lib/racc/state.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/state.rb, line 667
def check_la(la_rules)
@conflict = false
s = []
r = []
@closure.each do |ptr|
if t = ptr.dereference
if t.terminal?
s[t.ident] = t
if t.ident == 1 # $error
@conflict = true
end
end
else
r.push ptr.rule
end
end
unless r.empty?
if not s.empty? or r.size > 1
@conflict = true
end
end
s.compact!
@stokens = s
@rrules = r
if @conflict
@la_rules_i = la_rules.size
@la_rules = r.map {|i| i.ident }
la_rules.concat r
else
@la_rules_i = @la_rules = nil
end
end
No documentation available
lib/racc/state.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/state.rb, line 701
def conflict?
@conflict
end
No documentation available
#
lib/racc/state.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/state.rb, line 644
def inspect
"<state #{@ident}>"
end
No documentation available
#
lib/racc/state.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/state.rb, line 718
def la=(la)
return unless @conflict
i = @la_rules_i
@ritems = r = []
@rrules.each do |rule|
r.push Item.new(rule, la[i])
i += 1
end
end
No documentation available
lib/racc/state.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/state.rb, line 656
def make_closure(core)
set = ISet.new
core.each do |ptr|
set.add ptr
if t = ptr.dereference and t.nonterminal?
set.update_a t.expand
end
end
set.to_a
end
No documentation available
lib/racc/state.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/state.rb, line 754
def n_rrconflicts
@rrconf ? @rrconf.size : 0
end
No documentation available
lib/racc/state.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/state.rb, line 750
def n_srconflicts
@srconf ? @srconf.size : 0
end
No documentation available
lib/racc/state.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/state.rb, line 728
def rr_conflict(high, low, ctok)
c = RRconflict.new(@ident, high, low, ctok)
@rrconf ||= {}
if a = @rrconf[ctok]
a.push c
else
@rrconf[ctok] = [c]
end
end
No documentation available
lib/racc/state.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/state.rb, line 705
def rruleid(rule)
if i = @la_rules.index(rule.ident)
@la_rules_i + i
else
puts '/// rruleid'
p self
p rule
p @rrules
p @la_rules_i
raise 'racc: fatal: cannot get reduce rule id'
end
end
No documentation available
lib/racc/state.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/racc/state.rb, line 739
def sr_conflict(shift, reduce)
c = SRconflict.new(@ident, shift, reduce)
@srconf ||= {}
if a = @srconf[shift]
a.push c
else
@srconf[shift] = [c]
end
end
No documentation available