Skip to content

sebastianselander/QuasiParser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Btw

A lot of the code is taken from glguy's version of the same thing. This was mostly an opportunity to practice parsing and meta programming in Haskell

Example

CSV

Values are digits

[fmt|%d&(,)|]

This will parse 1,2,3,4,5 fine. To allow leading and trailing space we can do the following

[fmt|%d&(( )*,( )*)|]

Now we can parse 1,2, 3,2 , 4 just fine.

Can do much much more things too. Can't be arsed writing it all out atm.

E.g. to parse day 20 of advent of code

parser :: String -> [(String, [String])]
parser = [fmt|(((%y?%s)! -> %s&(, ))%n)*|]

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published