Class: Predicate
- Inherits:
-
SemanticContext
- Object
- SemanticContext
- Predicate
- Defined in:
- lib/antlr4/atn/SemanticContext.rb
Instance Attribute Summary collapse
-
#isCtxDependent ⇒ Object
Returns the value of attribute isCtxDependent.
-
#predIndex ⇒ Object
Returns the value of attribute predIndex.
-
#ruleIndex ⇒ Object
Returns the value of attribute ruleIndex.
Attributes inherited from SemanticContext
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #eval(parser, outerContext) ⇒ Object
- #hash ⇒ Object
-
#initialize(rule_index = -1,, pred_index = -1,, is_ctx_dependent = false) ⇒ Predicate
constructor
A new instance of Predicate.
- #to_s ⇒ Object
Methods inherited from SemanticContext
NONE, andContext, #andContext, #evalPrecedence, filterPrecedencePredicates, #filterPrecedencePredicates, orContext, #orContext, #simplify
Constructor Details
#initialize(rule_index = -1,, pred_index = -1,, is_ctx_dependent = false) ⇒ Predicate
Returns a new instance of Predicate.
97 98 99 100 101 |
# File 'lib/antlr4/atn/SemanticContext.rb', line 97 def initialize(rule_index=-1, pred_index=-1, is_ctx_dependent=false) self.ruleIndex = rule_index self.predIndex = pred_index self.isCtxDependent = is_ctx_dependent # e.g., $i ref in pred end |
Instance Attribute Details
#isCtxDependent ⇒ Object
Returns the value of attribute isCtxDependent.
96 97 98 |
# File 'lib/antlr4/atn/SemanticContext.rb', line 96 def isCtxDependent @isCtxDependent end |
#predIndex ⇒ Object
Returns the value of attribute predIndex.
96 97 98 |
# File 'lib/antlr4/atn/SemanticContext.rb', line 96 def predIndex @predIndex end |
#ruleIndex ⇒ Object
Returns the value of attribute ruleIndex.
96 97 98 |
# File 'lib/antlr4/atn/SemanticContext.rb', line 96 def ruleIndex @ruleIndex end |
Instance Method Details
#==(other) ⇒ Object
125 126 127 128 129 130 |
# File 'lib/antlr4/atn/SemanticContext.rb', line 125 def ==(other) self.equal?(other)or other.kind_of?(Predicate) and \ self.ruleIndex == other.ruleIndex and \ self.predIndex == other.predIndex and \ self.isCtxDependent == other.isCtxDependent end |
#eql?(other) ⇒ Boolean
122 123 124 |
# File 'lib/antlr4/atn/SemanticContext.rb', line 122 def eql?(other) self == other end |
#eval(parser, outerContext) ⇒ Object
103 104 105 106 107 108 109 110 111 |
# File 'lib/antlr4/atn/SemanticContext.rb', line 103 def eval(parser, outerContext) #localctx = outerContext if self.isCtxDependent else None if self.isCtxDependent localctx = outerContext else localctx = nil end return parser.sempred(localctx, self.ruleIndex, self.predIndex) end |
#hash ⇒ Object
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/antlr4/atn/SemanticContext.rb', line 112 def hash StringIO.open do |buf| buf.write(self.ruleIndex.to_s) buf.write("/") buf.write(self.predIndex.to_s) buf.write("/") buf.write(self.isCtxDependent.to_s) return buf.string().hash end end |
#to_s ⇒ Object
131 132 133 |
# File 'lib/antlr4/atn/SemanticContext.rb', line 131 def to_s "{#{self.ruleIndex}:#{self.predIndex}}?" end |