class Antlr4::Runtime::SemanticContext::Predicate
Attributes
is_ctx_dependent[RW]
pred_index[RW]
rule_index[RW]
Public Class Methods
new(rule_index = -1, pred_index = -1, is_ctx_dependent = false)
click to toggle source
# File lib/antlr4/runtime/semantic_context.rb, line 15 def initialize(rule_index = -1, pred_index = -1, is_ctx_dependent = false) @rule_index = rule_index @pred_index = pred_index @is_ctx_dependent = is_ctx_dependent @_hash = nil end
Public Instance Methods
eql?(other)
click to toggle source
# File lib/antlr4/runtime/semantic_context.rb, line 42 def eql?(other) return false unless other.is_a? Predicate return true if self == other @rule_index == other.rule_index && @pred_index == other.pred_index && @is_ctx_dependent == other.is_ctx_dependent end
eval(parser, parser_call_stack)
click to toggle source
# File lib/antlr4/runtime/semantic_context.rb, line 22 def eval(parser, parser_call_stack) localctx = @is_ctx_dependent ? parser_call_stack : nil parser.sempred(localctx, @rule_index, @pred_index) end
hash()
click to toggle source
# File lib/antlr4/runtime/semantic_context.rb, line 27 def hash return @_hash unless @_hash.nil? hash_code = RumourHash.calculate([@rule_index, @pred_index, @is_ctx_dependent ? 1 : 0]) unless @_hash.nil? if hash_code == @_hash puts 'Same hash_code for SemanticContext' else puts 'Different hash_code for SemanticContext' end end @_hash = hash_code end
to_s()
click to toggle source
# File lib/antlr4/runtime/semantic_context.rb, line 49 def to_s '{' + @rule_index + ':' + @pred_index + '}?' end