View Source Rollex.Token protocol (Rollex v0.9.0)

Link to this section Summary

Functions

Create a token from the passed-in string representing a roll expression. Returns a token and the number of bytes consumed in doing so.

The left binding power (lbp), or the precedence in infix form for operator precedence. Higher lbp takes precedence over lower

Left denotation (led): take action when this token is encountered within an expression, e.g. infix and postfix operations

Null denotation (nud): the action take when this token is at the start of an expression, e.g. prefix operations

Link to this section Types

Link to this section Functions

Link to this function

create(token, roll_expr, matches)

View Source
@spec create(Rollex.token(), roll_expr :: String.t(), matches :: [String.t()] | nil) ::
  {Rollex.token(), num_bytes_consumed :: integer()}

Create a token from the passed-in string representing a roll expression. Returns a token and the number of bytes consumed in doing so.

@spec lbp(Rollex.token()) :: integer()

The left binding power (lbp), or the precedence in infix form for operator precedence. Higher lbp takes precedence over lower

@spec led(Rollex.token(), left :: Rollex.totals(), rest :: Rollex.tokens()) ::
  {:ok, Rollex.totals(), Rollex.tokens()} | {:error, reason :: String.t()}

Left denotation (led): take action when this token is encountered within an expression, e.g. infix and postfix operations

@spec nud(Rollex.token(), rest :: Rollex.tokens()) ::
  {:ok, Rollex.totals(), Rollex.tokens()} | {:error, reason :: String.t()}

Null denotation (nud): the action take when this token is at the start of an expression, e.g. prefix operations