Replies: 10 comments
-
First step, let's look at the cycles in the grammar. The first one around
we can see how The cycles around Regarding a solution for this cycle one needs to analyse the context of these grammar rules and see what one can come up with, do you know how to tackle this? I'll take a look at the first cycle above and see whether I can come up with something when I have a bit more time. Further, considering the grammar and these issues I'm getting the idea that the grammar was actually a CFG and not a PEG, which also means that there might be other problems, i.e. other places where simply using the CFG as PEG does not create equivalent matching behaviour, have you in general looked into this for your ASN.1 grammar? |
Beta Was this translation helpful? Give feedback.
-
There might be more than one cycle containing |
Beta Was this translation helpful? Give feedback.
-
Yes, this grammar isn't PEG-based since ASN.1 is rather old (not even written in ABNF but in its own style of CFG-like grammar). |
Beta Was this translation helpful? Give feedback.
-
The good news is that yes, it is possible, however the bad news is that it can be difficult. As an example, have you looked at the comments at the beginning of |
Beta Was this translation helpful? Give feedback.
-
I do know you have the Lua grammar but didn't look into it yet. Now you've got me thrilled. :) |
Beta Was this translation helpful? Give feedback.
-
Thanks, just read it... now I understand "the bad news". :( bummer indeed as I'm not so grammar-friendly to come up with your trick applied there but at least I have an example to give it a try. Thanks a lot! P.S.: still I wouldn't mind to have pegtl::analyze improved a bit showing cycles in depth. :) |
Beta Was this translation helpful? Give feedback.
-
I just pushed a change that lets |
Beta Was this translation helpful? Give feedback.
-
Good luck with the CFG-to-PEG transformation, let us know if you get stuck and we'll see what we can do. You're at a good point if you now understand the "bad news"... |
Beta Was this translation helpful? Give feedback.
-
Final note: The grammar analysis does a good job of telling you that a problem exists, however the printed details on what and where exactly the problem are not always reliable, that's a long-term work-in-progress. |
Beta Was this translation helpful? Give feedback.
-
Thank you very much @ColinH! I'll try new
I really appretiate your generocity but will use it only as a last resort of course. :) |
Beta Was this translation helpful? Give feedback.
-
Hi gurus, was going to try use your master-piece to build ASN.1 compiler but after defining grammar in PEGTL it turned out to have a lot of cycle dependencies (loops) shown with pegtl::analyze:
Can you please give a hint how to resolve it? I mean how should I change grammar to get rid of such loops?
Beta Was this translation helpful? Give feedback.
All reactions