|
A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
|
Classes | |
| struct | Capture |
| What one hole took: a view into the subject that was matched. More... | |
| struct | Compiled |
| A pattern, or what is wrong with the text it was written as. More... | |
| struct | Hole |
| One capture position in a pattern. More... | |
| struct | Pattern |
| A compiled pattern: literals and holes, in the order they were written. More... | |
Enumerations | |
| enum class | HoleType { kString , kInt , kNumber , kBool , kWord , kLine , kRest , kDuration , kTime , kJson } |
The pattern language match reads: literal text and named holes. More... | |
Functions | |
| std::string_view | HoleTypeName (HoleType type) |
| std::optional< HoleType > | HoleTypeFromName (std::string_view name) |
| The type that name spells, or nothing where it is not one of them. | |
| Compiled | Compile (std::string_view text) |
| Compile a pattern, saying what is wrong rather than throwing. | |
| std::optional< std::vector< Capture > > | Match (const Pattern &pattern, std::string_view subject) |
Match pattern anywhere in subject, taking the earliest fit. | |
|
strong |
The pattern language match reads: literal text and named holes.
Why not a regular expression. A flow is text somebody writes in the moment, often a model, and the thing being written is almost always "this
line, with these bits pulled out of it". Regex answers that with name.*=.*(?<name>[^ ]+)\s+age.*=.*(?<age>\d+), which is unreadable at a glance and wrong in three ways before it is right. The same intent here is name={name} age={age:int}, and there is nothing to escape.
| In the pattern | Means |
|---|---|
| literal text | matches itself |
| a run of whitespace | matches any run of whitespace, at least one |
{name} | captures up to whatever literal follows, as little as it can |
{name:int} | and reads it as an integer |
{} | captures without a name, read as it[0], it[1], ... |
{{, }} | a literal brace |
The pattern searches: it matches anywhere in the value, so match("age={age:int}", line) works on a longer line without leading and trailing wildcards. A hole captures at least one character and does not cross a line break unless its type says to.
This half knows nothing about [Value]: it compiles a pattern, says what its holes are called, and hands back the text each one took. Reading that text as a number, an instant or a duration is the value layer's job, and keeping the split is what lets the resolver ask a pattern for its field names without the runtime being linked in. What a hole reads its text as, and how much of it a hole may take.
| Compiled a11::flow::pattern::Compile | ( | std::string_view | text | ) |
Compile a pattern, saying what is wrong rather than throwing.
| std::optional< HoleType > a11::flow::pattern::HoleTypeFromName | ( | std::string_view | name | ) |
The type that name spells, or nothing where it is not one of them.
| std::string_view a11::flow::pattern::HoleTypeName | ( | HoleType | type | ) |