Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Added with_slice, updated logos example#439

Open
zesterer wants to merge 1 commit intomainfrom
with_slice
Open

Added with_slice, updated logos example#439
zesterer wants to merge 1 commit intomainfrom
with_slice

Conversation

@zesterer
Copy link
Copy Markdown
Owner

@zesterer zesterer commented Jun 7, 2023

Currently unsound if passed an incorrectly sized slice.

@Amejonah1200
Copy link
Copy Markdown

It would be nice to have also a lasso integration.
This would allow making calls like ident().intern() possible.

Comment thread examples/logos.rs
Comment on lines 34 to 35
#[regex(r"[ \t\f\n]+", logos::skip)]
Whitespace,
Copy link
Copy Markdown

@Amejonah1200 Amejonah1200 Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be moved under the #[derive(...)] using #[logos(skip r"[ \t\f\n]+")]

Comment thread examples/logos.rs
) -> impl Parser<'a, I, SExpr, extra::Err<Rich<'a, Token<'a>>>> {
fn parser<'a, I>() -> impl Parser<'a, I, SExpr, extra::Err<Rich<'a, Token<'a>>>>
where
I: ValueInput<'a, Token = Token<'a>, Span = SimpleSpan> + SliceInput<'a, Slice = &'a str>,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbf, to avaid humongous types, trait "aliases" should be used.

pub type TokenParserExtra<'a> = Full<Rich<'a, Token>, (), ()>;

pub trait TokenInput<'a>: ValueInput<'a, Token = Token, Span = SimpleSpan> {}
impl<'a, T> TokenInput<'a> for T where T: ValueInput<'a, Token = Token, Span = SimpleSpan> {}

pub trait TokenParser<'a, I: TokenInput<'a>, O>:
    Parser<'a, I, O, TokenParserExtra<'a>> + Clone {
}
impl<'a, I: TokenInput<'a>, O, T> TokenParser<'a, I, O> for T where T: Parser<'a, I, O, TokenParserExtra<'a>> + Clone {}

until real trait aliases are available

@Zij-IT
Copy link
Copy Markdown
Contributor

Zij-IT commented Aug 25, 2023

It would be nice to have also a lasso integration. This would allow making calls like ident().intern() possible.

Would this not be equivalent to:

ident().map_with_state(|i, _, rodeo: &Rodeo| rodeo.get_or_intern(i))

@Amejonah1200
Copy link
Copy Markdown

It would be nice to have also a lasso integration. This would allow making calls like ident().intern() possible.

Would this not be equivalent to:

ident().map_with_state(|i, _, rodeo: &Rodeo| rodeo.get_or_intern(i))

Yes, I will use trait extensions for that then.

@zesterer zesterer force-pushed the main branch 5 times, most recently from 38bb88c to 02a1373 Compare May 26, 2025 14:11
@zesterer zesterer force-pushed the main branch 2 times, most recently from 0f2b61a to e350fc6 Compare November 5, 2025 19:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants