17 #ifndef COM_BORA_SOFTWARE__BALAU_LANG_PROPERTY_LANG__PROPERTY_AST 18 #define COM_BORA_SOFTWARE__BALAU_LANG_PROPERTY_LANG__PROPERTY_AST 58 return codeSpan == rhs.codeSpan;
89 public:
static std::string
normalise(std::string_view input) {
91 std::string output = std::string(input);
96 while (inOffset < (
int) input.length()) {
100 if (inOffset == (
int) input.length()) {
109 skipLineContinuation(input, inOffset, output, outOffset);
124 output.erase((
size_t) outOffset);
136 : codeSpan(codeSpan_) {}
139 : codeSpan(rhs.codeSpan) {}
141 private:
static void skipLineContinuation(
const std::string_view & input,
143 std::string & output,
145 if (inOffset == (
int) input.length()) {
151 if (c == U
'\r' || c == U
'\n') {
152 if (inOffset == (
int) input.length()) {
160 if (inOffset == (
int) input.length()) {
182 std::string && text_,
183 std::vector<std::unique_ptr<PropertyNode>> && nodes_)
185 , text(
std::move(text_))
186 , nodes(
std::move(nodes_)) {}
188 public:
const std::string & getText()
const {
192 public:
const std::vector<std::unique_ptr<PropertyNode>> & getNodes()
const {
197 auto * o =
dynamic_cast<const Properties *
>(&rhs);
203 ret = text == o->text
211 visitor.
visit(payload, *
this);
214 private: std::string text;
215 private: std::vector<std::unique_ptr<PropertyNode>> nodes;
236 , value(rhs.value) {}
263 ret = name == o->name
272 visitor.
visit(payload, *
this);
281 private: std::string_view name;
282 private: std::string_view value;
293 std::string_view name_,
294 std::vector<std::unique_ptr<PropertyNode>> && nodes_)
297 , nodes(
std::move(nodes_)) {}
305 , nodes(std::move(rhs.nodes)) {}
321 public:
const std::vector<std::unique_ptr<PropertyNode>> &
getNodes()
const {
332 ret = name == o->name
341 visitor.
visit(payload, *
this);
350 private: std::string_view name;
351 private: std::vector<std::unique_ptr<PropertyNode>> nodes;
388 ret = text == o->text
396 visitor.
visit(payload, *
this);
405 private: std::string_view text;
442 ret = text == o->text
450 visitor.
visit(payload, *
this);
459 private: std::string_view text;
492 visitor.
visit(payload, *
this);
504 #endif // COM_BORA_SOFTWARE__BALAU_LANG_PROPERTY_LANG__PROPERTY_AST std::string_view getName() const
Get the string view pointing to the name of the composite property.
Definition: PropertyAst.hpp:312
void visit(Payload &payload, PropertyVisitor &visitor) const override
Visit the node.
Definition: PropertyAst.hpp:491
void visit(Payload &payload, PropertyVisitor &visitor) const override
Visit the node.
Definition: PropertyAst.hpp:210
const std::vector< std::unique_ptr< PropertyNode > > & getNodes() const
Get the string view pointing to the value of the composite property.
Definition: PropertyAst.hpp:321
virtual void visit(Payload &payload, const AST::Properties &object)=0
Visit a Properties node.
virtual void visit(Payload &payload, PropertyVisitor &visitor) const =0
Visit the node.
const CodeSpan & getCodeSpan() const
Get the code span of the node.
Definition: PropertyAst.hpp:46
Simple name-value property node.
Definition: PropertyAst.hpp:221
Information on the span of some source code text.
Definition: CodeSpan.hpp:91
Visitor interface for property AST nodes.
Definition: PropertyVisitor.hpp:49
EmptyLinePropertyNode(const CodeSpan &codeSpan_)
Create a blank line property node with the supplied data.
Definition: PropertyAst.hpp:469
Abstract base class of Property AST node classes.
Definition: PropertyAst.hpp:35
static bool isBlank(char32_t c)
Is the specified code point a character that visibly separates words on a line.
Definition: Character.hpp:113
std::string_view getText() const
Get the string view pointing to the text of the include property.
Definition: PropertyAst.hpp:377
std::string_view getName() const
Get the string view pointing to the name of the value property.
Definition: PropertyAst.hpp:243
Represents a blank line in a property file.
Definition: PropertyAst.hpp:465
static char32_t getNextUtf8Safe(const std::string_view &text, int &offset)
Get the next code point from the UTF-8 string view (validating version).
Definition: Character.hpp:198
IncludePropertyNode(IncludePropertyNode &&rhs) noexcept
Construct an include property node by moving the contents of the supplied node.
Definition: PropertyAst.hpp:368
CompositeProperty(const CodeSpan &codeSpan_, std::string_view name_, std::vector< std::unique_ptr< PropertyNode >> &&nodes_)
Create a composite property node with the supplied data.
Definition: PropertyAst.hpp:292
A position in a piece of multi-line text.
virtual ~PropertyNode()=default
Destroy a Property AST node.
Composite name-value property node.
Definition: PropertyAst.hpp:288
Base class of property visitor payloads.
Definition: PropertyVisitor.hpp:39
void visit(Payload &payload, PropertyVisitor &visitor) const override
Visit the node.
Definition: PropertyAst.hpp:271
Utilities for unicode characters and code points.
ValueProperty(const CodeSpan &codeSpan_, std::string_view name_, std::string_view value_)
Create a name-value property node with the supplied data.
Definition: PropertyAst.hpp:225
Base Balau exception classes.
ValueProperty(ValueProperty &&rhs) noexcept
Construct a name-value property node by moving the contents of the supplied node. ...
Definition: PropertyAst.hpp:233
CompositeProperty(CompositeProperty &&rhs) noexcept
Construct a composite property node by moving the contents of the supplied node.
Definition: PropertyAst.hpp:302
Include property node.
Definition: PropertyAst.hpp:357
static void setUtf8AndAdvanceOffset(std::string &destination, int &offset, char32_t c)
Write a code point into the supplied UTF-8 string.
Definition: Character.hpp:329
bool operator!=(const PropertyNode &rhs) const
Returns true if the current node is not equal to the supplied node.
Definition: PropertyAst.hpp:68
std::string_view getValue() const
Get the string view pointing to the value of the value property.
Definition: PropertyAst.hpp:252
The Property parser Token enum.
void visit(Payload &payload, PropertyVisitor &visitor) const override
Visit the node.
Definition: PropertyAst.hpp:395
void visit(Payload &payload, PropertyVisitor &visitor) const override
Visit the node.
Definition: PropertyAst.hpp:340
IncludePropertyNode(const CodeSpan &codeSpan_, std::string_view text_)
Create an include property node with the supplied data.
Definition: PropertyAst.hpp:361
virtual bool operator==(const PropertyNode &rhs) const
Returns true if the current node is equal to the supplied node.
Definition: PropertyAst.hpp:57
The Property parser abstract syntax tree node classes.
Definition: PropertyAst.hpp:30
Visitor interface for property AST nodes.
EmptyLinePropertyNode(EmptyLinePropertyNode &&rhs) noexcept
Construct a blank line property node by moving the contents of the supplied node. ...
Definition: PropertyAst.hpp:475
The outer structure.
Definition: PropertyAst.hpp:175
Properties(const CodeSpan &codeSpan_, std::string &&text_, std::vector< std::unique_ptr< PropertyNode >> &&nodes_)
Create a properties node.
Definition: PropertyAst.hpp:181
static std::string normalise(std::string_view input)
Removing escaping, line continuation, and leading blanks.
Definition: PropertyAst.hpp:89