-
-
Save cdunklau/588151dd6de2a040941d87e9eddb8c04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Eur = Struct.new(:euro, :cents) | |
euroParser = | |
# Lets first parse some digits | |
digits > | |
-> eur { | |
# Then parse a comma | |
char(',') >> | |
# Then parse some more digits | |
digits > | |
-> cents { | |
# Then an optional comma | |
maybe(char('€')) >> | |
# If everything has parsed, we can produce a new result. | |
pure Eur.new(eur, cents) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment