Skip to content

Pest format bug #58

@kerstop

Description

@kerstop

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions