defmodule ExDiceRoller.Sigil do @moduledoc "Functionality for sigil usage." alias ExDiceRoller.{Compiler, Parser, Tokenizer} @doc """ Handles the sigil `~a` for dice rolling. Returns the compiled version of the dice roll. ## Example ```elixir iex> ``` """ def sigil_a(string, []) do {:ok, tokens} = Tokenizer.tokenize(string) {:ok, parsed} = Parser.parse(tokens) Compiler.compile(parsed) end def sigil_a(string, [mod]) when mod == ?r do {:ok, tokens} = Tokenizer.tokenize(string) {:ok, parsed} = Parser.parse(tokens) fun = Compiler.compile(parsed) fun.([]) end end