A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
a11::flow::syntax Namespace Reference

Classes

struct  Abort
 abort node [code] [message] – end a node with a failure. More...
 
struct  Advance
 advance name – rebind a let value to the next value of its stream. More...
 
struct  Attr
 base.name – a call's port, or a key of a value. More...
 
struct  Binary
 left op right for and or == != < <= > >= in + -. More...
 
struct  Bind
 name = ... – a step the rest of the flow can refer to. More...
 
struct  Block
 [try] { ... } – a block of statements that runs as one thing. More...
 
struct  Builtin
 name(arg, ...) – one of the language's fixed functions. More...
 
struct  CallExpression
 run/call action(port: pipeline, ...) and its modifiers. More...
 
struct  CallModifiers
 The tee/via/timeout/after/with/id/forward tail of a call. More...
 
struct  CallStatement
 A call whose outputs nobody names (they are drained for it). More...
 
struct  Cancel
 cancel name – ask a called action to stop, cooperatively. More...
 
struct  Carry
 name <- pipeline – what the next pass of a repeat carries. More...
 
struct  Constant
 A value the language can write out in full: what a literal is, and what folding a literal expression gives. More...
 
struct  Discard
 _ – the destination that keeps nothing. More...
 
struct  Drain
 drain target – hold until a node's writers are done and its buffer has landed. More...
 
struct  DtoDeclaration
 One struct name { ... } declaration: a shape a port may be typed with. More...
 
struct  ErrorNode
 A place the parser wanted a value and did not find one. More...
 
struct  Fail
 fail [code] [message] – end the flow with a status. More...
 
struct  FieldDeclaration
 One name: type [modifiers] ["description"] field of a struct. More...
 
struct  FieldRange
 A bound on a field: 1..200, 1.., ..200. More...
 
struct  FlowDeclaration
 One flow name { ... } declaration, or the one flow { ... } entry point. More...
 
struct  ForEach
 for name[, name...] in pipeline [parallel n] { ... }. More...
 
struct  HeaderDeclaration
 header "x-name" [as alias] [default value]. More...
 
struct  If
 if expr { ... } else { ... }. More...
 
struct  Index
 base[i] – an element of a list, or a key of an object. More...
 
struct  It
 it – the value a where/map/group stage is looking at. More...
 
struct  Let
 let name = pipeline – one value, read from a stream and given a name. More...
 
struct  ListLiteral
 [a, ...rest, c]. An item may be a [Spread]. More...
 
struct  Literal
 A number, string, boolean, null or duration written out. More...
 
struct  Location
 Where a piece of syntax starts, reduced to what every reader of it needs. More...
 
struct  Log
 log [level] [what] / logf [level] "format" [args] – write to the flow's own log. More...
 
struct  LogTail
 What a log or logf was written with, wherever it was written. More...
 
struct  Name
 A bare name: a port, a call, a loop variable, a header alias. More...
 
struct  Node
 Base of every syntax node: what it is, and where it started. More...
 
struct  NodeExpression
 node(id) [in map] – a node of this flow's own. More...
 
struct  NodeOf
 Gives each construct its kind without every constructor restating it. More...
 
struct  Nodes
 nodes name [{ ... }] – declare a temporary node map. More...
 
struct  ObjectLiteral
 { "key": expr, ...rest }. More...
 
struct  Outcome
 status subject – the status of a call, a node, or a barrier. More...
 
struct  Pipe
 pipeline -> target, target – write a stream into one or more nodes. More...
 
struct  Pipeline
 A source expression and the stages its values pass through. More...
 
struct  PipelineValue
 (stream | stage ...) used where a value is expected. More...
 
struct  PortDeclaration
 in/out name: type [stream] [required]. More...
 
struct  Repeat
 repeat [name = expr] [max n] { ... }. More...
 
struct  Skip
 skip n reference – discard the first n values for every reader. More...
 
struct  SkipTarget
 The one reference changed by a counted skip. More...
 
struct  Spread
 ...expr – everything expr holds, in the literal being written. More...
 
struct  Stage
 One | name arg stage of a pipeline. More...
 
struct  TypedValue
 Tag{...} or expr as Tag – a value made into a type's value. More...
 
struct  TypeExpression
 The type of a port, or of a value being made one: string, list[a11.NodeFragment], "audio/wav". More...
 
struct  Unary
 not operand. More...
 
struct  Until
 until expr / while expr – when a repeat stops. More...
 
struct  Wait
 wait subject – hold until a call, or a node this flow writes, is finished. More...
 
struct  Word
 A name as written, and where it was written. More...
 
struct  Zip
 Several streams read as one: zip(a, b, c), interleave(a, b, c). More...
 

Typedefs

using NodePtr = std::unique_ptr< Node >
 
using StagePtr = std::unique_ptr< Stage >
 
using PipelinePtr = std::unique_ptr< Pipeline >
 
using CallModifiersPtr = std::unique_ptr< CallModifiers >
 
using CallExpressionPtr = std::unique_ptr< CallExpression >
 
using PortDeclarationPtr = std::unique_ptr< PortDeclaration >
 
using HeaderDeclarationPtr = std::unique_ptr< HeaderDeclaration >
 
using FlowDeclarationPtr = std::unique_ptr< FlowDeclaration >
 
using FieldDeclarationPtr = std::unique_ptr< FieldDeclaration >
 
using DtoDeclarationPtr = std::unique_ptr< DtoDeclaration >
 

Enumerations

enum class  NodeKind {
  kError , kLiteral , kListLiteral , kObjectLiteral ,
  kSpread , kIt , kDiscard , kName ,
  kAttr , kIndex , kBuiltin , kZip ,
  kTypedValue , kUnary , kBinary , kStage ,
  kPipeline , kOutcome , kPipelineValue , kCallModifiers ,
  kCallExpression , kBind , kLet , kAdvance ,
  kBlock , kCallStatement , kPipe , kSkip ,
  kWait , kDrain , kCancel , kAbort ,
  kFail , kLog , kForEach , kRepeat ,
  kCarry , kUntil , kIf , kNodes ,
  kNodeExpression , kPortDeclaration , kHeaderDeclaration , kFlowDeclaration ,
  kFieldDeclaration , kDtoDeclaration
}
 What a node is. One per construct, mirroring a11/flow/syntax.py. More...
 
enum class  PortDirection { kInput , kOutput }
 Which side of the descriptor a port lands on, spelled as the plan spells it. More...
 

Functions

Location LocationOf (const Token &token)
 The location a token occupies.
 
std::string_view ConstantKindName (Constant::Kind kind)
 The spelling of a constant's kind in the output formats.
 
std::string_view NodeKindName (NodeKind kind)
 The name of a node kind in the output formats, in kebab case.
 
bool IsAnyOf (const Node *node, std::initializer_list< NodeKind > kinds)
 Whether a node is one of the kinds given.
 
std::string_view PortDirectionName (PortDirection direction)
 "inputs" or "outputs".
 
std::optional< Constant > ConstantValue (const Node *node)
 The constant node folds to, or nullopt where it is not one all the way down.
 
void VisitChildren (const Node &node, const std::function< void(const Node &)> &visit)
 Every node node directly holds, in the order they were written.
 
void VisitSubtree (const Node &node, const std::function< void(const Node &)> &visit)
 Every node of the subtree rooted at node, node itself included.
 
std::optional< std::string > DottedName (const Node *node)
 a11.sdk.AudioBuffer for a chain of plain names, or nullopt.
 
template<typename T >
const T * As (const Node *node)
 node as a T, or nullptr if it is something else.
 
template<typename T >
T * As (Node *node)
 

Typedef Documentation

◆ CallExpressionPtr

using a11::flow::syntax::CallExpressionPtr = typedef std::unique_ptr<CallExpression>

◆ CallModifiersPtr

using a11::flow::syntax::CallModifiersPtr = typedef std::unique_ptr<CallModifiers>

◆ DtoDeclarationPtr

using a11::flow::syntax::DtoDeclarationPtr = typedef std::unique_ptr<DtoDeclaration>

◆ FieldDeclarationPtr

using a11::flow::syntax::FieldDeclarationPtr = typedef std::unique_ptr<FieldDeclaration>

◆ FlowDeclarationPtr

using a11::flow::syntax::FlowDeclarationPtr = typedef std::unique_ptr<FlowDeclaration>

◆ HeaderDeclarationPtr

◆ NodePtr

using a11::flow::syntax::NodePtr = typedef std::unique_ptr<Node>

◆ PipelinePtr

using a11::flow::syntax::PipelinePtr = typedef std::unique_ptr<Pipeline>

◆ PortDeclarationPtr

using a11::flow::syntax::PortDeclarationPtr = typedef std::unique_ptr<PortDeclaration>

◆ StagePtr

using a11::flow::syntax::StagePtr = typedef std::unique_ptr<Stage>

Enumeration Type Documentation

◆ NodeKind

enum class a11::flow::syntax::NodeKind
strong

What a node is. One per construct, mirroring a11/flow/syntax.py.

Enumerator
kError 

Something the parser could not read.

Carried so the tree keeps its shape around a mistake: a statement with a broken argument is still a statement, and everything after it is still worth checking.

kLiteral 
kListLiteral 
kObjectLiteral 
kSpread 
kIt 
kDiscard 
kName 
kAttr 
kIndex 
kBuiltin 
kZip 
kTypedValue 
kUnary 
kBinary 
kStage 
kPipeline 
kOutcome 
kPipelineValue 
kCallModifiers 
kCallExpression 
kBind 
kLet 
kAdvance 
kBlock 
kCallStatement 
kPipe 
kSkip 
kWait 
kDrain 
kCancel 
kAbort 
kFail 
kLog 
kForEach 
kRepeat 
kCarry 
kUntil 
kIf 
kNodes 
kNodeExpression 
kPortDeclaration 
kHeaderDeclaration 
kFlowDeclaration 
kFieldDeclaration 
kDtoDeclaration 

◆ PortDirection

Which side of the descriptor a port lands on, spelled as the plan spells it.

Enumerator
kInput 
kOutput 

Function Documentation

◆ As() [1/2]

template<typename T >
const T * a11::flow::syntax::As ( const Node *  node)

node as a T, or nullptr if it is something else.

The one way to go from a node to a construct: it checks the kind, so a mistaken assumption is a null rather than a misread object.

◆ As() [2/2]

template<typename T >
T * a11::flow::syntax::As ( Node *  node)

◆ ConstantKindName()

std::string_view a11::flow::syntax::ConstantKindName ( Constant::Kind  kind)

The spelling of a constant's kind in the output formats.

◆ ConstantValue()

std::optional< Constant > a11::flow::syntax::ConstantValue ( const Node *  node)

The constant node folds to, or nullopt where it is not one all the way down.

A literal, and a list or object of literals; anything that has to be read at run time is not a constant. This is what the grammar's constant positions – a header's default – are checked with.

◆ DottedName()

std::optional< std::string > a11::flow::syntax::DottedName ( const Node *  node)

a11.sdk.AudioBuffer for a chain of plain names, or nullopt.

A tag is the only thing on the left of a { that means a type, and it arrives as the same Name/Attr chain any other dotted reference does.

◆ IsAnyOf()

bool a11::flow::syntax::IsAnyOf ( const Node *  node,
std::initializer_list< NodeKind >  kinds 
)

Whether a node is one of the kinds given.

◆ LocationOf()

Location a11::flow::syntax::LocationOf ( const Token &  token)

The location a token occupies.

◆ NodeKindName()

std::string_view a11::flow::syntax::NodeKindName ( NodeKind  kind)

The name of a node kind in the output formats, in kebab case.

◆ PortDirectionName()

std::string_view a11::flow::syntax::PortDirectionName ( PortDirection  direction)

"inputs" or "outputs".

◆ VisitChildren()

void a11::flow::syntax::VisitChildren ( const Node &  node,
const std::function< void(const Node &)> &  visit 
)

Every node node directly holds, in the order they were written.

One place that knows the shape of the tree, so a pass that only cares about some node kind – which types a body names, where a symbol is declared – says so and lets this find them, rather than restating the grammar. A pass that needs to treat each kind differently still switches on the kind; this is for the ones that do not.

Only the tree: a [TypeExpression] is a value on a node rather than a node, and is reached through the node that holds it.

◆ VisitSubtree()

void a11::flow::syntax::VisitSubtree ( const Node &  node,
const std::function< void(const Node &)> &  visit 
)

Every node of the subtree rooted at node, node itself included.

Iterative, with the work list on the heap. A pass that walked the tree by calling itself from a VisitChildren callback would put the document's nesting on the call stack, and A11's work runs on pooled fibers whose stacks are fixed and small – so the tree's shape must not decide how much stack a pass needs. The parser bounds nesting as well (see kMaxNesting there); this is the other half, and the one that does not depend on where the tree came from.

Order is unspecified beyond "parents before children": use VisitChildren directly if a pass needs source order.