23 FileName = fileName?.Replace(
'\\',
'/');
124 int start = Math.Max(0,
Index - left);
127 return Source.Substring(start, end - start);
134 for (
int i = 0; i <
Index; i++)
174 throw new InvalidOperationException(
"Cannot combine positions from different sources");
177 return Index < other.Index
Describes a specific position inside a source file.
string GetPositionInfo()
Returns position info. Format: file://[FileName] : Line [Line].
static BadSourcePosition Create(string fileName, string source, int index, int length)
Creates a new Source Position.
int Index
The Start Index of the Position.
string GetExcerpt(int left, int right)
Returns the excerpt of the source code.
string Source
The Source Code.
BadSourcePosition(string? fileName, string source, int index, int length)
Constructor for a Source Position.
BadSourcePosition(string fileName, int index, int length)
Constructor for a Source Position.
string GetExcerpt(int len=10)
Returns the excerpt of the source code.
static BadSourcePosition FromFile(string fileName, int index, int length)
Creates a new Source Position.
string? FileName
The Filename of the Source Code.
static BadSourcePosition FromSource(string source, int index, int length)
Creates a new Source Position.
BadSourcePosition Combine(BadSourcePosition other)
Combines two Source Positions.
string Text
Returns the Position as a string.
int Length
The Length of the Position.
Public interface for the filesystem abstraction of the BadScript Engine.
Contains Shared Data Structures and Functionality.
Contains IO Implementation for the BadScript2 Runtime.