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

Home page example doesn't work as described #46

Open
eugenesvk opened this issue May 29, 2023 · 5 comments
Open

Home page example doesn't work as described #46

eugenesvk opened this issue May 29, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@eugenesvk
Copy link

eugenesvk commented May 29, 2023

upd: the website Editor should try to pick the semantically top-level rule instead of the first in an alphabetically sorted order, or if it's not possible, at least do this for the example from the homepage

Or maybe the easier option is to just document that the user needs to select the general rule manually

Describe the bug

I was trying out the example from the home page and instead of getting the error mentioned there got a working - alpha: "a"

To Reproduce

  1. add the grammar from the home page
alpha = { 'a'..'z' | 'A'..'Z' }
digit = { '0'..'9' }

ident = { (alpha | digit)+ }

ident_list = _{ !digit ~ ident ~ (" " ~ ident)+ }
          // ^
          // ident_list rule is silent (produces no tokens or error reports)
  1. paste ab *

Expected behavior

Get the error message

thread 'main' panicked at ' --> 1:1
  |
1 | ab *
  |    ^---
  |
  = expected ident', src/main.rs:12

Actual behavior

Happy parsing outcome - alpha: "a"

Additional context

@eugenesvk eugenesvk added the bug Something isn't working label May 29, 2023
@tomtau
Copy link
Contributor

tomtau commented May 29, 2023

@eugenesvk you may need to use the "ident_list" rule (instead of "alpha") -- i.e. select it in the web editor or use Rule::ident_list in your parser Rust code... then you should see the expected behavior.

@eugenesvk
Copy link
Author

Oh, I see, so it just doesn't select the most general rule by default, but defaults to the alphabetic sorting

I'm not sure it's possible to generically determine what the top-level rule is, but I think at least for the homepage example the preselection should do the right thing

@tomtau tomtau transferred this issue from pest-parser/pest May 29, 2023
@tomtau
Copy link
Contributor

tomtau commented May 29, 2023

Yeah, it's not possible to tell which rule is the top-level one, but perhaps the homepage editor could be pre-filled with that example. @nathanielknight wdyt?

@HoloTheDrunk
Copy link

Oh, I see, so it just doesn't select the most general rule by default, but defaults to the alphabetic sorting

Fairly certain it's actually just the one that's at the top, not the first in alphabetical order

@nathanielknight
Copy link
Contributor

@eugenesvk Thanks for the report; I'm sure you're not the only person who's been caught out by this UX issue.

I think adding this as a default example (perhaps with an explanatory comment) would be an improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants