A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
highlight.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_HIGHLIGHT_H_
18#define A11_FLOW_HIGHLIGHT_H_
19
20#include <string_view>
21#include <vector>
22
23#include <absl/types/span.h>
24
25#include "a11/flow/token.h"
26
27namespace a11::flow {
28
92
96 size_t start = 0;
97 size_t end = 0;
98 int line = 1;
99 int column = 1;
100};
101
103std::string_view SemanticKindName(SemanticKind kind);
104
106SemanticKind SemanticKindFromName(std::string_view name);
107
121std::vector<SemanticToken> Highlight(absl::Span<const Token> tokens);
122
134void RefinePorts(std::string_view source, std::vector<SemanticToken>& semantic);
135
136} // namespace a11::flow
137
138#endif // A11_FLOW_HIGHLIGHT_H_
TokenKind kind
Definition format.cc:913
std::string name
The name and its colon, which travel together because they always do.
Definition format.cc:49
Definition boundary.cc:32
SemanticKind
What a token means where it stands, which is what a reader colours by.
Definition highlight.h:37
@ kFlowName
The name a flow declaration gives.
@ kNodeMapName
The name a nodes declaration, or a via, gives a node map.
@ kFlowOperator
->, <-, |: where a stream is going.
@ kOperator
=, ==, <, +, and the rest.
@ kIdentifier
Any other word: a node, a step, a loop variable, a let value.
@ kWordOperator
and, or, not.
@ kDeclarationKeyword
flow, in, out, header, node, nodes, as, default.
@ kMember
What follows a .: a port, a field, a node's id.
@ kModifierKeyword
tee, via, timeout, after, with, id, forward headers.
@ kPortName
A port of the flow: its declaration, and every mention of it.
@ kBad
Something the language has no meaning for.
@ kBuiltin
One of the fixed functions, where it is being called.
@ kStatementKeyword
run, call, try, wait, for, if, fail, and the rest.
@ kActionName
The action a run/call names.
@ kConstant
true, false, null, it.
@ kLogLevel
A log level, as log and logf name one.
@ kStage
A pipeline stage, offered after a |.
@ kStatusCode
A canonical status code, as fail names one.
std::vector< SemanticToken > Highlight(absl::Span< const Token > tokens)
Classify a token stream.
Definition highlight.cc:637
std::string_view SemanticKindName(SemanticKind kind)
The name of a semantic kind in the output formats, in kebab case.
Definition highlight.cc:539
SemanticKind SemanticKindFromName(std::string_view name)
The kind a name refers to, or kIdentifier if it is not one.
Definition highlight.cc:599
void RefinePorts(std::string_view source, std::vector< SemanticToken > &semantic)
Mark the identifiers that are ports of the flow they stand in.
Definition highlight.cc:641
One token, and what it means.
Definition highlight.h:94
SemanticKind kind
Definition highlight.h:95
size_t end
Definition highlight.h:97
int column
Definition highlight.h:99
size_t start
Definition highlight.h:96
int line
Definition highlight.h:98