exvalibur v0.10.0 Exvalibur.Sigils View Source
Implementation of sigils ~q and ~Q to allow patterns inside matches in rules.
Import this module to get an access to sigils.
Link to this section Summary
Functions
Handles the sigil ~Q for non-interpolated match expressions
Handles the sigil ~q for interpolated match expressions
Link to this section Functions
Link to this macro
sigil_Q(term, modifiers) View Source (macro)
Handles the sigil ~Q for non-interpolated match expressions.
It returns an AST that might be used as is in Exvalibur.validator!/2’s rules.
Examples
iex> import Exvalibur.Sigils
iex> ~Q[%{} = _]
{:=, [line: 15], [{:%{}, [line: 15], []}, {:_, [line: 15], nil}]}
iex> ~Q[<<"foo", _ :: binary>>]
{:<<>>, [line: 14],
["foo", {:::, [line: 14], [{:_, [line: 14], nil}, {:binary, [line: 14], nil}]}]}
iex> ~Q[<<invalid]
** (TokenMissingError) nofile:14: missing terminator: >> (for "<<" starting at line 14)
Link to this macro
sigil_q(term, modifiers) View Source (macro)
Handles the sigil ~q for interpolated match expressions.
It behaves exactly as sigil_Q save for it interpolates the string passed to sigil.