aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/token.H18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/include/token.H b/src/include/token.H
index 71d6cb10..b57b69d6 100644
--- a/src/include/token.H
+++ b/src/include/token.H
@@ -79,6 +79,19 @@ namespace OpenAxiom {
using LineNumber = std::size_t;
using ColumnIndex = std::size_t;
+ struct Locus {
+ LineNumber line;
+ ColumnIndex column;
+ };
+
+ std::ostream& operator<<(std::ostream&, const Locus&);
+
+ // Program text region
+ struct Region {
+ Locus start;
+ Locus end;
+ };
+
// Given a symbolic or alphabetic token, retrieve its category
// and associated abstract value.
struct TokenClassification {
@@ -92,6 +105,11 @@ namespace OpenAxiom {
TokenClassification classify(const std::string&);
+ // Token data structure: a region of text with a classification.
+ struct Token : TokenClassification, Region {
+ using Location = Locus;
+ };
+
// Cursor into a fragment.
struct FragmentCursor {
std::size_t line; // index of a line in a fragment