codewitch-honey-crisis / pck

The Parser Construction Kit ("Puck"): A Parser Generator and Grammar Translator in C#
https://www.codeproject.com/Articles/5165072/Pck-Code-Roundup-and-Quick-Start-Guide
MIT License
35 stars 3 forks source link

Empty rules not handling correctly in LALR #1

Open jdamen opened 4 years ago

jdamen commented 4 years ago

Describe the bug I noticed that empty rules in the pck are not handled correctly in LALR

To Reproduce Using following PCK content: programs: start whitespace: hidden

programs -> until_RUN RUN

until_RUN -> until_AT until_RUN until_RUN -> until_AT until_RUN -> until_AT -> RT until_AT -> ST

RUN= 'RUN' RT= 'RT' ST= 'ST' whitespace= '[ \t\r\n\f\v]+'

It parses correctly using the following content: RT RUN

But it does not parse correctly with the this content: RUN

while I think it should

codewitch-honey-crisis commented 4 years ago

I'll look into it, but LALR(1) support has always been a bit a dodgy in PCK. To be honest I don't know how to do it so I can't promise a fix

On Mon, Jan 27, 2020 at 1:40 PM Johan Damen notifications@github.com wrote:

Describe the bug I noticed that empty rules in the pck are not handled correctly in LALR

To Reproduce Using following PCK content: programs: start whitespace: hidden

programs -> until_RUN RUN

until_RUN -> until_AT until_RUN until_RUN -> until_AT until_RUN -> until_AT -> RT until_AT -> ST

RUN= 'RUN' RT= 'RT' ST= 'ST' whitespace= '[ \t\r\n\f\v]+'

It parses correctly using the following content: RT RUN

But it does not parse correctly with the this content: RUN

while I think it should

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/codewitch-honey-crisis/pck/issues/1?email_source=notifications&email_token=AD5ICVJ53PZWIIPJN4QOWRDQ75IGTA5CNFSM4KMISDT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IJBTHXA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD5ICVO67GFKFLSDKGRYA33Q75IGTANCNFSM4KMISDTQ .

codewitch-honey-crisis commented 4 years ago

Adding, you might have better luck with Parsley anyway. https://www.codeproject.com/Articles/5255746/Parse-Anything-Advanced-Parsley-Part-2

Unlike a LALR(1) parser you can override the parse if you have to so you can cajole it into parsing things like C# if you don't mind hand writing part of it.

On Mon, Jan 27, 2020 at 1:40 PM Johan Damen notifications@github.com wrote:

Describe the bug I noticed that empty rules in the pck are not handled correctly in LALR

To Reproduce Using following PCK content: programs: start whitespace: hidden

programs -> until_RUN RUN

until_RUN -> until_AT until_RUN until_RUN -> until_AT until_RUN -> until_AT -> RT until_AT -> ST

RUN= 'RUN' RT= 'RT' ST= 'ST' whitespace= '[ \t\r\n\f\v]+'

It parses correctly using the following content: RT RUN

But it does not parse correctly with the this content: RUN

while I think it should

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/codewitch-honey-crisis/pck/issues/1?email_source=notifications&email_token=AD5ICVJ53PZWIIPJN4QOWRDQ75IGTA5CNFSM4KMISDT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IJBTHXA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD5ICVO67GFKFLSDKGRYA33Q75IGTANCNFSM4KMISDTQ .