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/status/statusor.h>
25#include <absl/types/span.h>
26
27#include "a11/flow/diagnostic.h"
28#include "a11/flow/limits.h"
29#include "a11/flow/syntax.h"
30
31namespace a11::flow {
32
35 std::vector<syntax::ModuleDeclaration> modules;
36 std::vector<syntax::ExportDeclaration> exports;
37 std::vector<syntax::Import> imports;
38 std::vector<syntax::FlowDeclarationPtr> flows;
40 std::vector<syntax::DtoDeclarationPtr> dtos;
41 std::vector<Diagnostic> diagnostics;
42
44 std::vector<size_t> value_braces;
45
47 std::vector<size_t> tagged_braces;
48
49 [[nodiscard]] bool HasErrors() const;
50
54 [[nodiscard]] const Diagnostic* absl_nullable FirstError() const;
55};
56
59ParseResult Parse(std::string_view source, CompilationLimits limits = {},
60 CompilationBudget* absl_nullable budget = nullptr);
61
63absl::StatusOr<syntax::TypeExpression> ParseTypeExpression(
64 std::string_view source, CompilationLimits limits = {},
65 CompilationBudget* absl_nullable budget = nullptr);
66
72ParseResult ParseTokens(std::string_view source, absl::Span<const Token> tokens,
73 std::vector<Diagnostic> diagnostics,
75 CompilationBudget* absl_nullable budget = nullptr);
76
77} // namespace a11::flow
78
79#endif // A11_FLOW_PARSER_H_
CompilationLimits limits
Definition main.cc:148
CompilationBudget budget
Definition lsp.cc:289
Definition catalogue.cc:29
ParseResult Parse(std::string_view source, CompilationLimits limits, CompilationBudget *budget)
Definition parser.cc:3613
ParseResult ParseTokens(std::string_view source, absl::Span< const Token > tokens, std::vector< Diagnostic > diagnostics, CompilationLimits limits, CompilationBudget *budget)
Definition parser.cc:3641
absl::StatusOr< syntax::TypeExpression > ParseTypeExpression(std::string_view source, CompilationLimits limits, CompilationBudget *budget)
Definition parser.cc:3626
Host-controlled bounds shared by parsing, linking and semantic analysis.
Definition limits.h:24
Flow problem rendered by the CLI, JSON and SARIF writers, and editors.
Definition diagnostic.h:99
The flows a file declares, and everything wrong with it.
Definition parser.h:34
std::vector< size_t > value_braces
Sorted offsets of braces that open values, for formatter spacing.
Definition parser.h:44
const Diagnostic *absl_nullable FirstError() const
The first error in source order, or nullptr.
Definition parser.cc:3609
std::vector< syntax::DtoDeclarationPtr > dtos
Top-level shapes in declaration order.
Definition parser.h:40
std::vector< syntax::ModuleDeclaration > modules
Definition parser.h:35
std::vector< syntax::FlowDeclarationPtr > flows
Definition parser.h:38
std::vector< syntax::ExportDeclaration > exports
Definition parser.h:36
std::vector< size_t > tagged_braces
Sorted subset of value braces that follow a type tag.
Definition parser.h:47
bool HasErrors() const
Definition parser.cc:3605
std::vector< Diagnostic > diagnostics
Definition parser.h:41
std::vector< syntax::Import > imports
Definition parser.h:37