A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
syntax.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_SYNTAX_H_
18#define A11_FLOW_SYNTAX_H_
19
20#include <cstddef>
21#include <functional>
22#include <memory>
23#include <optional>
24#include <string>
25#include <string_view>
26#include <utility>
27#include <vector>
28
29#include <absl/time/time.h>
30
31#include "a11/flow/token.h"
32#include "a11/flow/vocabulary.h"
33
34namespace a11::flow::syntax {
35
49struct Location {
50 size_t start = 0;
51 size_t end = 0;
52 int line = 1;
53 int column = 1;
54};
55
57Location LocationOf(const Token& token);
58
65struct Word {
66 std::string text;
68
69 [[nodiscard]] bool Empty() const { return text.empty(); }
70};
71
72// A value the language can write out in full: what a literal is, and what
73// folding a literal expression gives.
80struct Constant {
81 enum class Kind {
82 kNull,
83 kBool,
85 kDouble,
86 kString,
88 kList,
89 kObject,
90 };
91
93 bool boolean = false;
94 long long integer = 0;
95 double number = 0.0;
96 std::string text;
97 absl::Duration duration;
98 std::vector<Constant> items;
99 std::vector<std::pair<std::string, Constant>> pairs;
100
101 static Constant Null() { return {}; }
102
103 static Constant Bool(bool value);
104 static Constant Integer(long long value);
105 static Constant Double(double value);
106 static Constant String(std::string value);
107 static Constant Duration(absl::Duration value);
108
110 [[nodiscard]] double AsDouble() const;
111};
112
114std::string_view ConstantKindName(Constant::Kind kind);
115
116// The type of a port, or of a value being made one: `string`,
117// `list[a11.NodeFragment]`, `"audio/wav"`.
128 std::string name;
129 std::vector<TypeExpression> parameters = {};
130 bool quoted = false;
136 bool sugared = false;
137
139 [[nodiscard]] std::string ToString() const;
140};
141
143enum class NodeKind {
147 kError,
148
149 kLiteral,
152 kSpread,
153 kIt,
154 kDiscard,
155 kName,
156 kAttr,
157 kIndex,
158 kBuiltin,
159 kZip,
161 kUnary,
162 kBinary,
163
164 kStage,
165 kPipeline,
166 kOutcome,
168
171
172 kBind,
173 kLet,
174 kAdvance,
175 kBlock,
177 kPipe,
178 kSkip,
179 kWait,
180 kDrain,
181 kCancel,
182 kAbort,
183 kFail,
184 kLog,
185 kForEach,
186 kRepeat,
187 kCarry,
188 kUntil,
189 kIf,
190 kNodes,
192
198};
199
201std::string_view NodeKindName(NodeKind kind);
202
204struct Node {
205 virtual ~Node() = default;
206
209};
210
211using NodePtr = std::unique_ptr<Node>;
212
214template <NodeKind K>
215struct NodeOf : Node {
216 static constexpr NodeKind kNodeKind = K;
217
218 NodeOf() { kind = K; }
219};
220
221// `node` as a `T`, or `nullptr` if it is something else.
226template <typename T>
227const T* As(const Node* node) {
228 if (node == nullptr || node->kind != T::kNodeKind) {
229 {
230 return nullptr;
231 }
232 }
233 return static_cast<const T*>(node);
234}
235
236template <typename T>
238 if (node == nullptr || node->kind != T::kNodeKind) {
239 {
240 return nullptr;
241 }
242 }
243 return static_cast<T*>(node);
244}
245
247bool IsAnyOf(const Node* node, std::initializer_list<NodeKind> kinds);
248
249// --- Expressions -------------------------------------------------------------
250
252struct ErrorNode : NodeOf<NodeKind::kError> {
254 std::string expected;
255};
256
258struct Literal : NodeOf<NodeKind::kLiteral> {
260};
261
268struct Spread : NodeOf<NodeKind::kSpread> {
270};
271
273struct ListLiteral : NodeOf<NodeKind::kListLiteral> {
274 std::vector<NodePtr> items;
275};
276
283struct ObjectLiteral : NodeOf<NodeKind::kObjectLiteral> {
284 std::vector<std::pair<std::string, NodePtr>> pairs;
285};
286
288struct It : NodeOf<NodeKind::kIt> {};
289
297struct Discard : NodeOf<NodeKind::kDiscard> {};
298
300struct Name : NodeOf<NodeKind::kName> {
301 std::string name;
302};
303
305struct Attr : NodeOf<NodeKind::kAttr> {
307 std::string name;
308};
309
311struct Index : NodeOf<NodeKind::kIndex> {
314};
315
317struct Builtin : NodeOf<NodeKind::kBuiltin> {
318 std::string name;
319 std::vector<NodePtr> args;
320};
321
334struct Zip : NodeOf<NodeKind::kZip> {
335 std::string name = "zip";
336 std::vector<NodePtr> sources;
337};
338
340struct TypedValue : NodeOf<NodeKind::kTypedValue> {
343};
344
346struct Unary : NodeOf<NodeKind::kUnary> {
347 std::string op;
349};
350
352struct Binary : NodeOf<NodeKind::kBinary> {
353 std::string op;
356};
357
358// --- Pipelines ---------------------------------------------------------------
359
367struct LogTail {
372 std::string format;
374 bool has_format = false;
376 std::vector<NodePtr> arguments;
377};
378
385struct Stage : NodeOf<NodeKind::kStage> {
386 std::string name;
389 double number = 0.0;
390 bool is_integer = false;
392 std::string text;
399 absl::Duration duration;
401 bool descending = false;
410 bool tolerant = false;
416 int parallel = 1;
417 // Whether the values leave in the order they arrived.
422 bool ordered = true;
426};
427
428using StagePtr = std::unique_ptr<Stage>;
429
431struct Pipeline : NodeOf<NodeKind::kPipeline> {
433 std::vector<StagePtr> stages;
434};
435
436using PipelinePtr = std::unique_ptr<Pipeline>;
437
442struct Outcome : NodeOf<NodeKind::kOutcome> {
444};
445
447struct PipelineValue : NodeOf<NodeKind::kPipelineValue> {
449};
450
451// --- Calls -------------------------------------------------------------------
452
454struct CallModifiers : NodeOf<NodeKind::kCallModifiers> {
455 bool tee = false;
457 std::optional<absl::Duration> timeout;
458 std::vector<Word> after;
459 std::vector<std::pair<std::string, NodePtr>> headers;
462 std::vector<std::string> forward;
463};
464
465using CallModifiersPtr = std::unique_ptr<CallModifiers>;
466
468struct CallExpression : NodeOf<NodeKind::kCallExpression> {
474
475 std::string action;
478 std::string mode;
479 std::vector<Argument> args;
481 bool tolerant = false;
482};
483
484using CallExpressionPtr = std::unique_ptr<CallExpression>;
485
486// --- Statements --------------------------------------------------------------
487
489struct Bind : NodeOf<NodeKind::kBind> {
492};
493
509struct Let : NodeOf<NodeKind::kLet> {
510 // One name is the value; several take it apart -- `let name, age = user` by
511 // field, `let first, second = pair` by position.
517 std::vector<Word> names;
519
521 [[nodiscard]] const Word& name() const {
522 static const Word kNone;
523 return names.empty() ? kNone : names.front();
524 }
525};
526
527// `[try] { ...
534struct Block : NodeOf<NodeKind::kBlock> {
535 bool tolerant = false;
536 std::vector<NodePtr> body;
537};
538
542struct Advance : NodeOf<NodeKind::kAdvance> {
544};
545
547struct CallStatement : NodeOf<NodeKind::kCallStatement> {
549};
550
552struct Pipe : NodeOf<NodeKind::kPipe> {
554 std::vector<NodePtr> targets;
555 std::vector<Word> after;
556 // `try source -> dest`: a failure arriving from the source, or refused by the
557 // destination, is a value this flow reads rather than the end of it.
565 bool tolerant = false;
566};
567
572 std::vector<Word> outputs;
573};
574
578struct Skip : NodeOf<NodeKind::kSkip> {
579 std::vector<SkipTarget> targets;
580 std::vector<Word> after;
581 std::optional<long long> count;
582};
583
584// `wait subject` -- hold until a call, or a node this flow writes, is finished.
593struct Wait : NodeOf<NodeKind::kWait> {
595 std::vector<NodePtr> subjects;
598 bool race = false;
599 std::optional<absl::Duration> timeout;
600 std::vector<Word> after;
601 // `wait first of a, b -> n`: where the winner's number goes.
608 std::vector<NodePtr> targets;
609};
610
613struct Drain : NodeOf<NodeKind::kDrain> {
615 std::vector<Word> after;
616};
617
619struct Cancel : NodeOf<NodeKind::kCancel> {
621 std::vector<Word> after;
622};
623
629struct Abort : NodeOf<NodeKind::kAbort> {
633 std::vector<Word> after;
634};
635
637struct Fail : NodeOf<NodeKind::kFail> {
640 std::vector<Word> after;
641};
642
645struct Log : NodeOf<NodeKind::kLog> {
647 std::vector<Word> after;
648};
649
650// `for name[, name...] in pipeline [parallel n] { ...
655struct ForEach : NodeOf<NodeKind::kForEach> {
656 std::vector<Word> variables;
658 int parallel = 1;
659 std::vector<NodePtr> body;
665 std::vector<Word> after;
666
668 [[nodiscard]] const Word& variable() const {
669 static const Word kNone;
670 return variables.empty() ? kNone : variables.front();
671 }
672};
673
675struct Repeat : NodeOf<NodeKind::kRepeat> {
679 // `max n`, where one was written.
685 std::optional<int> max_iterations;
686 std::vector<NodePtr> body;
688 std::vector<Word> after;
689};
690
692struct Carry : NodeOf<NodeKind::kCarry> {
695};
696
698struct Until : NodeOf<NodeKind::kUntil> {
700 bool stop_when = true;
701};
702
704struct If : NodeOf<NodeKind::kIf> {
706 std::vector<NodePtr> then_body;
707 std::vector<NodePtr> else_body;
708};
709
711struct Nodes : NodeOf<NodeKind::kNodes> {
713 std::vector<NodePtr> body;
716 bool has_body = false;
717};
718
720struct NodeExpression : NodeOf<NodeKind::kNodeExpression> {
723};
724
725// --- Declarations ------------------------------------------------------------
726
729
732
734struct PortDeclaration : NodeOf<NodeKind::kPortDeclaration> {
739 bool unary = true;
740 bool required = false;
741 std::string description;
742};
743
744using PortDeclarationPtr = std::unique_ptr<PortDeclaration>;
745
747struct HeaderDeclaration : NodeOf<NodeKind::kHeaderDeclaration> {
748 std::string name;
751 bool has_default = false;
752 std::string description;
753};
754
755using HeaderDeclarationPtr = std::unique_ptr<HeaderDeclaration>;
756
758struct FlowDeclaration : NodeOf<NodeKind::kFlowDeclaration> {
774 bool entry = false;
775 std::string description;
776 std::vector<PortDeclarationPtr> ports;
777 std::vector<HeaderDeclarationPtr> headers;
778 std::vector<NodePtr> body;
779};
780
781using FlowDeclarationPtr = std::unique_ptr<FlowDeclaration>;
782
790 bool has_minimum = false;
791 bool has_maximum = false;
794
795 [[nodiscard]] bool Empty() const { return !has_minimum && !has_maximum; }
796};
797
799struct FieldDeclaration : NodeOf<NodeKind::kFieldDeclaration> {
804 bool required = false;
806 bool unique = false;
810 std::string pattern;
811 bool has_pattern = false;
813 std::vector<Constant> enumeration;
814 bool has_enumeration = false;
817 bool has_default = false;
818 std::string description;
819};
820
821using FieldDeclarationPtr = std::unique_ptr<FieldDeclaration>;
822
823// One `struct name { ...
829struct DtoDeclaration : NodeOf<NodeKind::kDtoDeclaration> {
831 std::string description;
832 std::vector<FieldDeclarationPtr> fields;
833};
834
835using DtoDeclarationPtr = std::unique_ptr<DtoDeclaration>;
836
837// The constant `node` folds to, or `nullopt` where it is not one all the way
838// down.
845std::optional<Constant> ConstantValue(const Node* node);
846
857void VisitChildren(const Node& node,
858 const std::function<void(const Node&)>& visit);
859
872void VisitSubtree(const Node& node,
873 const std::function<void(const Node&)>& visit);
874
879std::optional<std::string> DottedName(const Node* node);
880
881} // namespace a11::flow::syntax
882
883#endif // A11_FLOW_SYNTAX_H_
std::string value
Definition discover.cc:114
TokenKind kind
Definition format.cc:913
std::string direction
in, out or header, as written – a shouted IN stays shouted.
Definition format.cc:47
Definition syntax.cc:27
Location LocationOf(const Token &token)
The location a token occupies.
Definition syntax.cc:29
std::string_view PortDirectionName(PortDirection direction)
"inputs" or "outputs".
Definition syntax.cc:229
std::unique_ptr< DtoDeclaration > DtoDeclarationPtr
Definition syntax.h:835
std::optional< Constant > ConstantValue(const Node *node)
The constant node folds to, or nullopt where it is not one all the way down.
Definition syntax.cc:251
void VisitSubtree(const Node &node, const std::function< void(const Node &)> &visit)
Every node of the subtree rooted at node, node itself included.
Definition syntax.cc:546
std::unique_ptr< Pipeline > PipelinePtr
Definition syntax.h:436
std::unique_ptr< FlowDeclaration > FlowDeclarationPtr
Definition syntax.h:781
void VisitChildren(const Node &node, const std::function< void(const Node &)> &visit)
Every node node directly holds, in the order they were written.
Definition syntax.cc:306
std::unique_ptr< CallModifiers > CallModifiersPtr
Definition syntax.h:465
bool IsAnyOf(const Node *node, std::initializer_list< NodeKind > kinds)
Whether a node is one of the kinds given.
Definition syntax.cc:222
std::unique_ptr< HeaderDeclaration > HeaderDeclarationPtr
Definition syntax.h:755
PortDirection
Which side of the descriptor a port lands on, spelled as the plan spells it.
Definition syntax.h:728
std::unique_ptr< PortDeclaration > PortDeclarationPtr
Definition syntax.h:744
std::unique_ptr< Stage > StagePtr
Definition syntax.h:428
std::optional< std::string > DottedName(const Node *node)
a11.sdk.AudioBuffer for a chain of plain names, or nullopt.
Definition syntax.cc:558
std::string_view ConstantKindName(Constant::Kind kind)
The spelling of a constant's kind in the output formats.
Definition syntax.cc:87
std::unique_ptr< CallExpression > CallExpressionPtr
Definition syntax.h:484
std::unique_ptr< Node > NodePtr
Definition syntax.h:211
std::unique_ptr< FieldDeclaration > FieldDeclarationPtr
Definition syntax.h:821
const T * As(const Node *node)
node as a T, or nullptr if it is something else.
Definition syntax.h:227
NodeKind
What a node is. One per construct, mirroring a11/flow/syntax.py.
Definition syntax.h:143
@ kError
Something the parser could not read.
std::string_view NodeKindName(NodeKind kind)
The name of a node kind in the output formats, in kebab case.
Definition syntax.cc:124
StageArgument
What a stage takes after its name.
Definition vocabulary.h:51
@ kNone
Nothing: | collect, | count.
absl::Duration Duration
A11 duration; an alias of absl::Duration (nanosecond-aware).
Definition time.h:40
graph::RefId node
The graph ref this answer corresponds to, when a graph is being built.
Definition resolve.cc:698
One token: what it is, where it is, and what it holds.
Definition token.h:87
abort node [code] [message] – end a node with a failure.
Definition syntax.h:629
NodePtr message
Definition syntax.h:632
std::vector< Word > after
Definition syntax.h:633
NodePtr target
Definition syntax.h:630
NodePtr code
Definition syntax.h:631
advance name – rebind a let value to the next value of its stream.
Definition syntax.h:542
Word name
Definition syntax.h:543
base.name – a call's port, or a key of a value.
Definition syntax.h:305
NodePtr base
Definition syntax.h:306
std::string name
Definition syntax.h:307
left op right for and or == != < <= > >= in + -.
Definition syntax.h:352
NodePtr left
Definition syntax.h:354
std::string op
Definition syntax.h:353
NodePtr right
Definition syntax.h:355
name = ... – a step the rest of the flow can refer to.
Definition syntax.h:489
Word name
Definition syntax.h:490
NodePtr value
Definition syntax.h:491
[try] { ... } – a block of statements that runs as one thing.
Definition syntax.h:534
bool tolerant
Definition syntax.h:535
std::vector< NodePtr > body
Definition syntax.h:536
name(arg, ...) – one of the language's fixed functions.
Definition syntax.h:317
std::vector< NodePtr > args
Definition syntax.h:319
std::string name
Definition syntax.h:318
One argument: the port named, where it was named, and what feeds it.
Definition syntax.h:470
PipelinePtr pipeline
Definition syntax.h:472
run/call action(port: pipeline, ...) and its modifiers.
Definition syntax.h:468
std::string mode
The verb written: "run" for the handler registered here, "call" for the stream this flow is attached ...
Definition syntax.h:478
std::vector< Argument > args
Definition syntax.h:479
std::string action
Definition syntax.h:475
bool tolerant
Definition syntax.h:481
CallModifiersPtr modifiers
Definition syntax.h:480
The tee/via/timeout/after/with/id/forward tail of a call.
Definition syntax.h:454
std::vector< Word > after
Definition syntax.h:458
std::vector< std::string > forward
Header names, or * patterns, that forward headers names.
Definition syntax.h:462
bool tee
Definition syntax.h:455
NodePtr action_id
Definition syntax.h:460
Word node_map
Definition syntax.h:456
std::vector< std::pair< std::string, NodePtr > > headers
Definition syntax.h:459
std::optional< absl::Duration > timeout
Definition syntax.h:457
A call whose outputs nobody names (they are drained for it).
Definition syntax.h:547
CallExpressionPtr call
Definition syntax.h:548
cancel name – ask a called action to stop, cooperatively.
Definition syntax.h:619
Word name
Definition syntax.h:620
std::vector< Word > after
Definition syntax.h:621
name <- pipeline – what the next pass of a repeat carries.
Definition syntax.h:692
PipelinePtr pipeline
Definition syntax.h:694
Word name
Definition syntax.h:693
A value the language can write out in full: what a literal is, and what folding a literal expression ...
Definition syntax.h:80
std::vector< std::pair< std::string, Constant > > pairs
Definition syntax.h:99
static Constant Null()
Definition syntax.h:101
std::vector< Constant > items
Definition syntax.h:98
Kind
Definition syntax.h:81
double AsDouble() const
The number this holds, whichever way it was written.
Definition syntax.cc:74
static Constant Double(double value)
Definition syntax.cc:53
double number
Definition syntax.h:95
static Constant Bool(bool value)
Definition syntax.cc:38
static Constant String(std::string value)
Definition syntax.cc:60
absl::Duration duration
Definition syntax.h:97
std::string text
Definition syntax.h:96
static Constant Integer(long long value)
Definition syntax.cc:45
Kind kind
Definition syntax.h:92
long long integer
Definition syntax.h:94
_ – the destination that keeps nothing.
Definition syntax.h:297
drain target – hold until a node's writers are done and its buffer has landed.
Definition syntax.h:613
std::vector< Word > after
Definition syntax.h:615
NodePtr target
Definition syntax.h:614
One struct name { ... } declaration: a shape a port may be typed with.
Definition syntax.h:829
std::vector< FieldDeclarationPtr > fields
Definition syntax.h:832
Word name
Definition syntax.h:830
std::string description
Definition syntax.h:831
A place the parser wanted a value and did not find one.
Definition syntax.h:252
std::string expected
What was expected there, for a formatter deciding to leave it alone.
Definition syntax.h:254
fail [code] [message] – end the flow with a status.
Definition syntax.h:637
NodePtr message
Definition syntax.h:639
std::vector< Word > after
Definition syntax.h:640
NodePtr code
Definition syntax.h:638
One name: type [modifiers] ["description"] field of a struct.
Definition syntax.h:799
bool unique
unique: no two items of a list are equal.
Definition syntax.h:806
Constant default_value
default ..: what a value that was not given is.
Definition syntax.h:816
bool required
Whether a value has to be given.
Definition syntax.h:804
bool has_pattern
Definition syntax.h:811
bool has_enumeration
Definition syntax.h:814
std::string pattern
matching "...": the pattern every value has to match, unanchored, as JSONSchema's pattern is.
Definition syntax.h:810
std::string description
Definition syntax.h:818
FieldRange range
Definition syntax.h:807
std::vector< Constant > enumeration
one of [..]: the only values allowed.
Definition syntax.h:813
Word name
Definition syntax.h:800
bool has_default
Definition syntax.h:817
TypeExpression type
Definition syntax.h:801
A bound on a field: 1..200, 1.., ..200.
Definition syntax.h:789
Constant maximum
Definition syntax.h:793
bool Empty() const
Definition syntax.h:795
bool has_minimum
Definition syntax.h:790
bool has_maximum
Definition syntax.h:791
Constant minimum
Definition syntax.h:792
One flow name { ... } declaration, or the one flow { ... } entry point.
Definition syntax.h:758
std::string description
Definition syntax.h:775
std::vector< PortDeclarationPtr > ports
Definition syntax.h:776
std::vector< HeaderDeclarationPtr > headers
Definition syntax.h:777
std::vector< NodePtr > body
Definition syntax.h:778
bool entry
Whether this is the file's entry point: flow { ... }, with no name.
Definition syntax.h:774
Word name
Definition syntax.h:759
for name[, name...] in pipeline [parallel n] { ... }.
Definition syntax.h:655
const Word & variable() const
The first name, which is the whole value where there is only one.
Definition syntax.h:668
PipelinePtr pipeline
Definition syntax.h:657
std::vector< Word > variables
Definition syntax.h:656
int parallel
Definition syntax.h:658
std::vector< NodePtr > body
Definition syntax.h:659
std::vector< Word > after
What has to have finished before the loop starts.
Definition syntax.h:665
header "x-name" [as alias] [default value].
Definition syntax.h:747
Word alias
Definition syntax.h:749
std::string name
Definition syntax.h:748
Constant default_value
Definition syntax.h:750
bool has_default
Definition syntax.h:751
std::string description
Definition syntax.h:752
if expr { ... } else { ... }.
Definition syntax.h:704
NodePtr condition
Definition syntax.h:705
std::vector< NodePtr > else_body
Definition syntax.h:707
std::vector< NodePtr > then_body
Definition syntax.h:706
base[i] – an element of a list, or a key of an object.
Definition syntax.h:311
NodePtr base
Definition syntax.h:312
NodePtr index
Definition syntax.h:313
it – the value a where/map/group stage is looking at.
Definition syntax.h:288
let name = pipeline – one value, read from a stream and given a name.
Definition syntax.h:509
PipelinePtr pipeline
Definition syntax.h:518
const Word & name() const
The first name, which is the whole value where there is only one.
Definition syntax.h:521
std::vector< Word > names
One name is the value; several take it apart – let name, age = user by field, let first,...
Definition syntax.h:517
[a, ...rest, c]. An item may be a [Spread].
Definition syntax.h:273
std::vector< NodePtr > items
Definition syntax.h:274
A number, string, boolean, null or duration written out.
Definition syntax.h:258
Constant value
Definition syntax.h:259
Where a piece of syntax starts, reduced to what every reader of it needs.
Definition syntax.h:49
size_t end
Definition syntax.h:51
int line
Definition syntax.h:52
size_t start
Definition syntax.h:50
int column
Definition syntax.h:53
What a log or logf was written with, wherever it was written.
Definition syntax.h:367
bool has_format
Whether a format was written at all, which tells logf "" from log.
Definition syntax.h:374
std::vector< NodePtr > arguments
What to log, or what fills the format. it is bound inside a stage.
Definition syntax.h:376
Word level
The level as written, or empty for the default.
Definition syntax.h:370
std::string format
logf's format, with escapes resolved. Empty for a log.
Definition syntax.h:372
log [level] [what] / logf [level] "format" [args] – write to the flow's own log.
Definition syntax.h:645
std::vector< Word > after
Definition syntax.h:647
LogTail tail
Definition syntax.h:646
A bare name: a port, a call, a loop variable, a header alias.
Definition syntax.h:300
std::string name
Definition syntax.h:301
node(id) [in map] – a node of this flow's own.
Definition syntax.h:720
Word node_map
Definition syntax.h:722
NodePtr id
Definition syntax.h:721
Gives each construct its kind without every constructor restating it.
Definition syntax.h:215
NodeOf()
Definition syntax.h:218
static constexpr NodeKind kNodeKind
Definition syntax.h:216
Base of every syntax node: what it is, and where it started.
Definition syntax.h:204
virtual ~Node()=default
NodeKind kind
Definition syntax.h:207
Location location
Definition syntax.h:208
nodes name [{ ... }] – declare a temporary node map.
Definition syntax.h:711
bool has_body
Whether a block was written, which is what tells nodes x {} – every call inside it placed in the map ...
Definition syntax.h:716
std::vector< NodePtr > body
Definition syntax.h:713
Word name
Definition syntax.h:712
{ "key": expr, ...rest }.
Definition syntax.h:283
std::vector< std::pair< std::string, NodePtr > > pairs
Definition syntax.h:284
status subject – the status of a call, a node, or a barrier.
Definition syntax.h:442
NodePtr subject
Definition syntax.h:443
pipeline -> target, target – write a stream into one or more nodes.
Definition syntax.h:552
std::vector< NodePtr > targets
Definition syntax.h:554
std::vector< Word > after
Definition syntax.h:555
bool tolerant
try source -> dest: a failure arriving from the source, or refused by the destination,...
Definition syntax.h:565
PipelinePtr pipeline
Definition syntax.h:553
(stream | stage ...) used where a value is expected.
Definition syntax.h:447
PipelinePtr pipeline
Definition syntax.h:448
A source expression and the stages its values pass through.
Definition syntax.h:431
std::vector< StagePtr > stages
Definition syntax.h:433
NodePtr source
Definition syntax.h:432
in/out name: type [stream] [required].
Definition syntax.h:734
Word name
Definition syntax.h:735
bool required
Definition syntax.h:740
std::string description
Definition syntax.h:741
TypeExpression type
Definition syntax.h:737
PortDirection direction
Definition syntax.h:736
bool unary
Whether the port carries one value. Most do, so it is the default.
Definition syntax.h:739
repeat [name = expr] [max n] { ... }.
Definition syntax.h:675
std::vector< Word > after
What has to have finished before the loop starts. See ForEach::after.
Definition syntax.h:688
std::optional< int > max_iterations
max n, where one was written.
Definition syntax.h:685
std::vector< NodePtr > body
Definition syntax.h:686
Word variable
Empty where the repeat carries nothing.
Definition syntax.h:677
NodePtr start
Definition syntax.h:678
The one reference changed by a counted skip.
Definition syntax.h:569
Word call
Definition syntax.h:571
std::vector< Word > outputs
Definition syntax.h:572
PipelinePtr pipeline
Definition syntax.h:570
skip n reference – discard the first n values for every reader.
Definition syntax.h:578
std::optional< long long > count
Definition syntax.h:581
std::vector< SkipTarget > targets
Definition syntax.h:579
std::vector< Word > after
Definition syntax.h:580
...expr – everything expr holds, in the literal being written.
Definition syntax.h:268
NodePtr value
Definition syntax.h:269
One | name arg stage of a pipeline.
Definition syntax.h:385
LogTail log
kLog/kLogFormat: what was written after the stage name.
Definition syntax.h:425
bool descending
kSortKey: whether desc was written.
Definition syntax.h:401
std::string name
Definition syntax.h:386
std::string text
kString/kOptionalString: the text, with escapes resolved.
Definition syntax.h:392
double number
kNumber: the count, and whether it was written as a whole number.
Definition syntax.h:389
bool is_integer
Definition syntax.h:390
vocabulary::StageArgument takes
Definition syntax.h:387
int parallel
parallel n: how many values this stage may be working on at once.
Definition syntax.h:416
NodePtr failures
into ref: where a tolerated failure goes, as a status record.
Definition syntax.h:413
absl::Duration duration
kDuration: how long timeout waits, or pace spaces values out by.
Definition syntax.h:399
bool ordered
Whether the values leave in the order they arrived.
Definition syntax.h:422
NodePtr argument
kExpression/kOptionalExpression: the expression, with it bound.
Definition syntax.h:397
Word carried
Definition syntax.h:406
Constant start
kFold: the literal to start from and the name bound to what the last value produced.
Definition syntax.h:405
bool tolerant
try map ...: a value this stage cannot do is dropped rather than ending the pipeline.
Definition syntax.h:410
The type of a port, or of a value being made one: string, list[a11.NodeFragment], "audio/wav".
Definition syntax.h:126
bool sugared
Whether a list[T] was written T[].
Definition syntax.h:136
bool quoted
Definition syntax.h:130
Location location
Definition syntax.h:127
std::string ToString() const
The type as it would be written, which is what a message quotes.
Definition syntax.cc:109
std::vector< TypeExpression > parameters
Definition syntax.h:129
std::string name
Definition syntax.h:128
Tag{...} or expr as Tag – a value made into a type's value.
Definition syntax.h:340
NodePtr value
Definition syntax.h:342
TypeExpression type
Definition syntax.h:341
not operand.
Definition syntax.h:346
std::string op
Definition syntax.h:347
NodePtr operand
Definition syntax.h:348
until expr / while expr – when a repeat stops.
Definition syntax.h:698
NodePtr condition
Definition syntax.h:699
bool stop_when
Definition syntax.h:700
wait subject – hold until a call, or a node this flow writes, is finished.
Definition syntax.h:593
bool race
Whether the first to finish is enough.
Definition syntax.h:598
std::vector< Word > after
Definition syntax.h:600
std::optional< absl::Duration > timeout
Definition syntax.h:599
std::vector< NodePtr > targets
wait first of a, b -> n: where the winner's number goes.
Definition syntax.h:608
std::vector< NodePtr > subjects
Definition syntax.h:595
NodePtr subject
Definition syntax.h:594
A name as written, and where it was written.
Definition syntax.h:65
Location location
Definition syntax.h:67
bool Empty() const
Definition syntax.h:69
std::string text
Definition syntax.h:66
Several streams read as one: zip(a, b, c), interleave(a, b, c).
Definition syntax.h:334
std::string name
Definition syntax.h:335
std::vector< NodePtr > sources
Definition syntax.h:336