Documentation
¶
Index ¶
- func BytesSource(content []byte) api.Source
- func CalcLocation(source api.SourceCode, pos int, isEndPos bool) (line, char int)
- func CalcLocationRange(source api.SourceCode, start, end int) (line1, line2, char1, char2 int)
- func Describe(n api.Node) (name string, children []api.Node)
- func EmptySource() api.Source
- func Expose[T any](expose func(T) string, items ...T) string
- func ExposeConfig(cfg api.Config) string
- func ExposeList[T any](expose func(T) string, items []T, sep string) string
- func ExposeNode(node api.Node) string
- func ExposeNodeSurface(node api.Node) string
- func ExposeParser(p api.Parser) string
- func ExposeScanner(scanner api.Scanner) string
- func ExposeSource(source api.Source) string
- func ExposeToken(token api.Token) string
- func ExposeTranslator[From, To any](translator api.Translator[From, To]) string
- func FileSource(path string) (api.Source, error)
- func FreeSource(path, content string) api.Source
- func Get[Option any](cfg api.Config, key string) (option Option, found bool)
- func InitParser[T api.Parser](s api.Scanner) (out T)
- func PointedWindow(source api.SourceCode, start, end int) string
- func PrintTree(w io.Writer, n api.Node)
- func Reclassify[T api.Node](nodes []T) []api.Node
- func StringSource(content string) api.Source
- func Tokenize(scanner api.Scanner, buf []api.Token) (_ []api.Token, errorToken *api.Token)
- func TranslateRemaining[From, To any](dest []To, translator api.Translator[From, To]) []To
- func Window(source api.SourceCode, start, end int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesSource ¶
func CalcLocation ¶
func CalcLocation(source api.SourceCode, pos int, isEndPos bool) (line, char int)
func CalcLocationRange ¶
func CalcLocationRange(source api.SourceCode, start, end int) (line1, line2, char1, char2 int)
func EmptySource ¶
func ExposeConfig ¶
func ExposeList ¶
ExposeList returns a string representation of a list of items
this function is guaranteed to return a string with a left-most '[' and a right-most ']' and a possibly empty string between them
func ExposeNode ¶
ExposeNode returns a string representation of the node's exposed data
Example:
"Node{line: 1, column: 1, name: foo, children: [Node{line: 1, column: 5, name: bar, children: []}]}"
func ExposeNodeSurface ¶
ExposeNodeSurface returns a string representation of the node's exposed top level data (no children)
If the node has children, the children will be represented as "[...]"; otherwise, they will be represented as "[]"
Example:
"Node{line: 1, column: 1, name: foo, children: [...]}"
func ExposeParser ¶
func ExposeScanner ¶
func ExposeSource ¶
func ExposeToken ¶
ExposeToken returns a string representation of the token's exposed data
func ExposeTranslator ¶
func ExposeTranslator[From, To any](translator api.Translator[From, To]) string
func FreeSource ¶
func PointedWindow ¶
func PointedWindow(source api.SourceCode, start, end int) string
func StringSource ¶
func Tokenize ¶
Tokenize scans all tokens from the scanner (from its current input position) and returns them in a slice.
If an error occurs during scanning, the function will return whatever tokens were scanned up to that point with a non-nil value for 'errorToken'.
func TranslateRemaining ¶
func TranslateRemaining[From, To any](dest []To, translator api.Translator[From, To]) []To
dest may be nil, in which case a new slice will be allocated
NOTE: if translator returns true on `translator.Done()`, this function will loop infinitely
- this can be prevented by implementing the following method: `UpperBound() int`
- an example of how this could be implemented in a reasonable way is shown in `api/examples/translator.go`
- if `UpperBound()` returns a negative value, the number of translations will be treated as unbounded
func Window ¶
func Window(source api.SourceCode, 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 3 | spec Functor f where 4 | map : (a -> b) -> f a -> f b 5 | (<$) : a -> f b -> f a mySrc.Window(x, y), where x is somewhere on line 3, and y is somewhere of line 4 3 | spec Functor f where 4 | map : (a -> b) -> f a -> f b
Types ¶
This section is empty.