class Antlr4::Runtime::Recognizer

Constants

EOF

Attributes

_interp[RW]
_state_number[RW]

Public Class Methods

new() click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 9
def initialize
  @token_type_map_cache = []
  @rule_index_map_cache = []
  @_listeners = []
  @_listeners << ConsoleErrorListener.instance
  @_interp = nil
  @_state_number = -1
end

Public Instance Methods

action(_localctx, _rule_index, _action_index) click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 130
def action(_localctx, _rule_index, _action_index)
end
add_error_listener(listener) click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 104
def add_error_listener(listener)
  raise NullPointerException, 'listener cannot be nil.' if listener.nil?

  @_listeners << listener
end
error_header(e) click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 81
def error_header(e)
  line = e.getOffendingToken.line
  charPositionInLine = e.getOffendingToken.char_position_in_line
  'line ' + line + ':' + charPositionInLine
end
error_listener_dispatch() click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 118
def error_listener_dispatch
  ProxyErrorListener.new(@_listeners)
end
get_rule_index_map() click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 52
def get_rule_index_map
  if rule_names.nil?
    raise UnsupportedOperationException, 'The current recognizer does not provide a list of rule names.'
  end

  result = @rule_index_map_cache[rule_names]
  if result.nil?
    result = Utils.toMap(rule_names)
    @rule_index_map_cache[rule_names] = result
  end

  result
end
get_serialized_atn() click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 73
def get_serialized_atn
  raise UnsupportedOperationException, 'there is no serialized ATN'
end
get_token_type(token_name) click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 66
def get_token_type(token_name)
  ttype = get_token_type_map[token_name]
  return ttype unless ttype.nil?

  Token::INVALID_TYPE
end
get_token_type_map() click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 30
def get_token_type_map
  vocab = get_vocabulary
  result = @token_type_map_cache[vocab]
  if result.nil?
    result = {}
    i = 0
    while i <= getATN.max_token_type
      literal_name = vocab.literal_name(i)
      result[literal_name] = i unless literal_name.nil?

      symbolic_name = vocab.symbolic_name(i)
      result[symbolic_name] = i unless symbolic_name.nil?
      i += 1
    end

    result['EOF'] = Token::EOF
    @token_type_map_cache[vocab] = result
  end

  result
end
get_vocabulary() click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 18
def get_vocabulary
  VocabularyImpl.from_token_names(token_names)
end
parse_info() click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 77
def parse_info
  nil
end
precpred(_localctx, _precedence) click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 126
def precpred(_localctx, _precedence)
  true
end
remove_error_listener(listener) click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 110
def remove_error_listener(listener)
  @_listeners.delete(listener)
end
remove_error_listeners() click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 114
def remove_error_listeners
  @_listeners.clear
end
rule_names() click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 26
def rule_names
  nil
end
sempred(_localctx, _rule_index, _action_index) click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 122
def sempred(_localctx, _rule_index, _action_index)
  true
end
token_error_display(t) click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 87
def token_error_display(t)
  return '<no token>' if t.nil?

  s = t.text
  if s.nil?
    s = if t.type == Token::EOF
          '<EOF>'
        else
          '<' + t.type + '>'
        end
  end
  s = s.tr_s!("\n", '\\n')
  s = s.tr_s!("\r", '\\r')
  s = s.tr_s!("\t", '\\t')
  "'" + s + "'"
end
token_names() click to toggle source
# File lib/antlr4/runtime/recognizer.rb, line 22
def token_names
  nil
end