-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
I'd like to volunteer! #291
Comments
Thank you! So I had a bit of a think about this, I think the best way to proceed that will futureproof the rewrite for inlining would be to define states using a fn lex(lex: &mut ::logos::Lexer<'s, Self>) {
use logos::internal::{CallbackResult, LexerInternal};
enum State {
GoTo1,
GoTo2,
GoTo3,
}
macro_rules! goto {
(GoTo1, $lex:ident) => {/* ... */};
(GoTo2, $lex:ident) => {/* ... */};
(GoTo3, $lex:ident) => {/* ... */};
}
let mut state = State::Goto3;
// Assuming Goto3 is the initial state
goto!(GoTo3, lex);
loop {
match state {
State::GoTo1 => goto!(GoTo1, lex),
State::GoTo2 => goto!(GoTo2, lex),
State::GoTo3 => goto!(GoTo3, lex),
}
}
} Just passing around the
This should make the whole codegen much easier to reason about and debug, particularly in issues like #279. The whole passing context around can potentially be scrapped. For starters I'd say do not care about performance. When I first got the 0.10 rewrite working it was chugging at maybe 20% of what it ended up running at eventually, so feel free to skip any complexity you feel makes things difficult, we can always add optimizations later once tests are green. Even then I think I'd be fine if the final product of the rewrite is tiny bit slower if it means it's actually 100% correct. Let me know if you need any more pointers, or if you have any questions about anything to get going. Powodzenia! 🥇 |
Just a side note: You mentioned other data structures like ropes that could be easily lexed after a rewrite. I just wanna tune in as someone who also has used Logos a few times to lex streams of binary data. For now this is largely undocumented magic, but i think it’s useful enough to advertise this in the future, and also design the Regex-replacing (yes, thanks!) DSL in a way that is binary-data-friendly. I’ve used Logos more often to verify arbitrary user inputs than i have to perform actual lexing for some parser. |
Well, the good thing about going that route is is that macros allow for a lot of neat syntax that's not easily done in regex. We could potentially abuse hexadecimal integer literals like |
Perfect. =) That DSL has pretty much all Rust tokens at its disposal. It could look like EBNF, ABNF, Rosie, what have you. It does rise the question, what »subpatterns« would look like in the new DSL, for i use subpatterns heavily. But as you mentioned, these are all questions for after the rewrite. |
As mentioned in a previous email we exchanged @maciejhirsz, I’d love to give some help too :) thanks for the detailed message above as well as the one in the release :) |
@maciejhirsz I have some old WIP in this fork https://github.com/uael/logos. |
@uael cheers, will have a look around. Sublexing will hopefully become much easier once we can remove this cursed field in the rewrite. It should be trivial to do something like: fn foo(lex: &mut Lexer<OuterToken>) {
let lex: &mut Lexer<InnerToken> = lex.as();
} Or even: fn foo(lex: &mut Lexer<OuterToken>) {
// Same as .next(), but but with a different token type
let inner = lex.sublex::<InnerToken>();
} We could even go as far and remove the There is |
@agluszak have you started any work on this yet? I think I have a big enough time window to dedicate to it so I could at least start it. |
On a side note @maciejhirsz, but related to this issue and to
in v0.13, I'd be happy to help you maintain this project :-) (so being able to review issues and PRs) |
@jeertmans thanks, everything you did so far was stellar, I've sent you an invite! |
Nice, thank you, @maciejhirsz! I think finishing up #301 will improve future PRs, so I'll have a look at Clippy's warnings when I have time to make the CI happy. Then, I would probably want to work on #311 Once that CI/doc step is done, I would be happy to help on the more technical parts (i.e., the macro), if you ever need help on that :-) |
🙋 is there any issue / project you guys are working on where I could volunteer? |
I'd like to help with the rewrite mentioned here: https://github.com/maciejhirsz/logos/releases/tag/v0.13 :) I already have some experience with logos' internals, at least the "frontend" part.
The text was updated successfully, but these errors were encountered: