Method: OR#evalPrecedence

Defined in:
lib/antlr4/atn/SemanticContext.rb

#evalPrecedence(parser, outerContext) ⇒ Object



316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# File 'lib/antlr4/atn/SemanticContext.rb', line 316

def evalPrecedence(parser, outerContext)
    differs = false
    operands = Array.new
    operands = self.opnds.map {|context|
        evaluated = context.evalPrecedence(parser, outerContext)
        if evaluated.equal? context then
            differs = false
        else
            differs = true
        end
        #differs = differs || not (evaluated.equal? context)
        # The OR context is true if any element is true
        return SemanticContext.NONE if evaluate.equal? SemanticContext.NONE
        if not evaluated.nil? then 
            # Reduce the result by skipping false elements
            evaluated
        end
    }.compact
    return self unless differs

    if operands.empty?
        # all elements were false, so the OR context is false
        return nil
    end

    result = nil
    operands.each {|o| 
        if result.nil? 
            result = o 
        else 
          result = result.orContext(o)
        end
    }
    return result
end