cenotelie / hime

Apache License 2.0
27 stars 4 forks source link

no-std support for Rust #83

Open stevefan1999-personal opened 12 months ago

stevefan1999-personal commented 12 months ago

I want to use this in a compiler project but the core part of the compiler, namely the parsing part is split out as no_std code and only specific loading algorithms are std only. This makes it quite difficult for Rust Embedding community as well

woutersl commented 12 months ago

Hi, no_std could be a reachable goal if alloc is still amenable to you. I think removing all allocation is impossible, LR and GLR algorithms were not designed for this use case.

stevefan1999-personal commented 12 months ago

@woutersl Yes that would be wonderful, given that we just need to have a static buffer to declare as a heap memory blob, having alloc is fine.

woutersl commented 12 months ago

@stevefan1999-personal , I just published a version 4.3.0 of hime_redist, with support for no_std. There is a "Support for no_std" paragraph in the package description showing how to setup the dependency for this purpose (which is just the classic having std feature that can be deactivated). alloc is still required as previously mentioned.

stevefan1999-personal commented 11 months ago

@woutersl Much appreciated!

stevefan1999-personal commented 11 months ago

@woutersl I also want to see if the codegen part could support no_std as well, in particular it seems like use std::io::Read is emitted every time and need some manual intervention. I intent to use the SDK to directly generate the code every time you compile the parser, but std::io is not emigrated to core::io yet in the current time, so it is quite hard to decide.

https://github.com/cenotelie/hime/blob/e8df5b66f7ab075276f4f0ab49684d6d8ffb7d31/sdk-rust/src/output/lexer_rust.rs#L68C39-L68C39