Documentation
¶
Overview ¶
================================================================================================= Alex Peters - January 18, 2024
Path specifier interface for either a file system path or stdin ¶
This is useful since the relevant information when the input is stdin is likely just that the source of input is the standard input rather than its file system path. =================================================================================================
================================================================================================= Alex Peters - January 29, 2024 =================================================================================================
Index ¶
Constants ¶
This section is empty.
Variables ¶
var StdinSpec = StandardInput{}
Functions ¶
func AssertStringInput ¶
func NamedStringInput ¶
func StringInput ¶
func StringInput(s string) stringInput
Types ¶
type SourceCode ¶
type SourceCode struct {
Path PathSpec
// source file as an array of strings for each non-empty line, does not include newline chars
Source []byte
// records end (exclusive) position for all lines n at index n-1.
//
// for example, given
// PositionRanges = []int{10, 23, 56}
// line one ends at position 10, line two ends at position 23, and line three ends at position 56
PositionRanges []int
}
func (SourceCode) CalcLocation ¶
func (source SourceCode) CalcLocation(pos int, isEndPos bool) (line, char int)
calculates line and char number given a source code position
first return value is line number, second is char
func (SourceCode) CalcLocationRange ¶
func (source SourceCode) CalcLocationRange(start, end int) (line1, line2, char1, char2 int)
calculates a location range given a `start` and `end` position
first two return values are start line number and end line number respectively. Last two return values are start and end char number respectively
func (SourceCode) PointedWindow ¶
func (source SourceCode) PointedWindow(start, end int) string
func (SourceCode) Window ¶
func (source SourceCode) Window(start, end int) string
returns a window for the source code according to the start to the end position.
example:
1 | -- original the source code 2 | module example where 3 | trait Functor f where 4 | map : (a -> b) -> f a -> f b 5 | _<$_ : a -> f b -> f a 6 | end 7 | end mySrc.Window(x, y) // where x is somewhere on line 3, and y is somewhere of line 4 3 | trait Functor f where 4 | map : (a -> b) -> f a -> f b