is in place:
moonlark.
libstarlark is a Starlark (i.e. Bazel language) parser written in
C11. moonlark is a Lua binding on libstarlark. Development was
motivated by the need to support automated maintenance of BUILD
files for OCaml projects using
OBazl, but the design is
language-agnostic. Two applications are provided. moonlark:edit
is a C application that takes a filename argument, uses
libstarklark to parse the file, converts the AST to a Lua table,
and invokes a user-provided Lua function, passing the AST table.
User code is then responsible for manipulating the AST. An
included library of Lua code will contain routines to support AST
editing, but in the current version only serialization is
supported. A second target, moonlark:repl, launches a Lua
interpreter with moonlark preloaded.
Lua is a simple but powerful language; the code to serialize an AST is only about 65 short lines of Lua code. Developers who want to build tools that need to parse Starlark files should be able to use moonlark to mangle the AST ad libitum and emit whatever they want with relative ease.