A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
vocabulary.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 The A11 Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef A11_FLOW_VOCABULARY_H_
18#define A11_FLOW_VOCABULARY_H_
19
20#include <optional>
21#include <string>
22#include <string_view>
23#include <vector>
24
25#include <absl/base/nullability.h>
26#include <absl/container/flat_hash_set.h>
27#include <absl/types/span.h>
28
29namespace a11::flow {
30
38namespace vocabulary {
39
45std::string Canonical(std::string_view word);
46
48bool IsShouted(std::string_view word);
49
81
84struct EntryPort {
85 std::string_view name;
86 std::string_view type;
88 bool unary;
89 std::string_view description;
90};
91
96absl::Span<const EntryPort> EntryPorts();
97
98absl::Span<const std::string_view> Stages();
99
101std::optional<StageArgument> StageTakes(std::string_view canonical_name);
102
104std::string_view StageArgumentName(StageArgument argument);
105
116struct WordDoc {
118 std::string_view summary;
122 std::string_view takes;
124 std::string_view detail;
127 std::string_view example;
128};
129
135const WordDoc* absl_nullable StageDocumentation(
136 std::string_view canonical_name);
137
145const WordDoc* absl_nullable BuiltinDocumentation(
146 std::string_view canonical_name);
147
162enum class WordRole {
164 kStage,
167 kBuiltin,
174 kClause,
176 kModifier,
179 kSource,
186 kType,
188 kConstant,
194 kLogLevel,
201 kSymbol,
202};
203
212const WordDoc* absl_nullable AnyDocumentation(std::string_view canonical_name);
213
215absl::Span<const WordRole> WordRoles();
216
221std::string_view WordRoleName(WordRole role);
222
228std::vector<std::string_view> WordsOf(WordRole role);
229
234const WordDoc* absl_nullable Documentation(WordRole role,
235 std::string_view canonical_name);
236
242absl::Span<const std::string_view> OrderedSymbols();
243
249const absl::flat_hash_set<std::string_view>& BareStages();
250
257const absl::flat_hash_set<std::string_view>& ParallelStages();
258
264const absl::flat_hash_set<std::string_view>& ReducingStages();
265
268const absl::flat_hash_set<std::string_view>& PositionalStages();
269
271const absl::flat_hash_set<std::string_view>& Builtins();
272
278const absl::flat_hash_set<std::string_view>& TypeNames();
279
284absl::Span<const int> TypeParameters(std::string_view canonical_name);
285
287absl::Span<const std::string_view> OrderedTypeNames();
288
290absl::Span<const std::string_view> OrderedBuiltins();
291
293const absl::flat_hash_set<std::string_view>& StatementWords();
294
297absl::Span<const std::string_view> OrderedStatements();
298
307const absl::flat_hash_set<std::string_view>& ClauseWords();
308
310absl::Span<const std::string_view> OrderedClauseWords();
311
313const absl::flat_hash_set<std::string_view>& DeclarationWords();
314
316absl::Span<const std::string_view> OrderedDeclarations();
317
319const absl::flat_hash_set<std::string_view>& ModifierWords();
320
324absl::Span<const std::string_view> OrderedModifiers();
325
327const absl::flat_hash_set<std::string_view>& SourceWords();
328
330const absl::flat_hash_set<std::string_view>& PortModifierWords();
331
333absl::Span<const std::string_view> OrderedPortModifiers();
334
340const absl::flat_hash_set<std::string_view>& FieldModifierWords();
341
344absl::Span<const std::string_view> OrderedFieldModifiers();
345
347absl::Span<const std::string_view> StatusCodes();
348
350bool IsStatusCode(std::string_view word);
351
356absl::Span<const std::string_view> LogLevels();
357
359bool IsLogLevel(std::string_view word);
360
362const absl::flat_hash_set<std::string_view>& StatusFields();
363
365absl::Span<const std::string_view> OrderedStatusFields();
366
368const absl::flat_hash_set<std::string_view>& ConstantWords();
369
371const absl::flat_hash_set<std::string_view>& OperatorWords();
372
374absl::Span<const std::string_view> DurationUnits();
375
377std::optional<double> DurationUnitSeconds(std::string_view unit);
378
379} // namespace vocabulary
380} // namespace a11::flow
381
382#endif // A11_FLOW_VOCABULARY_H_
const absl::flat_hash_set< std::string_view > & StatementWords()
Words that open a statement, and so are not read as a name there.
Definition vocabulary.cc:2093
absl::Span< const std::string_view > OrderedDeclarations()
The declarations in the order they are written in a flow.
Definition vocabulary.cc:2116
absl::Span< const std::string_view > OrderedModifiers()
The modifiers in the order they read after a call, forward headers being the one that is two words.
Definition vocabulary.cc:2126
std::string_view WordRoleName(WordRole role)
The name a role travels under in flow.vocabulary/v1: port_modifier.
Definition vocabulary.cc:1940
bool IsStatusCode(std::string_view word)
Whether a word names a canonical status code, in either case.
Definition vocabulary.cc:2175
bool IsShouted(std::string_view word)
Whether the word, canonicalised, is written entirely in upper case.
Definition vocabulary.cc:1768
std::vector< std::string_view > WordsOf(WordRole role)
The words role documents, in the order a listing reads them.
Definition vocabulary.cc:1980
const absl::flat_hash_set< std::string_view > & StatusFields()
The fields of a status record: what reading an outcome gives.
Definition vocabulary.cc:2193
std::string_view StageArgumentName(StageArgument argument)
The spelling of a stage argument kind in the output formats.
Definition vocabulary.cc:1806
absl::Span< const std::string_view > StatusCodes()
Abseil's canonical status codes, lower case, which is what fail names.
Definition vocabulary.cc:2171
absl::Span< const std::string_view > OrderedStatements()
The same, in the order they read: what a statement may begin with, most common first.
Definition vocabulary.cc:2098
absl::Span< const std::string_view > OrderedStatusFields()
The same, in the order a status record is written and read.
Definition vocabulary.cc:2198
const WordDoc *absl_nullable AnyDocumentation(std::string_view canonical_name)
What one word does under whichever role documents it, or nullptr.
Definition vocabulary.cc:1915
const WordDoc *absl_nullable BuiltinDocumentation(std::string_view canonical_name)
What a built-in function does, or nullptr where the name is not one.
Definition vocabulary.cc:1842
const absl::flat_hash_set< std::string_view > & ClauseWords()
Words that stand inside a statement without opening one.
Definition vocabulary.cc:2102
std::optional< double > DurationUnitSeconds(std::string_view unit)
The seconds one of that unit is, or nullopt if it is not a unit.
Definition vocabulary.cc:2217
const absl::flat_hash_set< std::string_view > & PortModifierWords()
What a port says about itself after its type: stream, required.
Definition vocabulary.cc:2137
absl::Span< const EntryPort > EntryPorts()
The ports the entry flow has without declaring them, in declaration order.
Definition vocabulary.cc:1781
const WordDoc *absl_nullable Documentation(WordRole role, std::string_view canonical_name)
What one word of role does, or nullptr where that table has no entry.
Definition vocabulary.cc:1848
const absl::flat_hash_set< std::string_view > & ParallelStages()
The stages a value may pass through several at a time.
Definition vocabulary.cc:2050
bool IsLogLevel(std::string_view word)
Whether a word names a log level, in either case.
Definition vocabulary.cc:2161
const absl::flat_hash_set< std::string_view > & SourceWords()
Words that open a pipeline source rather than naming one: status, zip.
Definition vocabulary.cc:2130
const absl::flat_hash_set< std::string_view > & OperatorWords()
Operators that are words: and, or, not.
Definition vocabulary.cc:2208
absl::Span< const std::string_view > OrderedSymbols()
Every punctuation mark and non-word operator the language gives meaning to, in the order a listing re...
Definition vocabulary.cc:1911
const absl::flat_hash_set< std::string_view > & Builtins()
The language's fixed function set. No user code, ever: a flow stays data.
Definition vocabulary.cc:2060
absl::Span< const std::string_view > OrderedTypeNames()
The built-in port type names, in the order a listing reads them.
Definition vocabulary.cc:2074
absl::Span< const std::string_view > OrderedFieldModifiers()
The same, in the order a field writes them, which is the order they are required to be written in.
Definition vocabulary.cc:2152
const absl::flat_hash_set< std::string_view > & DeclarationWords()
Words that declare something inside a flow.
Definition vocabulary.cc:2111
const absl::flat_hash_set< std::string_view > & ReducingStages()
The stages that read a whole stream and yield exactly one value.
Definition vocabulary.cc:2037
const absl::flat_hash_set< std::string_view > & FieldModifierWords()
What a struct field says about itself after its type.
Definition vocabulary.cc:2147
absl::Span< const std::string_view > OrderedPortModifiers()
The same, in the order a port writes them.
Definition vocabulary.cc:2142
absl::Span< const std::string_view > DurationUnits()
Duration suffixes a number may carry, shortest unit first.
Definition vocabulary.cc:2213
const absl::flat_hash_set< std::string_view > & ConstantWords()
Literals that are words: true, false, null, it.
Definition vocabulary.cc:2203
const absl::flat_hash_set< std::string_view > & PositionalStages()
The stages that choose which values of a stream to keep, or group them, rather than reshaping each on...
Definition vocabulary.cc:2043
WordRole
Which table a word is documented in.
Definition vocabulary.h:162
@ kConstant
A literal that is a word: true, it. [ConstantWords].
@ kDeclaration
A word that declares something: flow, in, header.
@ kStatement
A word that opens a statement: run, let, for. [StatementWords].
@ kSymbol
Punctuation and the operators that are not words, keyed by the symbol itself: |, ->,...
@ kClause
A word that continues a statement: else, parallel. [ClauseWords].
@ kFieldModifier
What a struct field says about itself after its type.
@ kLogLevel
The severity a log or logf may name. [LogLevels].
@ kDurationUnit
A duration suffix: ms, h. [DurationUnits].
@ kStage
A pipeline stage: | first 3. Same table as [StageDocumentation].
@ kModifier
A word that may follow a call's ): via, timeout. [ModifierWords].
@ kOperatorWord
An operator that is a word: and, not. [OperatorWords].
@ kSource
A word that opens a pipeline source rather than naming one: status, zip.
@ kBuiltin
A built-in function, where it is called.
@ kType
A built-in port type name. [TypeNames].
@ kStatusCode
One of Abseil's canonical status codes. [StatusCodes].
@ kStatusField
A field of a status record, read after a .. [StatusFields].
@ kPortModifier
What a port says about itself after its type. [PortModifierWords].
absl::Span< const std::string_view > OrderedBuiltins()
The fixed function set, in the order a listing reads it.
Definition vocabulary.cc:2065
const absl::flat_hash_set< std::string_view > & BareStages()
The two stages that may be written without their leading |.
Definition vocabulary.cc:2032
const absl::flat_hash_set< std::string_view > & ModifierWords()
Words that may follow a call's closing parenthesis.
Definition vocabulary.cc:2121
const WordDoc *absl_nullable StageDocumentation(std::string_view canonical_name)
What a stage does, or nullptr where the name is not a stage.
Definition vocabulary.cc:1836
absl::Span< const WordRole > WordRoles()
Every role, for something walking all of them.
Definition vocabulary.cc:1925
const absl::flat_hash_set< std::string_view > & TypeNames()
The built-in port type names.
Definition vocabulary.cc:2069
std::optional< StageArgument > StageTakes(std::string_view canonical_name)
What a stage takes, or nullopt if the name is not a stage.
Definition vocabulary.cc:1798
absl::Span< const std::string_view > OrderedClauseWords()
The same, in the order they read.
Definition vocabulary.cc:2107
absl::Span< const int > TypeParameters(std::string_view canonical_name)
How many type parameters a built-in type may be given.
Definition vocabulary.cc:2078
std::string Canonical(std::string_view word)
The lower-case form of a uniformly-cased word, or the word unchanged.
Definition vocabulary.cc:1745
absl::Span< const std::string_view > LogLevels()
The severities a log or logf may name, quietest first.
Definition vocabulary.cc:2157
StageArgument
What a stage takes after its name.
Definition vocabulary.h:51
@ kOptionalExpression
An expression, optional, with it bound: | sum, | sum it.price.
@ kLogFormat
An optional level word, a format string, and the values to fill it with, with it bound to the value i...
@ kString
A string, required: | strformat "took {}".
@ kFold
A literal to start from, a name for what is carried, and the expression that folds one value into it:...
@ kNone
Nothing: | collect, | count.
@ kSortKey
An optional by key with it bound, and an optional desc: | sort, | sort by it.score desc.
@ kNumber
A whole number of values: | first 3.
@ kDuration
A length of time: | timeout 30s, | pace 100ms.
@ kStream
Another stream to read after this one: | then other.
@ kOptionalString
A string, optional: | join, | join ", ".
@ kExpression
An expression, with it bound to the value in hand: | where it.ok.
@ kLog
An optional level word and an optional expression, with it bound to the value in hand: | log,...
absl::Span< const std::string_view > Stages()
Definition vocabulary.cc:1794
Definition boundary.cc:32
Every pipeline stage, in the order they read best in a listing.
Definition vocabulary.h:84
std::string_view type
Definition vocabulary.h:86
std::string_view name
Definition vocabulary.h:85
std::string_view description
Definition vocabulary.h:89
bool unary
Whether it carries one value rather than a stream.
Definition vocabulary.h:88
What one word of the language does, as reference an editor can show.
Definition vocabulary.h:116
std::string_view example
One line of Flow showing it in use.
Definition vocabulary.h:127
std::string_view takes
What it takes, spelled the way a reader writes it rather than as a type name: "a count",...
Definition vocabulary.h:122
std::string_view detail
How it behaves, and the caveat if it has one. Markdown, a short paragraph.
Definition vocabulary.h:124
std::string_view summary
One line: what it does. A sentence, because it is shown as one.
Definition vocabulary.h:118