scope_analysis & core_ast: added functions to convert directly from source for convenience
All checks were successful
ci/woodpecker/push/debian Pipeline was successful
ci/woodpecker/push/fedora Pipeline was successful
ci/woodpecker/push/nix Pipeline was successful
ci/woodpecker/push/publish Pipeline was successful
ci/woodpecker/cron/nix Pipeline was successful
ci/woodpecker/cron/fedora Pipeline was successful
ci/woodpecker/cron/debian Pipeline was successful
ci/woodpecker/cron/publish Pipeline was successful

This commit is contained in:
2026-02-28 18:59:37 +03:00
parent a95a676cb2
commit fe26b6c2b3
2 changed files with 10 additions and 0 deletions

View File

@@ -1,4 +1,6 @@
let traverse = Util.traverse
type literal = type literal =
| Int of int | Int of int
| Double of float | Double of float
@@ -121,3 +123,7 @@ and of_syntactic : Syntactic_ast.top_level -> top_level = function
let of_sexpr x = let of_sexpr x =
Result.bind (Syntactic_ast.make x) Result.bind (Syntactic_ast.make x)
(fun x -> Ok (of_syntactic x)) (fun x -> Ok (of_syntactic x))
let of_src src =
let sexprs = Parser.parse_str src in
traverse of_sexpr sexprs

View File

@@ -134,3 +134,7 @@ let convert program =
let tbl = SymbolTable.add s (id ()) tbl in let tbl = SymbolTable.add s (id ()) tbl in
(analyze tbl [] e) :: (aux tbl rest) (analyze tbl [] e) :: (aux tbl rest)
in traverse (fun x -> x) (aux SymbolTable.empty program) in traverse (fun x -> x) (aux SymbolTable.empty program)
let of_src src =
let* core = (Core_ast.of_src src) in
convert core