Module

location

Source location tracking for error messages and debugging.

Provides SourceLocation dataclass for tracking positions in source text. Used throughout Patitas for error messages, AST nodes, and debugging.

Thread Safety:

SourceLocation is frozen (immutable) and safe to share across threads.

Classes

SourceLocation 10 ▼

Attributes

Name Type Description
lineno int —
col_offset int —
offset int —
end_offset int —
end_lineno int | None —
end_col_offset int | None —
source_file str | None —

Methods

span_to 1 SourceLocation ▼
Create a new location spanning from this location to end.
def span_to(self, end: SourceLocation) -> SourceLocation
Parameters
Name Type Description
end —

Ending location

Returns
SourceLocation New SourceLocation with this start and end's end positions
unknown 0 SourceLocation ▼
Create an unknown/placeholder location. Use for AST nodes created syntheticall…
classmethod
def unknown(cls) -> SourceLocation

Create an unknown/placeholder location.

Use for AST nodes created synthetically or when location is unavailable.

Returns
SourceLocation
Internal Methods 1 ▼
__str__ 0 str ▼
Format location for error messages.
def __str__(self) -> str
Returns
str Formatted string like "file.md:10:5" or "10:5"