Formats Jai source. On success result is newly allocated (free it with free); on failure
it is empty and error (temporary storage) says why, with a line:column: prefix when it
points at the input: text that does not lex, unbalanced brackets, or the internal token check.
formatted, ok, error := format_source("f::(a:int)->int{return a;}\n");
assert(ok);
assert(formatted == "f :: (a: int) -> int {\n return a;\n}\n");
_, ok, error = format_source("f :: () {");
assert(!ok && error.count > 0);format_source :: (
text: string,
config: Format_Config = .{}
) -> (result: string, ok: bool, error: string)
Parameters
- text: string
- config: Format_Config = .{}
Returns
- result: string
- ok: bool
- error: string