11#ifndef EBGEOMETRY_LANGUAGESYNTAX_HPP
12#define EBGEOMETRY_LANGUAGESYNTAX_HPP
98 const std::string where =
110class Error :
public std::runtime_error
118 explicit Error(std::vector<Diagnostic> a_diagnostics)
119 : std::runtime_error(joined(a_diagnostics)), m_diagnostics(std::move(a_diagnostics))
137 const std::vector<Diagnostic>&
140 return m_diagnostics;
147 std::vector<Diagnostic> m_diagnostics;
156 joined(
const std::vector<Diagnostic>& a_diagnostics)
161 for (
const Diagnostic& d : a_diagnostics) {
162 if (d.m_severity == severity) {
163 text += (text.empty() ?
"" :
"\n") + d.str();
181enum class Token : uint8_t
200 Token m_token = Token::End;
210 double m_number = 0.0;
236 bool m_ownLine =
true;
250inline std::vector<Lexeme>
251tokenize(std::string_view a_text,
const std::string& a_file, std::vector<Comment>* a_comments =
nullptr);
256enum class NodeKind : uint8_t
283 NodeKind m_kind = NodeKind::Number;
288 double m_number = 0.0;
308 std::vector<Node> m_children;
313 std::vector<std::string> m_keys;
318 std::string m_material;
355 bool m_written =
false;
360 std::vector<Property> m_entries;
376 bool m_subdomain =
true;
396 std::vector<Node> m_list;
401 Properties m_properties;
407enum class StatementKind : uint8_t
427 StatementKind m_kind = StatementKind::Value;
432 bool m_param =
false;
457 Properties m_properties;
462 std::vector<DomainItem> m_items;
467 std::string m_coupleKind;
472 std::string m_ends[4];
498 uint32_t m_version = 0;
503 std::vector<Statement> m_statements;
508 std::vector<Comment> m_comments;
519parse(std::string_view a_text,
const std::string& a_file);
529parseExpression(std::string_view a_text,
const std::string& a_name);
538isReserved(std::string_view a_name)
noexcept;
544#include "EBGeometry_LanguageSyntaxImplem.hpp"
#define EBGEOMETRY_HOST
Mark a function as callable from host code only (no-op on host compilers).
Definition EBGeometry_GPU.hpp:83
Utility macros for EBGeometry.
A computational domain over a tape, for a downstream code (a solver EBGeometry does not provide): the...
Definition EBGeometry_Domain.hpp:63
What reading a model throws when it has errors: every error found (not only the first),...
Definition EBGeometry_LanguageSyntax.hpp:111
Error(std::vector< Diagnostic > a_diagnostics)
Error with its diagnostics.
Definition EBGeometry_LanguageSyntax.hpp:118
Error(const Span &a_span, const std::string &a_message)
One error at a span.
Definition EBGeometry_LanguageSyntax.hpp:128
const std::vector< Diagnostic > & diagnostics() const noexcept
The diagnostics, errors first.
Definition EBGeometry_LanguageSyntax.hpp:138
Model< T > parse(std::string_view a_text, const std::string &a_name, Pool &a_pool, const Overrides &a_overrides={})
Read a model from text.
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
Expr< ExprPrecision< A > > Overlay(const std::vector< A > &a_operands)
Regions by priority, a priority union: each operand is a region of its own, later operands on top of ...
One error or warning, at a span.
Definition EBGeometry_LanguageSyntax.hpp:65
Severity m_severity
Error or warning.
Definition EBGeometry_LanguageSyntax.hpp:78
std::string m_message
What is wrong, in words.
Definition EBGeometry_LanguageSyntax.hpp:88
std::string str() const
The diagnostic as one line: "file:line:column: error: message" ("file: error: message" for a whole fi...
Definition EBGeometry_LanguageSyntax.hpp:96
Span m_span
Where.
Definition EBGeometry_LanguageSyntax.hpp:83
Severity
Whether a diagnostic stops the model.
Definition EBGeometry_LanguageSyntax.hpp:70
@ Warning
The model is built; something looks unintended.
@ Error
The model cannot be built.
Where a piece of text is: its file, its first and one-past-last byte, and the line and column of its ...
Definition EBGeometry_LanguageSyntax.hpp:34
uint32_t m_begin
The first byte.
Definition EBGeometry_LanguageSyntax.hpp:43
uint32_t m_end
One past the last byte.
Definition EBGeometry_LanguageSyntax.hpp:48
std::string m_file
The file, as the model names it (the path given to read(), or the name given to parse()).
Definition EBGeometry_LanguageSyntax.hpp:38
uint32_t m_line
The line of the first byte, from 1; 0 for a span that is a whole file or no file (an override).
Definition EBGeometry_LanguageSyntax.hpp:53
uint32_t m_column
The column of the first byte, from 1, in bytes.
Definition EBGeometry_LanguageSyntax.hpp:58