Class: Antlr4::Runtime::SemanticContext

Inherits:
Object
  • Object
show all
Defined in:
lib/antlr4/runtime/semantic_context.rb

Direct Known Subclasses

Operator, PrecedencePredicate, Predicate

Defined Under Namespace

Classes: AND, OR, Operator, PrecedencePredicate, Predicate

Constant Summary collapse

NONE =
Predicate.new

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.and(a, b) ⇒ Object


284
285
286
287
288
289
290
291
292
# File 'lib/antlr4/runtime/semantic_context.rb', line 284

def self.and(a, b)
  return b if a.nil? || a == NONE
  return a if b.nil? || b == NONE

  result = AND.new(a, b)
  return result.opnds[0] if result.opnds.length == 1

  result
end

.filter_precedence_predicates(collection) ⇒ Object


305
306
307
308
309
# File 'lib/antlr4/runtime/semantic_context.rb', line 305

def self.filter_precedence_predicates(collection)
  result = collection.select {|item| item.is_a? PrecedencePredicate}
  collection.reject! {|item| (item.is_a? PrecedencePredicate)}
  result
end

.or(a, b) ⇒ Object


294
295
296
297
298
299
300
301
302
303
# File 'lib/antlr4/runtime/semantic_context.rb', line 294

def self.or(a, b)
  return b if a.nil?
  return a if b.nil?
  return NONE if a == NONE || b == NONE

  OR result = OR.new(a, b)
  return result.opnds[0] if result.opnds.length == 1

  result
end

Instance Method Details

#eval(parser, parser_call_stack) ⇒ Object


3
4
# File 'lib/antlr4/runtime/semantic_context.rb', line 3

def eval(parser, parser_call_stack)
end

#eval_precedence(_parser, _parser_call_stack) ⇒ Object


6
7
8
# File 'lib/antlr4/runtime/semantic_context.rb', line 6

def eval_precedence(_parser, _parser_call_stack)
  self
end