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

Custom Source implementation when using derive macro #225

Merged
merged 2 commits into from
Feb 26, 2023

Conversation

philliard3
Copy link
Contributor

Used existing macro code as a basis for implementing a source option for the derive macro. The idea is to allow users to derive their own Source using the provided trait, which was previously missing from derive.

This work was started based on the need expressed in issue #222 . Please let me know if anything seems incorrect or anything more needs to be done.

philliard3 and others added 2 commits September 28, 2021 22:02
…t for the derive macro. This should allow users to derive their own Source using the provided trait, which was previously missing from derive.
@maciejhirsz maciejhirsz merged commit 883cdfa into maciejhirsz:master Feb 26, 2023
@maciejhirsz
Copy link
Owner

Better late than never, eh? :)

@edko99
Copy link

edko99 commented Mar 27, 2023

Would it please be possible to implement Source for ropey::Rope?
I've tried, but got stuck because ropey::RopeSlice takes a lifetime parameter, so I cannot assign it to the Slice associated type.

@maciejhirsz
Copy link
Owner

@edko99 I think so. Since I made the trait GATs got stabilizied, so I reckon we could change:

pub trait Source {
    type Slice: ?Sized + PartialEq + Eq + Debug;

    ...
}

To:

pub trait Source {
    type Slice<'source>: PartialEq + Eq + Debug;
}

The bigger issue is that Logos expects to be able to access continuous chunks of memory (there are hidden methods that are used just by the macro for that purpose), but I think it should still be doable by getting the first non-zero sized chunk of the RopeSlice.

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.

3 participants