33 lines
850 B
C++
33 lines
850 B
C++
#pragma once
|
|
#include "sapphirepch.h"
|
|
|
|
/* Struct to represent a location in a file. */
|
|
struct Location
|
|
{
|
|
int line;
|
|
int column;
|
|
std::string filename;
|
|
|
|
/* The location at which this location was imported, for error traces in imported files. */
|
|
std::shared_ptr<Location> parent = nullptr;
|
|
|
|
/* Creates a Location with the given parameters. */
|
|
Location(int line, int column, std::string filename);
|
|
|
|
~Location();
|
|
|
|
/* Returns a string of the format FILE:LINE:COL. */
|
|
std::string str() const;
|
|
|
|
/* Advance to the next column in the file. */
|
|
void advance();
|
|
|
|
/* Advance to the next line if provided a newline. */
|
|
void pos_from_char(const char& character);
|
|
|
|
void operator=(const Location& other);
|
|
|
|
/* Returns a copy of the original Location. */
|
|
static Location copy(const Location& other);
|
|
};
|