I'm trying to make a parser using Sprache I'm using F#. All the examples I've ever seen for the library use the Linq query syntax. I tried to translate the linq to f# using the "query" computation expression, but I got lost there.
Here is a sample I've been using.
[TestClass]
public class tests
{
[TestMethod]
public void test()
{
var input = "\"this is text\"";
var content = Class1.Quoted.Parse(input);
Assert.AreEqual("this is text", content);
}
}
public class Class1
{
public static readonly Parser<string> Quoted =
(from open in Parse.Char('"')
from content in Parse.CharExcept('"').Many().Text()
from close in Parse.Char('"')
select content);
public static readonly Parser<string> Quoted2 =
Parse.Char('"').SelectMany(open =>
Parse.CharExcept('"').Many().Text(), ())
}
The obvious way to do it is to just translate the linq down to method calls, but I don't know how to do that. I tried looking at ILSpy, but that left me a bit confused.
How does the Linq query look as direct method calls?