mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-17 11:22:22 -07:00
35 lines
686 B
Odin
35 lines
686 B
Odin
package odin_format
|
|
|
|
import "core:odin/printer"
|
|
import "core:odin/parser"
|
|
import "core:odin/ast"
|
|
|
|
default_style := printer.default_style;
|
|
|
|
simplify :: proc(file: ^ast.File) {
|
|
|
|
}
|
|
|
|
format :: proc(source: [] u8, config: printer.Config, allocator := context.allocator) -> ([] u8, bool) {
|
|
|
|
pkg := ast.Package {
|
|
kind = .Normal,
|
|
};
|
|
|
|
file := ast.File {
|
|
pkg = &pkg,
|
|
src = source,
|
|
};
|
|
|
|
p := parser.default_parser();
|
|
|
|
ok := parser.parse_file(&p, &file);
|
|
|
|
if !ok || file.syntax_error_count > 0 {
|
|
return {}, false;
|
|
}
|
|
|
|
prnt := printer.make_printer(config, allocator);
|
|
|
|
return transmute([]u8) printer.print(&prnt, &file), true;
|
|
} |