Skip to content
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

Added with_slice, updated logos example #439

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Added with_slice, updated logos example #439

wants to merge 1 commit into from

Conversation

zesterer
Copy link
Owner

@zesterer zesterer commented Jun 7, 2023

Currently unsound if passed an incorrectly sized slice.

@Amejonah1200
Copy link

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

Comment on lines 34 to 38
#[regex(r"[ \t\f\n]+", logos::skip)]
Whitespace,
Copy link

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]+")]

) -> 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>,

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
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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants