ArkScript
A small, lisp-inspired, functional scripting language
Position.hpp
Go to the documentation of this file.
1/**
2 * @file Position.hpp
3 * @author Lex Plateau (lexplt.dev@gmail.com)
4 * @brief Defines position utilities (for text in a file) for the parser, formatter, diagnostics
5 * @date 2025-08-18
6 *
7 * @copyright Copyright (c) 2025
8 *
9 */
10
11#ifndef ARK_UTILS_POSITION_HPP
12#define ARK_UTILS_POSITION_HPP
13
14#include <optional>
15
17
18namespace Ark::internal
19{
21 {
22 std::size_t line = 0; ///< 0-indexed line number
23 std::size_t column = 0; ///< 0-indexed column number
24
25 [[nodiscard]] inline bool operator==(const FilePos& rhs) const noexcept
26 {
27 return line == rhs.line && column == rhs.column;
28 }
29 };
30
31 /**
32 * @brief Describes a span for a node/atom in a file, its start position and end position
33 */
35 {
37 std::optional<FilePos> end;
38 };
39}
40
41#endif // ARK_UTILS_POSITION_HPP
#define ARK_API
Definition Module.hpp:22
ArkScript configuration macros.
bool operator==(const FilePos &rhs) const noexcept
Definition Position.hpp:25
Describes a span for a node/atom in a file, its start position and end position.
Definition Position.hpp:35
std::optional< FilePos > end
Definition Position.hpp:37