SnmpKit.SnmpLib.MIB.SnmpTokenizer (snmpkit v0.6.3)

True 1:1 Elixir port of Erlang SNMP tokenizer (snmpc_tok.erl).

This is a direct translation of the official Erlang SNMP tokenizer from OTP lib/snmp/src/compile/snmpc_tok.erl

Original copyright: Ericsson AB 1996-2025 (Apache License 2.0)

Summary

Functions

Returns a specification to start this module under a supervisor.

Format error message. Equivalent to snmpc_tok:format_error/1

Get all remaining tokens. Equivalent to snmpc_tok:get_all_tokens/1

Get next token from tokenizer. Equivalent to snmpc_tok:get_token/1

Null get_line function. Equivalent to snmpc_tok:null_get_line/0

Start tokenizer gen_server. Equivalent to snmpc_tok:start_link/2

Stop tokenizer. Equivalent to snmpc_tok:stop/1

Test function. Equivalent to snmpc_tok:test/0

Tokenize a string directly. Equivalent to snmpc_tok:tokenize/2

Types

state()

@type state() :: %SnmpKit.SnmpLib.MIB.SnmpTokenizer{
  chars: charlist(),
  get_line_fun: function() | nil,
  line: pos_integer()
}

token()

@type token() :: {atom(), any(), pos_integer()}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

format_error(error)

@spec format_error(term()) :: charlist()

Format error message. Equivalent to snmpc_tok:format_error/1

get_all_tokens(pid)

@spec get_all_tokens(pid()) :: {:ok, [token()]} | {:error, term()}

Get all remaining tokens. Equivalent to snmpc_tok:get_all_tokens/1

get_token(pid)

@spec get_token(pid()) :: {:ok, token()} | {:error, term()}

Get next token from tokenizer. Equivalent to snmpc_tok:get_token/1

null_get_line()

@spec null_get_line() :: :eof

Null get_line function. Equivalent to snmpc_tok:null_get_line/0

start_link(chars, get_line_pid)

@spec start_link(
  charlist(),
  pid()
) :: {:ok, pid()} | {:error, term()}

Start tokenizer gen_server. Equivalent to snmpc_tok:start_link/2

stop(pid)

@spec stop(pid()) :: :ok

Stop tokenizer. Equivalent to snmpc_tok:stop/1

test()

Test function. Equivalent to snmpc_tok:test/0

tokenize(chars, get_line_fun)

@spec tokenize(
  charlist(),
  function()
) :: {:ok, [token()]} | {:error, term()}

Tokenize a string directly. Equivalent to snmpc_tok:tokenize/2