Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::SourceLocation Struct Reference

Represents a location in source code. More...

#include <parse_utils.H>

Collaboration diagram for Aleph::SourceLocation:
[legend]

Public Member Functions

 SourceLocation ()=default
 Default constructor.
 
 SourceLocation (std::string file, const int ln, const int col)
 Construct with all fields.
 
std::string to_string () const
 Convert to human-readable string.
 

Static Public Member Functions

static SourceLocation current (const std::string &file="")
 Construct from the current global parsing state.
 
static SourceLocation previous (const std::string &file="")
 Construct from the previous (token start) global parsing state.
 

Public Attributes

std::string filename
 Name of the source file.
 
int line = 1
 Line number (1-based)
 
int column = 1
 Column number (1-based)
 

Detailed Description

Represents a location in source code.

Stores file name, line number, and column number for precise error reporting in parsers and compilers.

Definition at line 601 of file parse_utils.H.

Constructor & Destructor Documentation

◆ SourceLocation() [1/2]

Aleph::SourceLocation::SourceLocation ( )
default

Default constructor.

◆ SourceLocation() [2/2]

Aleph::SourceLocation::SourceLocation ( std::string  file,
const int  ln,
const int  col 
)
inline

Construct with all fields.

Definition at line 611 of file parse_utils.H.

Member Function Documentation

◆ current()

static SourceLocation Aleph::SourceLocation::current ( const std::string &  file = "")
inlinestatic

Construct from the current global parsing state.

Definition at line 615 of file parse_utils.H.

References Aleph::current_col_number, Aleph::current_line_number, and file.

Referenced by TEST().

◆ previous()

static SourceLocation Aleph::SourceLocation::previous ( const std::string &  file = "")
inlinestatic

Construct from the previous (token start) global parsing state.

Definition at line 621 of file parse_utils.H.

References file, Aleph::previous_col_number, and Aleph::previous_line_number.

◆ to_string()

std::string Aleph::SourceLocation::to_string ( ) const
inline

Convert to human-readable string.

Returns
String in format "filename:line:column" or "line:column"

Definition at line 630 of file parse_utils.H.

References column, Aleph::DynList< T >::empty(), filename, line, and Aleph::maps().

Referenced by TEST(), TEST(), and Aleph::Token::to_string().

Member Data Documentation

◆ column

int Aleph::SourceLocation::column = 1

Column number (1-based)

Definition at line 605 of file parse_utils.H.

Referenced by TEST(), TEST(), and to_string().

◆ filename

std::string Aleph::SourceLocation::filename

Name of the source file.

Definition at line 603 of file parse_utils.H.

Referenced by TEST(), TEST(), and to_string().

◆ line

int Aleph::SourceLocation::line = 1

Line number (1-based)

Definition at line 604 of file parse_utils.H.

Referenced by TEST(), TEST(), and to_string().


The documentation for this struct was generated from the following file: