Class: PrecedencePredicate

Inherits:
SemanticContext show all
Defined in:
lib/antlr4/atn/SemanticContext.rb

Instance Attribute Summary collapse

Attributes inherited from SemanticContext

#opnds

Instance Method Summary collapse

Methods inherited from SemanticContext

NONE, #andContext, andContext, filterPrecedencePredicates, #filterPrecedencePredicates, #orContext, orContext, #simplify

Constructor Details

#initialize(_precedence = 0) ⇒ PrecedencePredicate

Returns a new instance of PrecedencePredicate.



139
140
141
# File 'lib/antlr4/atn/SemanticContext.rb', line 139

def initialize(_precedence=0)
    self.precedence = _precedence
end

Instance Attribute Details

#precedenceObject

Returns the value of attribute precedence.



138
139
140
# File 'lib/antlr4/atn/SemanticContext.rb', line 138

def precedence
  @precedence
end

Instance Method Details

#<=>(other) ⇒ Object



154
155
156
# File 'lib/antlr4/atn/SemanticContext.rb', line 154

def <=>(other)
    return self.precedence - other.precedence
end

#==(other) ⇒ Object



165
166
167
# File 'lib/antlr4/atn/SemanticContext.rb', line 165

def ==(other)
    self.equal?(other) or (other.kind_of?(PrecedencePredicate) and self.precedence == other.precedence )
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


162
163
164
# File 'lib/antlr4/atn/SemanticContext.rb', line 162

def eql?(other)
    self == other
end

#eval(parser, outer_context) ⇒ Object



143
144
145
# File 'lib/antlr4/atn/SemanticContext.rb', line 143

def eval(parser, outer_context)
    return parser.precpred(outer_context, self.precedence)
end

#evalPrecedence(parser, outer_context) ⇒ Object



147
148
149
150
151
152
153
# File 'lib/antlr4/atn/SemanticContext.rb', line 147

def evalPrecedence(parser, outer_context)
    if parser.precpred(outer_context, self.precedence)
        return SemanticContext.NONE
    else
        return nil
    end
end

#hashObject



158
159
160
# File 'lib/antlr4/atn/SemanticContext.rb', line 158

def hash
    return 31
end