docs: document methods

This commit is contained in:
2025-12-29 20:44:55 -05:00
parent 05cd8bc4f3
commit 412d3924eb
3 changed files with 3 additions and 1 deletions

View File

@@ -212,6 +212,7 @@ func parseStatement(i *TokenIterator) (ast.Statement, error) {
}
}
// Given a list of tokens, attempt to parse it into an syntax tree.
func Parse(tokens []token.Token) (ast.Expression, error) {
i := iterator.Of(tokens)

View File

@@ -54,6 +54,7 @@ func stringifyClause(n *ast.Clause) string {
return "{ " + stmts + Stringify(n.Returns) + " }"
}
// Convert an expression back into valid source code.
func Stringify(n ast.Expression) string {
switch n := n.(type) {
case *ast.Atom:

View File

@@ -97,7 +97,7 @@ func getToken(i *iterator.Iterator[rune]) (*token.Token, error) {
return nil, fmt.Errorf("unknown character '%v'", string(letter))
}
// Parses a list of runes into tokens. All error encountered are returned, as well.
// Parse a string into tokens.
func GetTokens(input string) ([]token.Token, error) {
i := iterator.Of([]rune(input))
tokens := []token.Token{}