P4C
The P4 Compiler
Util::SourceInfo Class Referencefinal

Public Member Functions

 SourceInfo ()=default
 Creates an "invalid" SourceInfo.
 
 SourceInfo (const InputSources *sources, SourcePosition point)
 Creates a SourceInfo for a 'point' in the source, or invalid.
 
 SourceInfo (const InputSources *sources, SourcePosition start, SourcePosition end)
 
 SourceInfo (const SourceInfo &other)=default
 
 SourceInfo (cstring filename, int line, int column, cstring srcBrief)
 
void dbprint (std::ostream &out) const
 
const SourcePositiongetEnd () const
 
cstring getLineNum () const
 
cstring getSourceFile () const
 
const SourcePositiongetStart () const
 
bool isValid () const
 
 operator bool () const
 
SourceInfo operator+ (const SourceInfo &rhs) const
 
SourceInfooperator+= (const SourceInfo &rhs)
 
bool operator< (const SourceInfo &rhs) const
 
bool operator<= (const SourceInfo &rhs) const
 
SourceInfooperator= (const SourceInfo &other)=default
 
bool operator== (const SourceInfo &rhs) const
 
bool operator> (const SourceInfo &rhs) const
 
bool operator>= (const SourceInfo &rhs) const
 
cstring toBriefSourceFragment () const
 
cstring toDebugString () const
 
SourceFileLine toPosition () const
 
cstring toPositionString () const
 
cstring toSourceFragment (bool useMarker=true) const
 
cstring toSourcePositionData (unsigned *outLineNumber, unsigned *outColumnNumber) const
 

Public Attributes

int column = -1
 
cstring filename = ""
 
int line = -1
 
cstring srcBrief = ""
 

Detailed Description

Information about the source position of a language element - a range of position within an InputSources. Can only be interpreted relative to some InputSources.

For a program element, the start is inclusive and the end is exclusive (the first position after the language element).

SourceInfo can also be "invalid"

Member Function Documentation

◆ operator+()

SourceInfo Util::SourceInfo::operator+ ( const SourceInfo rhs) const
inline

A SourceInfo that spans both this and rhs. However, if this or rhs is invalid, it is not taken into account

◆ operator<()

bool Util::SourceInfo::operator< ( const SourceInfo rhs) const
inline

True if this comes 'before' this source position. 'invalid' source positions come first. This is true if the start of other is strictly before the start of this.