nxt.pattern

Patterns.

Test: dmd -version=show -preview=dip1000 -preview=in -vcolumns -I.. -i -debug -g -checkaction=context -allinst -unittest -main -run pattern.d Test: ldmd2 -fsanitize=address -I.. -i -debug -g -checkaction=context -allinst -unittest -main -run pattern.d Debug: ldmd2 -fsanitize=address -I.. -i -debug -g -checkaction=context -allinst -unittest -main pattern.d && lldb pattern

Concepts and namings are inspired by regular expressions, symbolic (regular) expressions (Emacs' rx.el package), predicate logic and grammars.

String patterns are matched by their raw bytes for now.

Members

Aliases

Data
alias Data = ubyte[]

Untyped data.

Classes

Acronym
class Acronym

Word/Symbol Acronym Pattern.

Alt
class Alt

Alternative of Patterns in ALTS.

Any
class Any

Any Byte.

Clause
class Clause

Pattern Paired with Prefix and Suffix.

Ctx
class Ctx
Undocumented in source but is binding to C++. You might be able to learn more by searching the web for its name.
Lit
class Lit

Literal Pattern with Cached Binary Byte Histogram.

Node
class Node

Base Pattern.

Opt
class Opt

Optional Sub Pattern count times.

Rep
class Rep

Repetition Sub Pattern count times.

SPatt
class SPatt

Abstract Super Pattern.

SPatt1
class SPatt1

Abstract Singleton Super Pattern.

Seq
class Seq

Sequence of Patterns.

Space
class Space
Undocumented in source but is binding to C++. You might be able to learn more by searching the web for its name.

Functions

alt
auto alt(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
any
auto any(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
assac
auto assac(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
aswac
auto aswac(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
bob
Ctx bob(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
bol
Ctx bol(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
bos
Ctx bos(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
bow
Ctx bow(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
braced
Clause braced(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
buf
Seq buf(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
eob
Ctx eob(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
eol
Ctx eol(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
eos
Ctx eos(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
eow
Ctx eow(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
full
auto full(Args args)

Full|Exact literal.

hooked
Clause hooked(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
insac
auto insac(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
inwac
auto inwac(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
kwd
Seq kwd(Arg arg)

Keyword arg.

line
Seq line(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
lit
auto lit(Args args)

Literal.

match
inout(char)[] match(inout(char)[] input, Node node)
Undocumented in source. Be warned that the author may not have intended to support it.
matchFirst
inout(char)[] matchFirst(inout(char)[] input, Node node)

Matching input with node. Compatibility with std.regex.matchFirst.

matchFirst
auto ref matchFirst(Data input, Node node)

Match input with node.

oom
auto oom(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
opt
auto opt(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
paired
Clause paired(Node prefix, Node suffix, Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
parend
Clause parend(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
rep
auto rep(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
seq
auto seq(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
shebangLine
auto ref shebangLine(Node interpreter)

Create Matcher for a UNIX Shell $(LUCKY Shebang) Pattern.

sym
Seq sym(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
word
Seq word(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
ws
auto ws()
Undocumented in source. Be warned that the author may not have intended to support it.
zom
auto zom(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.

Structs

Bounds
struct Bounds

Pattern (length) bounds.

Meta

Authors

TODO: Merge with lpgen.d Node classes TODO: Extend Node classes to represent xlg.el read by LispFileParser. TODO: Replace findRawAt(const Data haystack with findRawAt(in Data haystack

TODO: Overload operators & (and), ! (not),

TODO: Add pattern for expressing inference with infer (infer ((x instanceOf X) & (X subClassOf Y)) (x instaceOf Y))

TODO: Variables are either - _ (ignore) - _x, _y, etc - _'x', _'y' - _!0, _!1, ..., _!(n-1)

infer(rel!desire(_!x, _!y) && rel!madeOf(_!z, _!y), rel!desire(_!x, _!z))

TODO: Support variables of specific types and inference using predicate logic: infer(and(fact(var!'x', rel'desire', var!'y'), fact(var!'z', opt(rel'madeOf', rel'instanceOf'), var!'y'))), pred(var!'x', rel'desire', var!'z' ))

TODO: Make returns from factory functions immutable. TODO: Reuse return patterns from Lit

TODO const s = seq(al..lit,pha.lit); const t = al.lit ~ pha.lit; assert(s !is t); assert(equal(s, t));