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/status/statusor.h>
30#include <absl/time/time.h>
31
32#include "a11/flow/token.h"
33#include "a11/flow/vocabulary.h"
34
35namespace a11::flow::syntax {
36
39struct Location {
40 size_t start = 0;
41 size_t end = 0;
42 int line = 1;
43 int column = 1;
44};
45
47Location LocationOf(const Token& token);
48
50struct Node;
51
52struct Word {
53 std::string text;
55 std::shared_ptr<Node> expression = {};
56
57 [[nodiscard]] bool Empty() const { return text.empty(); }
58};
59
62struct Constant {
63 enum class Kind {
64 kNull,
65 kBool,
67 kDouble,
68 kString,
70 kList,
71 kObject,
72 };
73
75 bool boolean = false;
76 long long integer = 0;
77 double number = 0.0;
78 std::string text;
79 absl::Duration duration;
80 std::vector<Constant> items;
81 std::vector<std::pair<std::string, Constant>> pairs;
82
83 static Constant Null() { return {}; }
84
85 static Constant Bool(bool value);
86 static Constant Integer(long long value);
87 static Constant Double(double value);
88 static Constant String(std::string value);
89 static Constant Duration(absl::Duration value);
90
92 [[nodiscard]] double AsDouble() const;
93};
94
96std::string_view ConstantKindName(Constant::Kind kind);
97
100std::string SourceTypeName(std::string_view name);
101std::string SourceFunctionName(std::string_view name);
102std::string RuntimeActionName(std::string_view name);
103std::string ActionSource(std::string_view name);
104
107 std::string name;
108 std::vector<TypeExpression> parameters = {};
109 bool quoted = false;
111 bool sugared = false;
112
114 [[nodiscard]] std::string ToString() const;
115
117 absl::StatusOr<std::string> ToSource() const;
118};
119
121enum class NodeKind {
123 kError,
124
125 kLiteral,
128 kSpread,
129 kIt,
130 kDiscard,
131 kName,
132 kAttr,
133 kIndex,
134 kBuiltin,
135 kZip,
137 kUnary,
138 kBinary,
139
140 kStage,
141 kPipeline,
142 kOutcome,
143 kActionId,
145
148
149 kBind,
150 kBlock,
152 kPipe,
153 kSkip,
154 kWait,
155 kClose,
156 kCancel,
157 kAbort,
158 kFail,
159 kLog,
160 kForEach,
161 kRepeat,
162 kCarry,
163 kUntil,
164 kIf,
165 kNodes,
167
173};
174
176std::string_view NodeKindName(NodeKind kind);
177
179struct Node {
180 virtual ~Node() = default;
181
186 std::vector<Location> groups;
187};
188
189using NodePtr = std::unique_ptr<Node>;
190
192template <NodeKind K>
193struct NodeOf : Node {
194 static constexpr NodeKind kNodeKind = K;
195
196 NodeOf() { kind = K; }
197};
198
200template <typename T>
201const T* As(const Node* node) {
202 if (node == nullptr || node->kind != T::kNodeKind) {
203 {
204 return nullptr;
205 }
206 }
207 return static_cast<const T*>(node);
208}
209
210template <typename T>
212 if (node == nullptr || node->kind != T::kNodeKind) {
213 {
214 return nullptr;
215 }
216 }
217 return static_cast<T*>(node);
218}
219
221bool IsAnyOf(const Node* node, std::initializer_list<NodeKind> kinds);
222
223// --- Expressions -------------------------------------------------------------
224
226struct ErrorNode : NodeOf<NodeKind::kError> {
228 std::string expected;
229};
230
232struct Literal : NodeOf<NodeKind::kLiteral> {
234};
235
237struct Spread : NodeOf<NodeKind::kSpread> {
239};
240
242struct ListLiteral : NodeOf<NodeKind::kListLiteral> {
243 std::vector<NodePtr> items;
244};
245
248struct ObjectLiteral : NodeOf<NodeKind::kObjectLiteral> {
249 std::vector<std::pair<std::string, NodePtr>> pairs;
250};
251
253struct It : NodeOf<NodeKind::kIt> {};
254
256struct Discard : NodeOf<NodeKind::kDiscard> {};
257
259struct Name : NodeOf<NodeKind::kName> {
260 std::string name;
261};
262
264struct Attr : NodeOf<NodeKind::kAttr> {
266 std::string name;
267 bool optional = false;
268};
269
271struct Index : NodeOf<NodeKind::kIndex> {
274 bool optional = false;
275};
276
278struct Builtin : NodeOf<NodeKind::kBuiltin> {
279 std::string name;
280 std::vector<NodePtr> args;
281};
282
285struct Zip : NodeOf<NodeKind::kZip> {
286 std::string name = "zip";
287 std::vector<NodePtr> sources;
288};
289
291struct TypedValue : NodeOf<NodeKind::kTypedValue> {
294};
295
297struct Unary : NodeOf<NodeKind::kUnary> {
298 std::string op;
300};
301
303struct Binary : NodeOf<NodeKind::kBinary> {
304 std::string op;
307};
308
309// --- Pipelines ---------------------------------------------------------------
310
313struct LogTail {
318 std::string format;
320 bool has_format = false;
322 std::vector<NodePtr> arguments;
323};
324
371
372using StagePtr = std::unique_ptr<Stage>;
373
375struct Pipeline : NodeOf<NodeKind::kPipeline> {
377 std::vector<StagePtr> stages;
378};
379
380using PipelinePtr = std::unique_ptr<Pipeline>;
381
383struct Outcome : NodeOf<NodeKind::kOutcome> {
385};
386
388struct ActionId : NodeOf<NodeKind::kActionId> {
390};
391
393struct PipelineValue : NodeOf<NodeKind::kPipelineValue> {
396 bool take = false;
397 bool optional = false;
398};
399
400// --- Calls -------------------------------------------------------------------
401
403struct CallModifiers : NodeOf<NodeKind::kCallModifiers> {
405 std::vector<Location> clause_locations;
406 bool tee = false;
408 std::optional<absl::Duration> timeout;
411 std::vector<Word> after;
412 std::vector<std::pair<std::string, NodePtr>> headers;
416 std::vector<std::string> forward;
417};
418
419using CallModifiersPtr = std::unique_ptr<CallModifiers>;
420
422struct CallExpression : NodeOf<NodeKind::kCallExpression> {
428
429 std::string action;
433 std::string mode;
434 std::vector<Argument> args;
436 bool tolerant = false;
437
440 std::string member;
442 };
443
444 bool invalid_target = false;
445 std::vector<TargetSuffix> target_suffixes;
446};
447
448using CallExpressionPtr = std::unique_ptr<CallExpression>;
449
450// --- Statements --------------------------------------------------------------
451
453struct Bind : NodeOf<NodeKind::kBind> {
455 std::vector<Word> names;
457 std::optional<TypeExpression> type;
458};
459
462struct Block : NodeOf<NodeKind::kBlock> {
463 bool tolerant = false;
464 std::vector<Word> after;
465 std::vector<NodePtr> body;
466};
467
469struct CallStatement : NodeOf<NodeKind::kCallStatement> {
471};
472
474struct Pipe : NodeOf<NodeKind::kPipe> {
476 std::vector<NodePtr> targets;
477 std::vector<Word> after;
479 bool tolerant = false;
480};
481
486 std::vector<Word> outputs;
487};
488
492struct Skip : NodeOf<NodeKind::kSkip> {
493 std::vector<SkipTarget> targets;
494 std::vector<Word> after;
495 std::optional<long long> count;
496};
497
500struct Wait : NodeOf<NodeKind::kWait> {
501 bool scope_barrier = false;
503 std::vector<NodePtr> subjects;
505 bool race = false;
506 std::optional<absl::Duration> timeout;
509 std::vector<Word> after;
511 std::vector<NodePtr> targets;
512};
513
516struct Close : NodeOf<NodeKind::kClose> {
518 std::vector<Word> after;
519};
520
522struct Cancel : NodeOf<NodeKind::kCancel> {
524 std::vector<Word> after;
525};
526
528struct Abort : NodeOf<NodeKind::kAbort> {
532 std::vector<Word> after;
533};
534
536struct Fail : NodeOf<NodeKind::kFail> {
539 std::vector<Word> after;
540};
541
544struct Log : NodeOf<NodeKind::kLog> {
546 std::vector<Word> after;
547};
548
553struct ForEach : NodeOf<NodeKind::kForEach> {
554 std::vector<Word> variables;
556 int parallel = 1;
559 std::vector<NodePtr> body;
563 std::vector<Word> after;
564
566 [[nodiscard]] const Word& variable() const {
567 static const Word kNone;
568 return variables.empty() ? kNone : variables.front();
569 }
570};
571
573struct Repeat : NodeOf<NodeKind::kRepeat> {
578 std::optional<int> max_iterations;
579 std::vector<NodePtr> body;
583 std::vector<Word> after;
584};
585
587struct Carry : NodeOf<NodeKind::kCarry> {
590};
591
593struct Until : NodeOf<NodeKind::kUntil> {
595 bool stop_when = true;
596};
597
599struct If : NodeOf<NodeKind::kIf> {
603 std::vector<NodePtr> then_body;
604 std::vector<NodePtr> else_body;
605};
606
608struct Nodes : NodeOf<NodeKind::kNodes> {
610 std::vector<NodePtr> body;
612 bool has_body = false;
613};
614
616struct NodeExpression : NodeOf<NodeKind::kNodeExpression> {
619};
620
621// --- Declarations ------------------------------------------------------------
622
625
628
630struct PortDeclaration : NodeOf<NodeKind::kPortDeclaration> {
635 bool unary = true;
636 bool required = false;
637 std::string description;
638};
639
640using PortDeclarationPtr = std::unique_ptr<PortDeclaration>;
641
643struct HeaderDeclaration : NodeOf<NodeKind::kHeaderDeclaration> {
644 std::string name;
647 bool has_default = false;
648 std::string description;
649};
650
651using HeaderDeclarationPtr = std::unique_ptr<HeaderDeclaration>;
652
658
660struct Import {
661 std::string source;
662 std::string scope;
663 bool namespace_source = false;
664 bool explicit_alias = false;
666 bool exported = false;
667 bool selective = false;
668 size_t selection_start = 0;
669 std::vector<ImportedSymbol> symbols;
673};
674
682
690
691struct DtoDeclaration;
692
694struct FlowDeclaration : NodeOf<NodeKind::kFlowDeclaration> {
696 std::string binding_name;
697 std::string module;
698 std::string scope;
701 bool entry = false;
702 bool interface_only = false;
703 bool imported = false;
704 bool exported = false;
705 bool registerable = true;
706 std::string description;
707 std::vector<PortDeclarationPtr> ports;
708 std::vector<HeaderDeclarationPtr> headers;
709 std::vector<Import> imports;
710 std::vector<std::unique_ptr<FlowDeclaration>> declarations;
711 std::vector<std::unique_ptr<DtoDeclaration>> structs;
712 std::vector<NodePtr> body;
713};
714
715using FlowDeclarationPtr = std::unique_ptr<FlowDeclaration>;
716
720 bool has_minimum = false;
721 bool has_maximum = false;
724
725 [[nodiscard]] bool Empty() const { return !has_minimum && !has_maximum; }
726};
727
729struct FieldDeclaration : NodeOf<NodeKind::kFieldDeclaration> {
733 bool required = false;
735 bool unique = false;
739 std::string pattern;
740 bool has_pattern = false;
742 std::vector<Constant> enumeration;
743 bool has_enumeration = false;
746 bool has_default = false;
747 std::string description;
748};
749
750using FieldDeclarationPtr = std::unique_ptr<FieldDeclaration>;
751
755struct DtoDeclaration : NodeOf<NodeKind::kDtoDeclaration> {
757 std::string module;
758 std::string scope;
759 bool exported = false;
760 std::string description;
761 std::vector<FieldDeclarationPtr> fields;
762};
763
764using DtoDeclarationPtr = std::unique_ptr<DtoDeclaration>;
765
768
770std::optional<Constant> ConstantValue(const Node* node);
771
774void VisitChildren(const Node& node,
775 const std::function<void(const Node&)>& visit);
776
779void VisitSubtree(const Node& node,
780 const std::function<void(const Node&)>& visit);
781
783void VisitMutableSubtree(Node& node, const std::function<void(Node&)>& visit);
784
786std::optional<std::string> DottedName(const Node* node);
787
788} // namespace a11::flow::syntax
789
790#endif // A11_FLOW_SYNTAX_H_
std::string value
Definition discover.cc:100
TokenKind kind
Definition format.cc:1372
std::string name
The declaration name and its colon.
Definition format.cc:50
std::string direction
in, out or header as written; empty for a shape field.
Definition format.cc:48
constexpr size_t kNone
Sentinel for an absent graph ID.
Definition graph.h:45
Definition syntax.cc:32
Location LocationOf(const Token &token)
The location a token occupies.
Definition syntax.cc:34
std::string_view PortDirectionName(PortDirection direction)
"inputs" or "outputs".
Definition syntax.cc:311
std::unique_ptr< DtoDeclaration > DtoDeclarationPtr
Definition syntax.h:764
std::optional< Constant > ConstantValue(const Node *node)
Folds a literal expression, or returns nullopt for runtime values.
Definition syntax.cc:377
std::string SourceTypeName(std::string_view name)
A port or cast type, such as string, list[a11.NodeFragment], or "audio/wav".
Definition syntax.cc:141
std::string SourceFunctionName(std::string_view name)
Definition syntax.cc:133
void VisitSubtree(const Node &node, const std::function< void(const Node &)> &visit)
Visits a subtree iteratively, starting with node.
Definition syntax.cc:734
std::unique_ptr< Pipeline > PipelinePtr
Definition syntax.h:380
bool IsPureLiteralExpression(const Node &node)
Whether a bounded expression contains only literal data and pure operators.
Definition syntax.cc:333
std::unique_ptr< FlowDeclaration > FlowDeclarationPtr
Definition syntax.h:715
void VisitChildren(const Node &node, const std::function< void(const Node &)> &visit)
Visits direct child nodes in source order.
Definition syntax.cc:432
std::unique_ptr< CallModifiers > CallModifiersPtr
Definition syntax.h:419
bool IsAnyOf(const Node *node, std::initializer_list< NodeKind > kinds)
Whether a node is one of the kinds given.
Definition syntax.cc:304
std::unique_ptr< HeaderDeclaration > HeaderDeclarationPtr
Definition syntax.h:651
PortDirection
Which side of the descriptor a port lands on, spelled as the plan spells it.
Definition syntax.h:624
std::unique_ptr< PortDeclaration > PortDeclarationPtr
Definition syntax.h:640
std::unique_ptr< Stage > StagePtr
Definition syntax.h:372
std::optional< std::string > DottedName(const Node *node)
Returns a dotted Name/Attr chain, or nullopt for other nodes.
Definition syntax.cc:746
std::string_view ConstantKindName(Constant::Kind kind)
The spelling of a constant's kind in the output formats.
Definition syntax.cc:92
void VisitMutableSubtree(Node &node, const std::function< void(Node &)> &visit)
Walk an exclusively owned syntax tree for native linking/editing.
Definition syntax.cc:764
std::unique_ptr< CallExpression > CallExpressionPtr
Definition syntax.h:448
std::unique_ptr< Node > NodePtr
Definition syntax.h:189
std::unique_ptr< FieldDeclaration > FieldDeclarationPtr
Definition syntax.h:750
const T * As(const Node *node)
Returns node as T, or null when its kind differs.
Definition syntax.h:201
NodeKind
Syntax node kinds, one per construct.
Definition syntax.h:121
@ kError
A syntax error retained in the recovering parser's tree.
std::string_view NodeKindName(NodeKind kind)
The name of a node kind in the output formats, in kebab case.
Definition syntax.cc:208
std::string ActionSource(std::string_view name)
Definition syntax.cc:118
std::string RuntimeActionName(std::string_view name)
Definition syntax.cc:114
StageArgument
What a stage takes after its name.
Definition vocabulary.h:43
@ kNone
Nothing: | collect, | count.
absl::Duration Duration
A11 duration; an alias of absl::Duration (nanosecond-aware).
Definition time.h:40
graph::RefId node
Graph ref for this result, or [graph::kNone] without a resolved ref.
Definition resolve.cc:809
One token: what it is, where it is, and what it holds.
Definition token.h:104
abort node [code] [message] – end a node with a failure.
Definition syntax.h:528
NodePtr message
Definition syntax.h:531
std::vector< Word > after
Definition syntax.h:532
NodePtr target
Definition syntax.h:529
NodePtr code
Definition syntax.h:530
id subject – the identity assigned to a run or call.
Definition syntax.h:388
NodePtr subject
Definition syntax.h:389
base.name – a call's port, or a key of a value.
Definition syntax.h:264
NodePtr base
Definition syntax.h:265
std::string name
Definition syntax.h:266
bool optional
Definition syntax.h:267
left op right for and or == != < <= > >= in + -.
Definition syntax.h:303
NodePtr left
Definition syntax.h:305
std::string op
Definition syntax.h:304
NodePtr right
Definition syntax.h:306
name = ... – a step the rest of the flow can refer to.
Definition syntax.h:453
Word name
Definition syntax.h:454
std::vector< Word > names
Definition syntax.h:455
std::optional< TypeExpression > type
Definition syntax.h:457
NodePtr value
Definition syntax.h:456
[try] { ... } groups concurrent statements into one outcome.
Definition syntax.h:462
bool tolerant
Definition syntax.h:463
std::vector< Word > after
Definition syntax.h:464
std::vector< NodePtr > body
Definition syntax.h:465
name(arg, ...) – one of the language's fixed functions.
Definition syntax.h:278
std::vector< NodePtr > args
Definition syntax.h:280
std::string name
Definition syntax.h:279
One argument: the port named, where it was named, and what feeds it.
Definition syntax.h:424
PipelinePtr pipeline
Definition syntax.h:426
Location location
Definition syntax.h:439
NodePtr index
Definition syntax.h:441
std::string member
Definition syntax.h:440
run/call action(port: pipeline, ...) and its modifiers.
Definition syntax.h:422
std::string mode
The verb written: "run" for the handler registered here, "call" for the stream this flow is attached ...
Definition syntax.h:433
std::vector< Argument > args
Definition syntax.h:434
Location action_location
Definition syntax.h:430
std::string action
Definition syntax.h:429
bool tolerant
Definition syntax.h:436
CallModifiersPtr modifiers
Definition syntax.h:435
bool invalid_target
Definition syntax.h:444
std::vector< TargetSuffix > target_suffixes
Definition syntax.h:445
The tee/via/timeout/after/with/id/id-into/forward tail.
Definition syntax.h:403
std::vector< Word > after
Definition syntax.h:411
NodePtr id_into
Definition syntax.h:414
std::vector< std::string > forward
Header names, or * patterns, that forward headers names.
Definition syntax.h:416
NodePtr timeout_expression
Definition syntax.h:410
NodePtr deadline
Definition syntax.h:409
bool tee
Definition syntax.h:406
NodePtr action_id
Definition syntax.h:413
Word node_map
Definition syntax.h:407
std::vector< Location > clause_locations
Modifier keyword positions, in source order.
Definition syntax.h:405
std::vector< std::pair< std::string, NodePtr > > headers
Definition syntax.h:412
std::optional< absl::Duration > timeout
Definition syntax.h:408
A call statement whose unnamed outputs are drained.
Definition syntax.h:469
CallExpressionPtr call
Definition syntax.h:470
cancel name – ask a called action to stop, cooperatively.
Definition syntax.h:522
Word name
Definition syntax.h:523
std::vector< Word > after
Definition syntax.h:524
name <- pipeline – what the next pass of a repeat carries.
Definition syntax.h:587
PipelinePtr pipeline
Definition syntax.h:589
Word name
Definition syntax.h:588
close target – hold until a node's writers are done and its buffer has landed.
Definition syntax.h:516
NodePtr target
Definition syntax.h:517
std::vector< Word > after
Definition syntax.h:518
A literal or folded literal expression, including nested lists and objects.
Definition syntax.h:62
std::vector< std::pair< std::string, Constant > > pairs
Definition syntax.h:81
static Constant Null()
Definition syntax.h:83
std::vector< Constant > items
Definition syntax.h:80
Kind
Definition syntax.h:63
double AsDouble() const
The number this holds, whichever way it was written.
Definition syntax.cc:79
static Constant Double(double value)
Definition syntax.cc:58
double number
Definition syntax.h:77
static Constant Bool(bool value)
Definition syntax.cc:43
static Constant String(std::string value)
Definition syntax.cc:65
absl::Duration duration
Definition syntax.h:79
std::string text
Definition syntax.h:78
static Constant Integer(long long value)
Definition syntax.cc:50
Kind kind
Definition syntax.h:74
long long integer
Definition syntax.h:76
_, a pipe destination that discards its input.
Definition syntax.h:256
One struct name { ... } declaration: a shape a port may be typed with.
Definition syntax.h:755
std::vector< FieldDeclarationPtr > fields
Definition syntax.h:761
std::string std::string scope
Definition syntax.h:758
bool exported
Definition syntax.h:759
Word name
Definition syntax.h:756
std::string description
Definition syntax.h:760
A place the parser wanted a value and did not find one.
Definition syntax.h:226
std::string expected
What was expected there, for a formatter deciding to leave it alone.
Definition syntax.h:228
A public alias of an existing namespace member.
Definition syntax.h:684
Word alias
Definition syntax.h:686
Word symbol
Definition syntax.h:685
std::string scope
Definition syntax.h:687
Location extent
Definition syntax.h:688
fail [code] [message] – end the flow with a status.
Definition syntax.h:536
NodePtr message
Definition syntax.h:538
std::vector< Word > after
Definition syntax.h:539
NodePtr code
Definition syntax.h:537
One name: type [modifiers] ["description"] field of a struct.
Definition syntax.h:729
bool unique
unique: no two items of a list are equal.
Definition syntax.h:735
Constant default_value
default ..: what a value that was not given is.
Definition syntax.h:745
bool required
Whether the value must be supplied; optional fields may be absent.
Definition syntax.h:733
bool has_pattern
Definition syntax.h:740
bool has_enumeration
Definition syntax.h:743
std::string pattern
matching "...": the pattern every value has to match, unanchored, as JSONSchema's pattern is.
Definition syntax.h:739
std::string description
Definition syntax.h:747
FieldRange range
Definition syntax.h:736
std::vector< Constant > enumeration
one of [..]: the only values allowed.
Definition syntax.h:742
Word name
Definition syntax.h:730
bool has_default
Definition syntax.h:746
TypeExpression type
Definition syntax.h:731
A field bound such as 1..200, 1.., or ..200.
Definition syntax.h:719
Constant maximum
Definition syntax.h:723
bool Empty() const
Definition syntax.h:725
bool has_minimum
Definition syntax.h:720
bool has_maximum
Definition syntax.h:721
Constant minimum
Definition syntax.h:722
One flow name { ... } declaration, or the one flow { ... } entry point.
Definition syntax.h:694
std::string description
Definition syntax.h:706
std::vector< PortDeclarationPtr > ports
Definition syntax.h:707
std::vector< std::unique_ptr< DtoDeclaration > > structs
Definition syntax.h:711
std::vector< HeaderDeclarationPtr > headers
Definition syntax.h:708
bool interface_only
Definition syntax.h:702
std::vector< NodePtr > body
Definition syntax.h:712
bool exported
Definition syntax.h:704
std::string std::string scope
Definition syntax.h:698
std::vector< Import > imports
Definition syntax.h:709
bool entry
Whether this is the unnamed flow { ... } entry point.
Definition syntax.h:701
bool registerable
Definition syntax.h:705
Word name
Definition syntax.h:695
bool imported
Definition syntax.h:703
std::string binding_name
Definition syntax.h:696
std::vector< std::unique_ptr< FlowDeclaration > > declarations
Definition syntax.h:710
for name[, name...] in pipeline [parallel n] { ... }.
Definition syntax.h:553
const Word & variable() const
The first name, which is the whole value where there is only one.
Definition syntax.h:566
PipelinePtr pipeline
Definition syntax.h:555
NodePtr termination
Optional postcondition, evaluated after a complete pass.
Definition syntax.h:561
std::vector< Word > variables
Definition syntax.h:554
int parallel
Definition syntax.h:556
NodePtr parallel_expression
A nonliteral concurrency count, evaluated once before iteration.
Definition syntax.h:558
std::vector< NodePtr > body
Definition syntax.h:559
std::vector< Word > after
Dependencies that finish before the loop starts.
Definition syntax.h:563
header "x-name" [as alias] [default value].
Definition syntax.h:643
Word alias
Definition syntax.h:645
std::string name
Definition syntax.h:644
Constant default_value
Definition syntax.h:646
bool has_default
Definition syntax.h:647
std::string description
Definition syntax.h:648
if expr { ... } else { ... }.
Definition syntax.h:599
NodePtr condition
Definition syntax.h:602
Location binding_scope
Definition syntax.h:601
std::vector< NodePtr > else_body
Definition syntax.h:604
std::vector< NodePtr > then_body
Definition syntax.h:603
Word binding
Definition syntax.h:600
A source module bound to a namespace or selected local symbols.
Definition syntax.h:660
Location source_location
Definition syntax.h:665
bool explicit_alias
Definition syntax.h:664
bool namespace_source
Definition syntax.h:663
Location extent
Definition syntax.h:672
bool selective
Definition syntax.h:667
std::string source
Definition syntax.h:661
bool exported
Definition syntax.h:666
std::vector< ImportedSymbol > symbols
Definition syntax.h:669
Location location
Definition syntax.h:671
Word alias
Definition syntax.h:670
size_t selection_start
Definition syntax.h:668
std::string scope
Definition syntax.h:662
Definition syntax.h:653
Word name
Definition syntax.h:654
Word alias
Definition syntax.h:655
bool explicit_alias
Definition syntax.h:656
base[i] – an element of a list, or a key of an object.
Definition syntax.h:271
NodePtr base
Definition syntax.h:272
bool optional
Definition syntax.h:274
NodePtr index
Definition syntax.h:273
it – the value a where/map/group stage is looking at.
Definition syntax.h:253
[a, ...rest, c]. An item may be a [Spread].
Definition syntax.h:242
std::vector< NodePtr > items
Definition syntax.h:243
A number, string, boolean, null or duration written out.
Definition syntax.h:232
Constant value
Definition syntax.h:233
The start token's byte span, line, and code-point column.
Definition syntax.h:39
size_t end
Definition syntax.h:41
int line
Definition syntax.h:42
size_t start
Definition syntax.h:40
int column
Definition syntax.h:43
Arguments shared by log and logf statements and stages.
Definition syntax.h:313
bool has_format
Whether a format was written at all, which tells logf "" from log.
Definition syntax.h:320
std::vector< NodePtr > arguments
What to log, or what fills the format. it is bound inside a stage.
Definition syntax.h:322
Word level
The level as written, or empty for the default.
Definition syntax.h:316
std::string format
logf's format, with escapes resolved. Empty for a log.
Definition syntax.h:318
log [level] [what] / logf [level] "format" [args] – write to the flow's own log.
Definition syntax.h:544
std::vector< Word > after
Definition syntax.h:546
LogTail tail
Definition syntax.h:545
A namespace contribution in one source document.
Definition syntax.h:676
bool exported
Definition syntax.h:679
Word name
Definition syntax.h:677
Location extent
Definition syntax.h:680
bool interface_only
Definition syntax.h:678
A bare name: a port, a call, a loop variable, a header alias.
Definition syntax.h:259
std::string name
Definition syntax.h:260
node(id) [in map] – a node of this flow's own.
Definition syntax.h:616
Word node_map
Definition syntax.h:618
NodePtr id
Definition syntax.h:617
Assigns a fixed kind to each syntax node type.
Definition syntax.h:193
NodeOf()
Definition syntax.h:196
static constexpr NodeKind kNodeKind
Definition syntax.h:194
Base of every syntax node: what it is, and where it started.
Definition syntax.h:179
virtual ~Node()=default
NodeKind kind
Definition syntax.h:182
std::vector< Location > groups
Definition syntax.h:186
Location extent
Full source extent and transparent grouping, for native edits.
Definition syntax.h:185
Location location
Definition syntax.h:183
nodes name [{ ... }] – declare a temporary node map.
Definition syntax.h:608
bool has_body
Whether a node-map block was written, including an empty block.
Definition syntax.h:612
std::vector< NodePtr > body
Definition syntax.h:610
Word name
Definition syntax.h:609
{ "key": expr, ...rest }.
Definition syntax.h:248
std::vector< std::pair< std::string, NodePtr > > pairs
Definition syntax.h:249
status subject; reading it waits for the subject to finish.
Definition syntax.h:383
NodePtr subject
Definition syntax.h:384
pipeline -> target, target – write a stream into one or more nodes.
Definition syntax.h:474
std::vector< NodePtr > targets
Definition syntax.h:476
std::vector< Word > after
Definition syntax.h:477
bool tolerant
try source -> dest: capture a source or destination failure as a value.
Definition syntax.h:479
PipelinePtr pipeline
Definition syntax.h:475
(stream | stage ...) used where a value is expected.
Definition syntax.h:393
bool take
Explicit extraction, with absence on EOF only when optional.
Definition syntax.h:396
bool optional
Definition syntax.h:397
PipelinePtr pipeline
Definition syntax.h:394
A source expression and the stages its values pass through.
Definition syntax.h:375
std::vector< StagePtr > stages
Definition syntax.h:377
NodePtr source
Definition syntax.h:376
in/out name: type [stream] [required].
Definition syntax.h:630
Word name
Definition syntax.h:631
bool required
Definition syntax.h:636
std::string description
Definition syntax.h:637
TypeExpression type
Definition syntax.h:633
PortDirection direction
Definition syntax.h:632
bool unary
Whether the port carries one value. Most do, so it is the default.
Definition syntax.h:635
repeat [name = expr] [max n] { ... }.
Definition syntax.h:573
std::vector< Word > after
What has to have finished before the loop starts. See ForEach::after.
Definition syntax.h:583
std::optional< int > max_iterations
Optional max n bound; absent for a condition-only loop.
Definition syntax.h:578
std::vector< NodePtr > body
Definition syntax.h:579
NodePtr termination
Optional postcondition, resolved in the iteration scope.
Definition syntax.h:581
Word variable
Empty where the repeat carries nothing.
Definition syntax.h:575
NodePtr start
Definition syntax.h:576
The one reference changed by a counted skip.
Definition syntax.h:483
Word call
Definition syntax.h:485
std::vector< Word > outputs
Definition syntax.h:486
PipelinePtr pipeline
Definition syntax.h:484
skip n reference – discard the first n values for every reader.
Definition syntax.h:492
std::optional< long long > count
Definition syntax.h:495
std::vector< SkipTarget > targets
Definition syntax.h:493
std::vector< Word > after
Definition syntax.h:494
...expr in a list or object literal.
Definition syntax.h:237
NodePtr value
Definition syntax.h:238
One | name arg stage of a pipeline.
Definition syntax.h:327
LogTail log
kLog/kLogFormat: what was written after the stage name.
Definition syntax.h:369
bool descending
kSortKey: whether desc was written.
Definition syntax.h:346
std::string name
Definition syntax.h:328
NodePtr parallel_expression
A nonliteral concurrency count, evaluated once when the stage starts.
Definition syntax.h:359
std::string text
kString/kOptionalString: the text, with escapes resolved.
Definition syntax.h:336
double number
kNumber: a constant count, when the argument folds to an integer.
Definition syntax.h:332
bool is_integer
Definition syntax.h:334
NodePtr context_after
Definition syntax.h:362
std::optional< TypeExpression > type
Definition syntax.h:330
vocabulary::StageArgument takes
Definition syntax.h:329
NodePtr context_base
Definition syntax.h:364
int parallel
parallel n: maximum concurrent values; one is the default.
Definition syntax.h:357
long long integer
Definition syntax.h:333
bool context_numbered
Definition syntax.h:363
NodePtr failures
failures into ref: where a tolerated failure goes.
Definition syntax.h:355
absl::Duration duration
kDuration: how long timeout waits, or pace spaces values out by.
Definition syntax.h:344
bool ordered
Whether output preserves input order; unordered clears this flag.
Definition syntax.h:366
NodePtr argument
kExpression/kOptionalExpression: the expression, with it bound.
Definition syntax.h:342
Word carried
Definition syntax.h:349
Constant start
kFold: the initial literal and carried name.
Definition syntax.h:348
bool tolerant
try map ...: tolerate an item's evaluation failure; context may retain the item.
Definition syntax.h:352
NodePtr context_before
context: surrounding item counts, evaluated once outside it.
Definition syntax.h:361
Definition syntax.h:105
bool sugared
Whether list[T] used the T[] spelling, retained by the formatter.
Definition syntax.h:111
bool quoted
Definition syntax.h:109
Location location
Definition syntax.h:106
std::string ToString() const
The type as it would be written, which is what a message quotes.
Definition syntax.cc:160
std::vector< TypeExpression > parameters
Definition syntax.h:108
absl::StatusOr< std::string > ToSource() const
Emit a bounded type expression, preserving quoted representations.
Definition syntax.cc:175
std::string name
Definition syntax.h:107
Tag{...} or expr as Tag – a value made into a type's value.
Definition syntax.h:291
NodePtr value
Definition syntax.h:293
TypeExpression type
Definition syntax.h:292
not operand.
Definition syntax.h:297
std::string op
Definition syntax.h:298
NodePtr operand
Definition syntax.h:299
until expr / while expr – when a repeat stops.
Definition syntax.h:593
NodePtr condition
Definition syntax.h:594
bool stop_when
Definition syntax.h:595
Wait for one subject, the first of several, or all of several.
Definition syntax.h:500
bool race
Whether the first plural subject to finish satisfies the wait.
Definition syntax.h:505
bool scope_barrier
Definition syntax.h:501
std::vector< Word > after
Definition syntax.h:509
std::optional< absl::Duration > timeout
Definition syntax.h:506
NodePtr deadline
Definition syntax.h:507
std::vector< NodePtr > targets
Destinations for the winning subject's zero-based index.
Definition syntax.h:511
NodePtr timeout_expression
Definition syntax.h:508
std::vector< NodePtr > subjects
Definition syntax.h:503
NodePtr subject
Definition syntax.h:502
Definition syntax.h:52
Location location
Definition syntax.h:54
bool Empty() const
Definition syntax.h:57
std::shared_ptr< Node > expression
Definition syntax.h:55
std::string text
Definition syntax.h:53
zip or interleave over stream sources.
Definition syntax.h:285
std::string name
Definition syntax.h:286
std::vector< NodePtr > sources
Definition syntax.h:287