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

Pest format bug #58

Open
kerstop opened this issue Apr 4, 2024 · 0 comments
Open

Pest format bug #58

kerstop opened this issue Apr 4, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@kerstop
Copy link

kerstop commented Apr 4, 2024

Describe the bug
using the editor on pest.rs I found a bug in the formater that creates an invalid schema

To Reproduce
Here is the link to the editor, clicking on format moves the closing } on the number rule into a comment.

https://pest.rs/?g=N4Ig5gTghgtjURALhAdQBIEkAqBRAygAoCCAwrgAQC8FA%2BsBQBQA6IFrFAPuyM8wC4duAOVyoAMplEBKCgF9mAOyUA3KABsArgFMKe-dQoNGAewBGAK20BjflwoJoAT3sBnfhACWisPY877ADMNV11uRU11dVkFRXMrWwM9GgZWYA4APyZ4m35aAAcoTwgKLJYQABpMihzbAqKIaQAqaQB%2BUp4FNljavMLiwwZ3Lx8O1iRqtS1dWMcoFyTBngBtSY0AstYqtiypnWaxkABdDliImDNtEqSUpQNWAFpWdqyKAHo3ildPMGVFPXKAAYhBQAOQARlBADooaCAJygjrEfCkTCYWgAEUwAHEcC0OuUodVkaj0VjcdgWi89B8KIFoLZPCY-npWLhWJxWNpquUANQgx6sNqlElozE4vHvT7aAAe%2BWZ2kUgkUsX8ukWS1YatOSmC6lCGpSPD1oR1igiUQ1mpAFvUZqUw28vit%2BhoABJUrw%2BLwdhRvIorrRHaMsqw%2BGHukp-YHg86DDQAAIMaMQIMeJ20awACwQTXkUfNMfTPkzOZKNCMd30AEJyuGffYw%2BGhUjhABNKvcJv1gndhtdr09gdvAUgMyjwKj5RsAcQUeCEDSTs8Zs81iaYkosXoXAADXFFOAABY5EuVUpKiBvPlNPxkCB0v99KwA%2B4neMjDwUzVLLkP8A5HkKon1ZEAoH%2BOYnA-ZZwShABWCoKDVRDbUQ8FtAeAA2I5gPuEBYwoAB3Tx%2BCzChtFcawoHybQABMKFokxNDMdRdAAR00Ex%2BAojgkBXb0OM8awAGsKDMCATEI-5AhMGUeO9MMVRAOQgA#editor 

Or here is the un-formated input.

WHITESPACE = _{ (" " | "\t" | NEWLINE) }

value       = { (object | array | string | true | false | null) }
object      = { "{" ~ (object_pair ~ ("," ~ object_pair)*)? ~ "}" }
object_pair = { string ~ ":" ~ value }
array       = { "[" ~ value ~ ("," ~ value)* ~ "]" }
number      = {
    "-"? ~  // sign
  ("0" | '1'..'9' ~ ASCII_DIGIT*) ~ ("." ~ ASCII_DIGIT*)? ~  // fraction
  "E"|"e" ~ ("+" | "-")? ~ASCII_DIGIT* // exponent
}
true        = { "true" }
false       = { "false" }
null        = { "null" }

string            = ${ "\"" ~ inner_string ~ "\"" }
inner_string      = @{ inner_string_char* }
inner_string_char =  {
    !("\"" | "\\") ~ ANY
  | "\\" ~ ("\"" | "\\" | "/" | "b" | "f" | "n" | "r" | "t")
  | "\\" ~ ("u" ~ ASCII_HEX_DIGIT{4})
}

Expected behavior
Running format should not change the semantics of the source

@kerstop kerstop added the bug Something isn't working label Apr 4, 2024
@tomtau tomtau transferred this issue from pest-parser/pest Apr 4, 2024
huacnlee added a commit to pest-parser/pest-fmt that referenced this issue Apr 5, 2024
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

2 participants