Xeger.AST (Xeger v0.1.0)

View Source

Internal AST for Xeger patterns.

Xeger.Parser.Actions builds this tree from a parse of priv/grammar/xeger.aether; Xeger.Generator and Xeger.Random are its consumers.

Summary

Functions

Resolves a :class node's items/neg? (as matched against alphabet) to the concrete list of codepoints it allows. Shared by Xeger.Generator (which enumerates all of them) and Xeger.Random (which picks one).

Types

class_item()

@type class_item() ::
  {:char, non_neg_integer()} | {:range, non_neg_integer(), non_neg_integer()}

t()

@type t() ::
  {:lit, binary()}
  | {:dot}
  | {:class, [class_item()], boolean()}
  | {:seq, [t()]}
  | {:alt, [t()]}
  | {:rep, t(), non_neg_integer(), non_neg_integer() | :infty}

Functions

class_codepoints(items, neg?, alphabet)

@spec class_codepoints([class_item()], boolean(), [non_neg_integer()]) :: [
  non_neg_integer()
]

Resolves a :class node's items/neg? (as matched against alphabet) to the concrete list of codepoints it allows. Shared by Xeger.Generator (which enumerates all of them) and Xeger.Random (which picks one).