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

Allow Stdin to be used as input file for lrlex/nimbleparse #466

Merged
merged 2 commits into from
Aug 22, 2024

Conversation

ratmice
Copy link
Collaborator

@ratmice ratmice commented Aug 22, 2024

Working a small project where I wanted to run lrlex over some compressed data, it seemed like it would be nice
to do so without having to decompress using a temporary file... This implements it so you can do the the following

zcat compressed_stuff| lrlex foo.l -

Or a nimbleparse example that should work in the repository (echo -n to avoid newline)

echo -n "1 + 1" | target/release/nimbleparse lrpar/examples/calc_parsetree/src/calc.{l,y} -

@@ -26,14 +26,18 @@ fn usage(prog: &str, msg: &str) {
}

fn read_file(path: &str) -> String {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It might be worth noting here, that the read_file functions between lrlex and nimbleparse,
seem to have diverged in their argument types:

lrlex takes an &str, which nimbleparse takes an AsRef<Path>, and the difference effects these two implementations because there is no Path* implementation for PartialEq<&str>.

This explains why in lrlex I implemented the logic inside read_file, while in nimbleparse the logic ended up outside.

Copy link
Member

Choose a reason for hiding this comment

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

I'd be happy to see the two homogenised in a future PR!

@ltratt
Copy link
Member

ltratt commented Aug 22, 2024

Thanks -- this is good!

@ltratt ltratt added this pull request to the merge queue Aug 22, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 22, 2024
@ratmice
Copy link
Collaborator Author

ratmice commented Aug 22, 2024

Sorry, looks like I failed to rustfmt

@ltratt
Copy link
Member

ltratt commented Aug 22, 2024

Please squash.

@ratmice
Copy link
Collaborator Author

ratmice commented Aug 22, 2024

Squashed.

@ltratt ltratt added this pull request to the merge queue Aug 22, 2024
Merged via the queue into softdevteam:master with commit e750db4 Aug 22, 2024
2 checks passed
@ratmice ratmice deleted the stdin branch August 26, 2024 20:26
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.

2 participants