docs: def _symbol_identifier_or_unquoted_symbol_handler(c, ctx, is_field_name=False):
      """Handles symbol tokens that begin with a dollar sign. These may end up being system symbols ($ion_*), symbol
      identifiers ('$' DIGITS+), or regular unquoted symbols.
      """
      assert c == _DOLLAR_SIGN
      in_sexp = ctx.container.ion_type is IonType.SEXP
      ctx.set_unicode().set_ion_type(IonType.SYMBOL)
      val = ctx.value
      val.append(c)
      prev = c
      c, self = yield
      trans = ctx.immediate_transition(self)
      maybe_ivm = ctx.depth == 0 and not is_field_name and not ctx.annotations
      complete_ivm = False
      maybe_symbol_identifier = True
      match_index = 1
      ivm_post_underscore = False
      while True:
          if c not in _WHITESPACE:
              if prev in _WHITESPACE or _ends_value(c) or c == _COLON or (in_sexp and c in _OPERATORS):
                  break
              maybe_symbol_identifier = maybe_symbol_identifier and c in _DIGITS
              if maybe_ivm:
                  if match_index == len(_IVM_PREFIX):
                      if c in _DIGITS:
                          if ivm_post_underscore:
                              complete_ivm = True
                      elif c == _UNDERSCORE and not ivm_post_underscore:
                          ivm_post_underscore = True
                      else:
                          maybe_ivm = False
                          complete_ivm = False
                  else:
                      maybe_ivm = c == _IVM_PREFIX[match_index]
              if maybe_ivm:
                  if match_index < len(_IVM_PREFIX):
                      match_index += 1
              elif not maybe_symbol_identifier:
                  yield ctx.immediate_transition(_unquoted_symbol_handler(c, ctx, is_field_name))
              val.append(c)
          elif match_index < len(_IVM_PREFIX):
              maybe_ivm = False
          prev = c
          c, _ = yield trans
      if len(val) == 1:
          assert val[0] == _chr(_DOLLAR_SIGN)
      elif maybe_symbol_identifier:
          assert not maybe_ivm
          sid = int(val[1:])
          val = SymbolToken(None, sid)
      elif complete_ivm:
          val = _IVMToken(*val.as_symbol())
      yield _symbol_token_end(c, ctx, is_field_name, value=val)