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 multi-line recipe signatures #1266

Closed
casey opened this issue Jul 13, 2022 · 6 comments
Closed

Allow multi-line recipe signatures #1266

casey opened this issue Jul 13, 2022 · 6 comments

Comments

@casey
Copy link
Owner

casey commented Jul 13, 2022

This came up in #1265. We can do this without requiring a continuation of any kind, just ignore newlines when parsing recipe parameters.

Great first issue!

@neunenak
Copy link
Contributor

Hey @casey , I thought I'd take a crack at this. #1272 seems to work with at least one test justfile I've made - I'm still figuring out how the just codebase works, how tests work, etc., and I'm not sure if this is the best way to solve this parsing problem, so I don't want to call this ready for review just yet. I'd appreciate it if you had any suggestions about what to tell the parser to do here.

@casey
Copy link
Owner Author

casey commented Jul 22, 2022

Nice!

I think the difficulty with the approach in #1272 is that we want to ignore newlines in grammatical sub constructs. So here:

    loop {
        if self.next_is(Identifier) || self.next_is(Dollar) {
            positional.push(self.parse_parameter(ParameterKind::Singular)?);
        } else if self.next_is(Eol) {
            self.accept(Eol)?;
        } else {
            break;
        }
    }

We also want to ignore newlines in parameters, which would require a change to parse-parameter.

One potential solution is to switch the parser between eol-sensitive and non eol-sensitive mode. In non EOL sensitive modes, parser functions that checked for tokens/returned tokens would switch the TokenKind of line endings whitespace.

I'm not really sure which approach is better, it really depends on how gross the code is for each.

@jraygauthier
Copy link

One of the main pain point for me.

@laniakea64
Copy link
Contributor

@jraygauthier Why is it a main pain point to use \ or parentheses?

@jraygauthier
Copy link

@laniakea64: Lol, because I wasn't aware this has been fixed yet (as it appears in v1.15) and was using v1.13:

$ just build-debug-features
error: Unknown start of token:
   |
33 | build-debug-features: \
   |                       ^

$ just --version
just 1.13.0

I will upgrade a more recent > v1.15 version.

Now, to me this ticket should be marked as fixed by PR #1551, right? It might be a good idea to update Q/A #1265 as well.

@casey
Copy link
Owner Author

casey commented Jan 11, 2024

Yup, I think this can be closed.

@casey casey closed this as completed Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants