#FsAttoparsec
FsAttoparsec is a port of Attoparsec and scala-attoparsec.
A port of Bryan O'Sullivan's attoparsec from Haskell to F#
License: BSD 3-Clause "New" or "Revised" License
#FsAttoparsec
FsAttoparsec is a port of Attoparsec and scala-attoparsec.
fparsecのgetPosition
みたいなパーサー。
http://www.quanttec.com/fparsec/reference/charparsers.html#members.getPosition
バイナリをパースし、特定の要素を置き換える(例えば0x00で)処理を書きたい。そのためには位置を取得できる必要がある。
とりあえずはBinaryParserに対してあれば良いです。
Hi there,
I would be great to have a high-performance binary parser in F#. Are you considering maintaining and moving forward with this project?
val tuple2<'a, 'b, 'c>: Parser<'a, 'b> -> Parser<'a, 'c> -> Parser<'a, 'b * 'c>
let inline (.>>.) p1 p2 = tuple2 p1 p2
実装
let ba xs = Array.map byte xs
let ``-`` = bytes (ba [| '-' |])
let boundary b =
let parser = bytes b
(``-`` >>. ``-`` >>. parser) <|> parser
|>> ignore
テスト
[<TestCase("abc", "--abc", true)>]
[<TestCase("abc", "abc", true)>]
[<TestCase("abc", "--", false)>]
[<TestCase("abc", "abC", false)>]
[<TestCase("abc", "bac", false)>]
[<TestCase("abc", "---abc", false)>]
[<TestCase("--abc", "----abc", true)>]
[<TestCase("--abc", "--abc", true)>]
[<TestCase("--abc", "---abc", false)>]
let boundaryをparseできる(b: string, input: string, expected: bool) =
let actual =
match parse (boundary (ba b)) (ba input) with
| Done _ -> true
| _ -> false
actual |> should equal expected
"--abc" "--abc"のパターンが失敗する。
実装で選択の順番を入れ替えるとparser <|> (``-`` >>. ``-`` >>. parser)
成功する。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.