-
-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow lexers to use custom source types #222
Comments
Fixed in #225. |
Unless I'm misunderstanding the #225 (comment) notes that it might be possible using Ropey's |
@jeertmans I think the concern there is a bit different since rope types should generally have no problems with random access. |
I put together a basic crate demoing the possibility of using Ropey and Logos together: https://github.com/kmicklas/logos-ropey However, I can't publish it on crates.io until #332 and #333 are released. |
Oh that's pretty nice @kmicklas! I think Ropey's Rope is so important that it might be worth to implement that directly within the What do you think? |
That would be nice! I'm happy to make a PR for that if you think it's a better approach. |
Super! I just merged the two PRs :) |
Okay, I did some testing, and #222 (comment) is definitely a problem. (It's not actually totally trivial to trigger a chunk size greater than 1.) To support non-contiguous sources like ropes, I can think of three possibilities:
|
I thought of another option that might work well and be easy to implement. Instead of type Chunk<'a, const N: usize>: Into<&'a [u8; N]>
where Self: 'a The contiguous string sources would just define this as This avoids any branching or copying in the string case and lets the rope case use borrowed data when possible. |
Nice finding @kmicklas! I think the best is to test that out, and include some benchmarks if possible. If we can change the current traits without degrading performances on |
Is there any particular direction your decided to pursue to make logos work with non-contiguous types, any area where it is possible to help? I am interested in using rope or gap buffer source as well. |
Hello @flyingmutant, well almost nothing was done on that topic, but you can surely help :-) There is also a list of "future work" that @maciejhirsz mentioned in the last release: https://github.com/maciejhirsz/logos/releases/tag/v0.13. |
I'm currently using
ropey
in my LSP wherelogos
is the backing lexer, and I'd like to be able to use aRope
natively within my generated lexer. TheSource
trait looks perfect, except there's no way I can find to be able to use arbitrary implements withlogos::Lexer
The text was updated successfully, but these errors were encountered: