lukaslueg / macro_railroad

A library to generate syntax diagrams for Rust macros.
MIT License
536 stars 11 forks source link

SynParsing(Error("unrecognized fragment specifier")) #25

Open Wandalen opened 2 years ago

Wandalen commented 2 years ago

Hi! Thanks, but does not work on my Firefox.

image

bjorn3 commented 2 years ago

The error seems to come from https://github.com/lukaslueg/macro_railroad/blob/9941de799eb0c2cc067351551ee67cce6b65a2fd/src/parser.rs#L252 The problem is probably that the pat_param fragment specifier of $pattern:pat_param isn't supported yet by macro_railroad. The fix would be to add a PatParam variant to the Fragment enum and then parse pat_param to this variant I think. pat_param was introduced in the rust 2021 edition. The latest commit to macro_railroad was from 2020.

lukaslueg commented 2 years ago

Yes, this is because the parser does not recognize or-patterns as defined in the 2021 editions. We need two things, at least:

The parser needs to be expanded here to add the PatParam, an appropriate lowering here (if needed), and - if a new lowering-pattern was added - a rule how to draw the pattern based on railroad here. We need test cases for the parser's behavior in all cases four cases (2018, 2021, pat_param, pat).