Skip to content

Instantly share code, notes, and snippets.

@aggieben
Created July 15, 2009 21:13
Show Gist options
  • Save aggieben/147999 to your computer and use it in GitHub Desktop.
Save aggieben/147999 to your computer and use it in GitHub Desktop.
#light
#r @"C:\Users\Ben\Development\.NET\FParsec\Build\Release\FParsecCS.dll"
#r @"C:\Users\Ben\Development\.NET\FParsec\Build\Release\FParsec.dll"
open FParsec.Primitives
open FParsec.CharParsers
let s0 = @"~01001~^~0100~^~Butter, salted~^~BUTTER,WITH SALT~^~~^~~^~Y~^~~^0^~~^6.38^4.27^8.79^3.87"
let s1 = "~01001~^~0100~^~Butter, salted~^~BUTTER,WITH SALT~^~~^~~^~Y~^~~^0^~~^6.38^4.27^8.79^3.87
~01002~^~0100~^~Butter, whipped, with salt~^~BUTTER,WHIPPED,WITH SALT~^~~^~~^~Y~^~~^0^~~^6.38^4.27^8.79^3.87
~01003~^~0100~^~Butter oil, anhydrous~^~BUTTER OIL,ANHYDROUS~^~~^~~^~Y~^~~^0^~~^6.38^4.27^8.79^3.87
~01004~^~0100~^~Cheese, blue~^~CHEESE,BLUE~^~~^~~^~Y~^~~^0^~~^6.38^4.27^8.79^3.87
~01005~^~0100~^~Cheese, brick~^~CHEESE,BRICK~^~~^~~^~Y~^~~^0^~~^6.38^4.27^8.79^3.87"
let fieldParser : Parser<string list,unit> = sepBy (manyChars (noneOf "^")) (pchar '^')
let lineBasedFieldParser : Parser<string list list, unit> = sepBy fieldParser unicodeNewline
//let result = run lineBasedFieldParser testString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment