A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
parser.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_PARSER_H_
18#define A11_FLOW_PARSER_H_
19
20#include <string_view>
21#include <vector>
22
23#include <absl/base/nullability.h>
24#include <absl/types/span.h>
25
26#include "a11/flow/diagnostic.h"
27#include "a11/flow/syntax.h"
28
29namespace a11::flow {
30
33 std::vector<syntax::FlowDeclarationPtr> flows;
40 std::vector<syntax::DtoDeclarationPtr> dtos;
41 std::vector<Diagnostic> diagnostics;
42
50 std::vector<size_t> value_braces;
51
57 std::vector<size_t> tagged_braces;
58
59 [[nodiscard]] bool HasErrors() const;
60
64 [[nodiscard]] const Diagnostic* absl_nullable FirstError() const;
65};
66
78ParseResult Parse(std::string_view source);
79
85ParseResult ParseTokens(std::string_view source, absl::Span<const Token> tokens,
86 std::vector<Diagnostic> diagnostics);
87
88} // namespace a11::flow
89
90#endif // A11_FLOW_PARSER_H_
Definition boundary.cc:32
ParseResult Parse(std::string_view source)
Parse Flow source.
Definition parser.cc:2628
ParseResult ParseTokens(std::string_view source, absl::Span< const Token > tokens, std::vector< Diagnostic > diagnostics)
Parse an already-lexed stream, sharing the lex diagnostics.
Definition parser.cc:2633
One problem found in a flow.
Definition diagnostic.h:108
The flows a file declares, and everything wrong with it.
Definition parser.h:32
std::vector< size_t > value_braces
The offset of every { that opens a value rather than a block, sorted.
Definition parser.h:50
const Diagnostic *absl_nullable FirstError() const
The first error in source order, or nullptr.
Definition parser.cc:2624
std::vector< syntax::DtoDeclarationPtr > dtos
The shapes the file declares, in declaration order.
Definition parser.h:40
std::vector< syntax::FlowDeclarationPtr > flows
Definition parser.h:33
std::vector< size_t > tagged_braces
The offsets of the value braces that follow a type tag, sorted.
Definition parser.h:57
bool HasErrors() const
Definition parser.cc:2620
std::vector< Diagnostic > diagnostics
Definition parser.h:41