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

Prettier seems to have trouble with tags #3336

Open
OAGr opened this issue Aug 10, 2024 · 1 comment
Open

Prettier seems to have trouble with tags #3336

OAGr opened this issue Aug 10, 2024 · 1 comment
Labels
Bug Something isn't working Language Regarding Squiggle language semantics, distributions and function registry Prettier

Comments

@OAGr
Copy link
Contributor

OAGr commented Aug 10, 2024

Description of suggestion or shortcoming:

https://www.squiggle-language.com/playground?v=0.9.5#code=eNqdVs1u00AQfpWpe8BO05S0PaCIVggoSKhICHKre9gm68TgrIt3w48aH7nxCPByfRJmdnaddX6Ulotlz87PNzPf7PguGstMzAvzqhzLaBC90EZU5lVRajlO1aiSwsiLH7dyZITJSxWLkZmLIoEzuEsVgClfygG%2FAiykVZTjBX%2FnGbA67J2BPwMzlQrS6MJ%2FpxEcLE8P6PtmbmBSGnvErsB7koWWYKq5JHnd9RjeWqDVcCrUA%2BA83wXH6VkwpoQbCRMOgOpCtXA1jrYgu5RaPxDW%2BeNhFej98ZiGKEE8iwUF33NeVyOSWasTay1YOnwjUNZ43OIwI6XdHutUpaqaq6HUJjb4aMiWqY9SI1Xxm%2BS9TMUJyV1hlZghBntCr12W3gqNVB4Exmc2lDuWVVVWA0LdKOyxAuNvpBZjGqWRNawdzva4TKSSFdKEoH%2BUt2VlYovEgmI%2FusmGgZGqRtFlTgnlBXIsDrS7WFOzANNj7drmm4m8eKjlXmhKxlecdxrt7wO5gE%2Fz3GDdbD8ILdMLXKL00ukMS0MNpYidjtO1cQupJmYat%2FLbYP%2FBQthoGpRho%2Bkbm%2BxG06AOSWPRMnaYBp1O4%2FV6Y%2BeyspoJM2zSCDKihsXIj6XEVdQT%2FP7PL4Tm%2BHH%2F93caJTyKnAu%2FB9ZcZBKuuLVcJPpRFt47J3N4eAgXTNWOrcOa2UGT9RLMChJK%2B%2BgI3otcgf46zyeTQr4jCmQVQvpeVl9Wy9LScrzly2UAa7uh6%2FOki4B5n6kF3LnB9BIaRaj57hhLParym2CFLOdFu%2Fsx4JZn%2B0zc2gYhyd1FkbBuZYcO1R40iUv%2Fr6VBLq35b0ZplR7O1CqPSjUSJubQ3dBdAofnrPO5zFVsGxAl%2Fiq2LDRc2LDOPZKlypdm9dTLU8WNWD1nKbf6yE54ribEn1TNcMUX1EbAiZ%2FpAVz1u3DchZNrus%2BQIapdax8qZgq9t%2BZ23NwsXS0rGPvdk0ZToTkAfM%2FNFHhY4aQZTLB7gnHG4TxbfD1rmiQ92ivxSVKzkR9wjhVleYWFI1XINfTRd%2Bg0cHT19Nq56id120kDuBCBr9aiP94MOvR%2F7PwHfyAUahPqJqCWSJpxE3K5xE92x%2Bu7eP6%2FIn62IxiGQjYqTUvNTH%2FCN1Hg%2F8D2ZuhyJsOIVNkc9zqcw9Pa9YV%2BIOIdccel1OqJARcfTv8nJi7rUx%2FU%2FmRsiRqZKRbSTpOelvNibJfkCi36jgnHngm4C5Ko%2Fgdd058Y

You can see here that the @startClosed tags are different colors.

@OAGr OAGr added Bug Something isn't working Language Regarding Squiggle language semantics, distributions and function registry Prettier labels Aug 10, 2024
@github-project-automation github-project-automation bot moved this to 🆕 To prioritize in Main project Aug 10, 2024
@berekuk
Copy link
Collaborator

berekuk commented Aug 30, 2024

There are two problems here, both related to Lezer grammar (not Prettier).

  1. {|| ... was parsed as {, || (OR operator); I fixed this in e16dc56 (it's in my semantic-analysis branch, sorry, I should've sent it in a separate PR)

  2. Ambiguity around whitespace and end expressions, also mentioned here: Whitespace parser quirks #1736 (comment)

Basically, this is ambiguous without distinguishing between " " and "\n":

{
  x = [0]
  [0]
  [0]
}

Could be either { x=[0][0]; [0] } // returns [0] or { x=[0]; [0][0] } // returns 0. In practice, Peggy parser would just fail because it doesn't allow whitespace before [], but Lezer doesn't know that. It just behaves greedily, eats the entire x[0][0][0] and fails the block. This breaks the syntax in the following lines.

The problem is that whitespace tokens in Lezer are configured globally. There are some ways around that, but the grammar would become much more complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Language Regarding Squiggle language semantics, distributions and function registry Prettier
Projects
Status: 🆕 To prioritize
Development

No branches or pull requests

2 participants