Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't think you can do this without recompiling, since the grammars get translated into C code before use. But the built-in command line tools (‘tree-sitter parse’, etc) all support a mode where they will detect local changes to a checked-out grammar definition, and recompile on the fly if needed. (This happens each time the CLI program is started up; it doesn't happen during a long-running process.)


The obvious answer is to embed TCC or another C compiler and either generate a dynamic library or generate wasm and load it directly into the process.

exec_wasm(generate_wasm(generate_c(grammar)))

Now if you can make that whole fn chain incremental, then a delta_grammar -> delta_c -> delta_wasm -> delta_recomputed_wasm_call stack, this will propagate deltas down to exec_wasm and you could dynamically execute the generated code as the grammar changes.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: