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

feat: Allow s & f strings to contain expressions #3280

Closed
wants to merge 1 commit into from

Conversation

max-sixty
Copy link
Member

This doesn't work at all, but using it to ask a question of the best way of doing #3279 — how can we parse an expression from within another parser?

Here's the relevant line: https://github.com/PRQL/prql/compare/main...max-sixty:prql:try-s-string-expr?expand=1#diff-f3825716552312a9ef9f74ba3196b570761c8907b541923cdd5f6f4dcebb677fR162-R164

@max-sixty max-sixty changed the title feat: Allow s-strings to contain expressions feat: Allow s & f strings to contain expressions Aug 8, 2023
@max-sixty
Copy link
Member Author

I think this isn't trivial, but I might be over-complicating it:

That's not a great road to go down and then realize it was all wrong, so I'll try and not proceed until someone else thinks that's reasonable...

@aljazerzen
Copy link
Member

I don't quite remember how this works, but I do remember that I wanted to make lexer recursive, but later realized that it is really not a good idea.

@max-sixty
Copy link
Member Author

I wanted to make lexer recursive, but later realized that it is really not a good idea.

OK interesting. Is this just a general thing that it's better to not have recursive lexers, or something specific?

If we want to parse expressions within strings, I guess we do need some sort of thing that resembles recursion, though there are a few possible forms.

@aljazerzen
Copy link
Member

That's because lexer a usually limited to operate on regular languages (i.e. whatever can be matched with a regular expression). This limitation is deliberate to limit the complexity of the code for the lexer and leave the recursive stuff to the parser.

@max-sixty
Copy link
Member Author

Yes, though if we want something like python f-strings, is there any way around having recursion in the lexer (or something that is functionally similar to recursion)? I had thought not...

@aljazerzen aljazerzen added the language-design Changes to PRQL-the-language label Oct 16, 2023
@max-sixty
Copy link
Member Author

As discussed on the dev call — no one is opposed to on principle, but @aljazerzen thinks it's not easy, so we should only do this if it's tractable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language-design Changes to PRQL-the-language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants