Skip to content

Instantly share code, notes, and snippets.

@cdunklau

cdunklau/f.rb Secret

Forked from dminuoso/ex.hs
Last active June 12, 2018 12:34
Show Gist options
  • Save cdunklau/588151dd6de2a040941d87e9eddb8c04 to your computer and use it in GitHub Desktop.
Save cdunklau/588151dd6de2a040941d87e9eddb8c04 to your computer and use it in GitHub Desktop.
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