Giter Club home page Giter Club logo

Comments (6)

woha avatar woha commented on June 29, 2024 1

@marklauter This works simply perfect!

Thank you very much for your time and help, highly appreciated.

Looks like I should start reading Graham Hutton's and Erik Meijer's paper as well - I wish you some enlightening moments reading it.

Once again - thank you!

from superpower.

marklauter avatar marklauter commented on June 29, 2024

I'm not 100% sure, but I think it's up to the "this parser" to be able to parse an empty or zero result.
parser.ManyDelim..
^ parser must be able to succeed with something like "" or "\0" input. Based on the error, I'd guess this is the TgwComCon parser.

This is based on my read of the ManyDelim... method

        public static TextParser<T[]> ManyDelimitedBy<T, U>(this TextParser<T> parser, TextParser<U> delimiter)
        {
            if (parser == null) throw new ArgumentNullException(nameof(parser));
            if (delimiter == null) throw new ArgumentNullException(nameof(delimiter));

            return parser.Then(first => delimiter.IgnoreThen(parser).Many().Select(rest => ArrayEnumerable.Cons(first, rest)))
                .OptionalOrDefault(Array.Empty<T>());
        }

from superpower.

woha avatar woha commented on June 29, 2024

Thank you @marklauter. I think you are totally correct.
I've tried that, but failed.
Could you please give me an example / idea of how to parse such an empty result?

from superpower.

marklauter avatar marklauter commented on June 29, 2024

Full disclosure, I'm new to parser combinators and am still working my way through Graham Hutton's and Erik Meijer's 1996 paper, but I will attempt a sample today after work.

from superpower.

marklauter avatar marklauter commented on June 29, 2024

I wrote a very simple tokenizer with a "null value" parser that recognizes consecutive ';' characters. The semicolons can be separated by whitespace. Readme shows output. I hope it's useful.

https://github.com/marklauter/superpower-delimited-combinator

from superpower.

marklauter avatar marklauter commented on June 29, 2024

I'm so glad this idea worked for you. Happy parsing.

from superpower.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.