rspeele / fparsec-pipes Goto Github PK
View Code? Open in Web Editor NEWA set of operators for FParsec (http://www.quanttec.com/fparsec/) intended to simplify chaining parsers together.
License: MIT License
A set of operators for FParsec (http://www.quanttec.com/fparsec/) intended to simplify chaining parsers together.
License: MIT License
Here is some sample
not sure if I have configured one of the pipes wrong. also can we add a p<string>
or other means of capturing a whole line?
Users of my library graphql-net are attempting to deploy to SharePoint and having troubles because FParsec-Pipes is not signed on NuGet:
You probably know what I mean:
let num: Parser<int,unit> =
%% +.digits 1 -- +.digits 2 -- +.digits 3 -- +.digits 4 -- +.digits 5 -- +.digits 6 -- +.digits 7
-%> fun a b c d e f g -> f
I've been studying the library for a while now and though I'd ask how is it possible to get that precise -%> fun a b c d e f g -> f
dependent on the parsers used previously without pattern matching on tuples like in Fparsec?
Actually, I was sure being able to take the correct number of arguments at the end as if accumulating them would be something impossible in F#, but you proved me wrong. Of course, I've been studying the code, but it is not really obvious what is happening there and I am not sure how to come up with a minimalist example. I would not mind if you gave me a pointer. Thanks!
Edit: Actually, what the linkBeyond5
example does just dawned on me. It is similar to this:
let a = "asd"
let b = 2
let c = 'a'
let w = a |> (fun a b c -> c)
let e = b |> w
let r = c |> e
But still, the Pipes library takes all the arguments at the end, not at the start. How is that possible?
Edit2: I figured this out too. I asked because I thought I would not be able to do it, but I guess I did.
let a = "asd"
let b = 2
let c = 'a'
let w f = a |> f
let e f = b |> w f
let r f = c |> e f
r (fun a b c -> c)
You just pass in an argument acting as an accumulator. This does not explain everything, but now I understand what Pipes is doing. I feel like I have a firm basis now. Thanks for the novel idea. I'll definitely be using Pipes to write the parser I am about to do.
Yes, a deliberate pun on the #7's title :)
I am wondering why support for the framework had to go with the commits de52172 and 69fd979. FParsec itself still targets as low as net40 (I think F# 4.1 may generate code only for net45 and above, though). It also seems that these changes did not require any APIs beyond 1.6, if I am not mistaken, so 2.0 seems too high for a library.
One of these commits did away with the README.md and LICENSE files by the way. It's not clear if that was intentional.
I was having issues with the intro code in VSCode on Windows with the Ionide plugin.
Specifically:
// Parses
count digits and returns the result as an integer. let digits (count : int) = %% +.(qty.[count] * digit) -%> (String >> Int32.Parse)
was complaining about the (String >> Int32.Parse)
construct needing a type annotation to allow the String constructor to be resolved.
I ended up (after some assistance on fsharp slack) going with:
let digits (count : int) = %% +.(qty.[count] * digit) -%> (fun (chars:char[]) -> String(chars) |> Int32.Parse )
which worked for me
The included example project, Examples.SQLite, takes 25 seconds to compile on my PC. Most F# projects compile in 1-2 seconds.
This also makes Intellisense extremely sluggish. Finally, third party tools using F# compiler services, such as the F# Power Tools extension for Visual Studio, take ages to perform simple tasks.
I am so sorry to raise an issue. I can't, for the life me me, get even the most basic code to work. I have a horrible feeling that this has nothing to do with your code.
#I @"../packages/fparsec/lib/netstandard1.6"
#r @"fparseccs.dll"
#r @"fparsec.dll"
#I @"../packages/fparsec-pipes/lib/netstandard1.6"
#r @"fparsec-pipes.dll"
open FParsec
open FParsec.Pipes
open System
// Parses `count` digits and returns the result as an integer.
let digits (count : int) =
%% +.(qty.[count] * digit)
-|> (String >> Int32.Parse)
and I get this output when I run it in FSI
error FS0193: Could not load file or assembly 'FParsecCS, Version=1.0.3.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
Hi,
is it possible to support .NET Standard 2.0?
The project graphql-net depends on this library, i try to add support for .NET Standard 2.0 (see chkimes/graphql-net#34).
Started a PR as well: #6
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.