j-mie6 / parsley

A fast and modern parser combinator library for Scala
https://j-mie6.github.io/parsley/
BSD 3-Clause "New" or "Revised" License
173 stars 15 forks source link

[Question] How to create a standalone parser for floating-point values? #217

Closed willowell closed 11 months ago

willowell commented 11 months ago

Hello!

How can I create a standalone parser for floating-point values? e.g.,

val double: Parsley[Double] = ???

I'm porting my Advent of Code solutions over to Scala and building a foundation for this year's Advent of Code. So, I would like to have a simple parser for floating-point values on-hand, just in case.

I see that I could create a parser for floating-point values by creating a lexer (as described here https://github.com/j-mie6/Parsley/wiki/Building-a-Parser-for-Haskell#lexing), but this feels a bit over-kill for my use-case.

Is this the best way to approach this with Parsley or is there a simpler way?

Thank you!