datalust / superpower

A C# parser construction toolkit with high-quality error reporting
Apache License 2.0
1.05k stars 98 forks source link

Questions: My On Going Questions #130

Closed TheColonel2688 closed 3 years ago

TheColonel2688 commented 3 years ago

To continue the discussion. From https://github.com/sprache/Sprache/issues/169

I posted a general question on SO and haven't gotten a response yet.

https://stackoverflow.com/questions/66344163/superpower-create-parser-to-match-against-r-n-or-n-more-general-match

This is my code so far

TextParser<char[]> EndOfLine; //** Stuck here
TextParser<char> Pipe = Character.EqualTo('|');
TextParser<char[]> Text = Character.LetterOrDigit.Many();

TextParser<char[]> Heading = from _ in Character.EqualTo('#')
                     from name in Character.Letter.Many()
                     select name;

TextParser<char[]> ItemListParser = from _ in Heading
                                    from items in Text.ManyDelimitedBy<char[],char>(Pipe)
                                    from end in EndOfLine
                                    select new List<char[]>();
nblumhardt commented 3 years ago

Spotted the answer has now been posted on Stack Overflow 👍

TheColonel2688 commented 3 years ago

@nblumhardt

This question is bound to attract the wrath of the StackOverflow Horde so I'll ask it here.

Is there anything to make Pretty Print of your parsed model easier? Or is this 100% up to the user to do?

nblumhardt commented 3 years ago

Fair call! :-) .. No, there's nothing built-in.

TheColonel2688 commented 3 years ago

Thanks, that's what I figured but I thought I would check anyway.