-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
base: main
Are you sure you want to change the base?
Conversation
It would be nice to have also a lasso integration. |
#[regex(r"[ \t\f\n]+", logos::skip)] | ||
Whitespace, |
There was a problem hiding this comment.
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>, |
There was a problem hiding this comment.
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
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. |
Currently unsound if passed an incorrectly sized slice.