Giter VIP home page Giter VIP logo

Comments (7)

nblumhardt avatar nblumhardt commented on July 29, 2024 1

Closing this as stale since we haven't looped back to it in a while, but hope all's going well!

from superpower.

nblumhardt avatar nblumhardt commented on July 29, 2024

Hi!

The problem looks to be that at the end of the input, Cell will still match via the LiteralCellContent.Many() rule, and RecordTerminator will also match, because of the Parse.Return("").AtEnd() rule, meaning there would be an essentially infinite procession of empty records at the end of the input.

A quick fix (not sure about error message quality implications?) might be to remove the terminator part from Record, and make the final rule:

    public static readonly TextParser<IEnumerable<IEnumerable<string>>> Csv =
        Record.ManyDelimitedBy(NewLine).AtEnd().Select(x => x.AsEnumerable());

from superpower.

NLI-KelbyHunt avatar NLI-KelbyHunt commented on July 29, 2024

I figured the Parse.Return("").AtEnd() rule could potentially be hurting me.

Believe it or not, in my experimenting with this conversion, I have attempted what you suggested and it still fails with the same exception.

I am going to keep working on this today, any other suggestions appreciated.

from superpower.

NLI-KelbyHunt avatar NLI-KelbyHunt commented on July 29, 2024

Looks like it was the NewLine field/prop was causing my problem, even in my simpler non-quoted Csv parser.

I changed this line

static readonly TextParser<string> NewLine = Parse.Return(Environment.NewLine);

to

static readonly TextParser<TextSpan> NewLine = Span.EqualTo(Environment.NewLine);

It now works as intended and I am going to clean it up.

@nblumhardt Any chance you want a test or sample PR submitted?

from superpower.

nblumhardt avatar nblumhardt commented on July 29, 2024

Aha, great! I missed that one :-)

It'd be awesome if you can post the example somewhere we can link, but I don't think we should currently add more text-parser examples to this repo, since the general not-migrating-from-Sprache usage should probably be via TokenParser.

from superpower.

NLI-KelbyHunt avatar NLI-KelbyHunt commented on July 29, 2024

It'd be awesome if you can post the example somewhere we can link, but I don't think we should currently add more text-parser examples to this repo

No problem and makes sense. I will respond to this issue when I have a sample Gist created using TextParser method/style.

since the general not-migrating-from-Sprache usage should probably be via TokenParser.

Curious, are you saying the proper way to use Superpower is to preferably utilize the TokenParser instead of the built in TextParser's? Is that because Token parsers have better error messaging and reporting? Or?

I am going to keep practicing with this library and also make a simple TokenParser to handle CSV/TSV files. Perhaps when I feel comfortable with it you could review it one day? I know you're busy and I will never ask for immediate review. Just a big fan of your work, style, design and architecture.

from superpower.

nblumhardt avatar nblumhardt commented on July 29, 2024

Thanks! :D

I might have overstated the suggestion to start with token parsers; for simple things that stay simple, text parsers are probably just as good from the perspective of this library. Token parsers are able to make use of more features of Superpower, though, including the nicer error reporting and the easy handling of whitespace and comments. Not a big difference, but probably enough that I'd try starting with a token parser in most cases.

Keen to hear how you go, making the API as usable/approachable as Sprache's is an ongoing project :-) Cheers!

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.