PUMA Library Reference Manual
Loading...
Searching...
No Matches
Puma::Location Class Reference

#include <Puma/Location.h>

Description

Location of a token in a source file.

Public Member Functions

 Location ()
 Construct an empty location. More...
 
 Location (Filename filename, int line, int column=0)
 Construct a token location. More...
 
void setup (Filename filename, int line, int column=0)
 Initialize a token location. More...
 
const Filenamefilename () const
 Get the name of the file the token is located in. More...
 
int line () const
 Get the number of the line in the file. More...
 
int column () const
 Get the number of the column in the file. More...
 
bool operator== (const Location &location) const
 Compare with another location. More...
 
bool operator!= (const Location &location) const
 Compare with another location. More...
 
bool operator< (const Location &location) const
 Compare with another location in the same file. More...
 

Constructor & Destructor Documentation

◆ Location() [1/2]

Puma::Location::Location ( )
inline

Construct an empty location.

◆ Location() [2/2]

Puma::Location::Location ( Filename  filename,
int  line,
int  column = 0 
)
inline

Construct a token location.

Parameters
filenameThe name of the file the token is located in.
lineThe line number.
columnThe optional column number. Defaults to 0.

Member Function Documentation

◆ column()

int Puma::Location::column ( ) const
inline

Get the number of the column in the file.

Returns
The column number.

◆ filename()

const Filename & Puma::Location::filename ( ) const
inline

Get the name of the file the token is located in.

Returns
A reference to the file name.

◆ line()

int Puma::Location::line ( ) const
inline

Get the number of the line in the file.

Returns
The line number.

◆ operator!=()

bool Puma::Location::operator!= ( const Location location) const
inline

Compare with another location.

Parameters
locationThe other location.
Returns
True if both locations differ.

◆ operator<()

bool Puma::Location::operator< ( const Location location) const
inline

Compare with another location in the same file.

Parameters
locationThe other location.
Returns
True if this location is before the given location in the same file.

◆ operator==()

bool Puma::Location::operator== ( const Location location) const
inline

Compare with another location.

Parameters
locationThe other location.
Returns
True if both locations are equal.

◆ setup()

void Puma::Location::setup ( Filename  filename,
int  line,
int  column = 0 
)
inline

Initialize a token location.

Parameters
filenameThe name of the file the token is located in.
lineThe line number.
columnThe optional column number. Defaults to 0.